Clover coverage report - Code Coverage for tapestry-portlet release 4.0.2
Coverage timestamp: Thu Apr 13 2006 10:54:39 EDT
file stats: LOC: 94   Methods: 4
NCLOC: 48   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PortletMultipartDecoderImpl.java 0% 0% 0% 0%
coverage
 1    // Copyright 2006 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14    package org.apache.tapestry.portlet.multipart;
 15   
 16    import java.io.File;
 17    import java.util.List;
 18    import java.util.Map;
 19   
 20    import javax.portlet.ActionRequest;
 21   
 22    import org.apache.commons.fileupload.FileItemFactory;
 23    import org.apache.commons.fileupload.FileUploadException;
 24    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 25    import org.apache.commons.fileupload.portlet.PortletFileUpload;
 26    import org.apache.hivemind.ApplicationRuntimeException;
 27    import org.apache.tapestry.multipart.AbstractMultipartDecoder;
 28    import org.apache.tapestry.multipart.MultipartMessages;
 29   
 30    /**
 31    * @author Raphael Jean
 32    *
 33    */
 34    public class PortletMultipartDecoderImpl extends AbstractMultipartDecoder implements PortletMultipartDecoder {
 35   
 36    /* maximum size of file allowed to be uploaded */
 37    protected long _sizeMax = 10000000;
 38    /*
 39    * boolean check for whether someone has manually set
 40    * the maximum upload size directly on this service
 41    */
 42    protected boolean _sizeMaxSet = false;
 43   
 44  0 public ActionRequest decode(ActionRequest request) {
 45  0 _encoding = request.getCharacterEncoding();
 46   
 47  0 PortletFileUpload upload = createFileUpload();
 48   
 49  0 try
 50    {
 51  0 List fileItems = upload.parseRequest(request);
 52   
 53  0 processFileItems(fileItems);
 54    }
 55    catch (FileUploadException ex)
 56    {
 57  0 throw new ApplicationRuntimeException(MultipartMessages.unableToDecode(ex), ex);
 58    }
 59   
 60  0 Map parameterMap = buildParameterMap();
 61   
 62  0 return new UploadFormPortletParametersWrapper(request, parameterMap);
 63    }
 64   
 65  0 private PortletFileUpload createFileUpload() {
 66  0 FileItemFactory factory = new DiskFileItemFactory(_thresholdSize, new File(_repositoryPath));
 67  0 PortletFileUpload upload = new PortletFileUpload(factory);
 68   
 69    // set maximum file upload size
 70  0 upload.setSizeMax(_sizeMax);
 71   
 72  0 if (_encoding != null)
 73  0 upload.setHeaderEncoding(_encoding);
 74   
 75  0 return upload;
 76    }
 77   
 78    /**
 79    * {@inheritDoc}
 80    */
 81  0 public void setSizeMax(long sizeMax)
 82    {
 83  0 _sizeMaxSet = true;
 84  0 _sizeMax = sizeMax;
 85    }
 86   
 87    /**
 88    * {@inheritDoc}
 89    */
 90  0 public boolean isMaxSizeSet()
 91    {
 92  0 return _sizeMaxSet;
 93    }
 94    }