Coverage report

  %line %branch
org.apache.jetspeed.deployment.impl.StandardDeploymentObject
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.deployment.impl;
 18  
 
 19  
 import java.io.File;
 20  
 import java.io.IOException;
 21  
 import java.io.InputStream;
 22  
 import java.util.zip.ZipEntry;
 23  
 import java.util.zip.ZipFile;
 24  
 
 25  
 import org.apache.jetspeed.deployment.DeploymentObject;
 26  
 
 27  
 /**
 28  
  * <p>
 29  
  * DeploymentObject
 30  
  * </p>
 31  
  * 
 32  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
 33  
  * @version $Id: StandardDeploymentObject.java 516448 2007-03-09 16:25:47Z ate $
 34  
  */
 35  
 public class StandardDeploymentObject implements DeploymentObject
 36  
 {
 37  
     protected File    deploymentObject;
 38  
     protected ZipFile zipFile;
 39  
 
 40  
     /**
 41  
      * @throws IOException
 42  
      */
 43  
     public StandardDeploymentObject(File deploymentObject) throws FileNotDeployableException
 44  0
     {
 45  0
         if (verclass="keyword">ifyExtension(deploymentObject))
 46  
         {
 47  0
             this.deploymentObject = deploymentObject;
 48  
         }
 49  
         else
 50  
         {
 51  0
             throw new FileNotDeployableException("File type for " + deploymentObject.getName()
 52  
                                                  + " is not supported by StandardDeploymentObject.");
 53  
         }
 54  
 
 55  0
     }
 56  
 
 57  
     /**
 58  
      * <p>
 59  
      * close
 60  
      * </p>
 61  
      * 
 62  
      * @see org.apache.jetspeed.deployment.DeploymentObject#close()
 63  
      * @throws IOException
 64  
      */
 65  
     public void close() throws IOException
 66  
     {
 67  0
         if (zipFile != null)
 68  
         {
 69  0
             zipFile.close();
 70  0
             zipFile = null;
 71  
         }
 72  0
     }
 73  
 
 74  
     /**
 75  
      * <p>
 76  
      * getConfiguration
 77  
      * </p>
 78  
      * 
 79  
      * @see org.apache.jetspeed.deployment.DeploymentObject#getConfiguration(java.lang.String)
 80  
      * @param configPath
 81  
      * @return
 82  
      * @throws IOException
 83  
      */
 84  
     public InputStream getConfiguration(String configPath) throws IOException
 85  
     {
 86  0
         ZipFile zipFile = getZipFile();
 87  0
         ZipEntry entry = zipFile.getEntry(configPath);
 88  0
         if (entry != null)
 89  
         {
 90  0
             return zipFile.getInputStream(entry);
 91  
         }
 92  0
         return null;
 93  
     }
 94  
 
 95  
     /**
 96  
      * <p>
 97  
      * getName
 98  
      * </p>
 99  
      * 
 100  
      * @see org.apache.jetspeed.deployment.DeploymentObject#getName()
 101  
      * @return
 102  
      */
 103  
     public String getName()
 104  
     {
 105  0
         return deploymentObject.getName();
 106  
     }
 107  
 
 108  
     /**
 109  
      * <p>
 110  
      * getPath
 111  
      * </p>
 112  
      * 
 113  
      * @see org.apache.jetspeed.deployment.DeploymentObject#getPath()
 114  
      * @return
 115  
      */
 116  
     public String getPath()
 117  
     {
 118  0
         return deploymentObject.getAbsolutePath();
 119  
     }
 120  
 
 121  
     public ZipFile getZipFile() throws IOException
 122  
     {
 123  0
         if (zipFile == null)
 124  
         {
 125  0
             zipFile = new ZipFile(deploymentObject);
 126  
         }
 127  0
         return zipFile;
 128  
     }
 129  
 
 130  
     public File getFile()
 131  
     {
 132  0
         return deploymentObject;
 133  
     }
 134  
 
 135  
     protected boolean verifyExtension(File file)
 136  
     {
 137  0
         String fileName = file.getName();
 138  0
         int dot = fileName.lastIndexOf('.');
 139  0
         if (dot != -1)
 140  
         {
 141  0
             String ext = fileName.substring(dot);
 142  0
             return ext.equals(".war") || ext.equals(".jar") || ext.equals(".zip");
 143  
         }
 144  
         else
 145  
         {
 146  0
             return false;
 147  
         }
 148  
     }
 149  
 
 150  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.