http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java index df64812..d692f4a 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java @@ -19,6 +19,14 @@ package org.apache.oodt.cas.product.data; //JDK imports + +import org.apache.oodt.cas.filemgr.structs.Product; +import org.apache.oodt.cas.filemgr.structs.ProductType; +import org.apache.oodt.cas.filemgr.structs.Reference; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.SerializableMetadata; +import org.apache.oodt.cas.product.exceptions.CasProductException; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -35,11 +43,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; //OODT imports -import org.apache.oodt.cas.filemgr.structs.Product; -import org.apache.oodt.cas.filemgr.structs.ProductType; -import org.apache.oodt.cas.filemgr.structs.Reference; -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.metadata.SerializableMetadata; /** * @@ -62,7 +65,7 @@ public final class DataUtils implements DataDeliveryKeys { }; public static String createDatasetZipFile(ProductType type, - String workingDirPath) throws Exception { + String workingDirPath) throws IOException, CasProductException { String datasetZipFileName = type.getName() + ".zip"; workingDirPath += workingDirPath.endsWith("/") ? "" : "/"; String datasetZipFilePath = workingDirPath + datasetZipFileName; @@ -85,7 +88,7 @@ public final class DataUtils implements DataDeliveryKeys { File[] productZipFiles = new File(workingDirPath).listFiles(ZIP_FILTER); if (productZipFiles == null || productZipFiles.length == 0) { - throw new Exception("No product zip files to include in dataset: [" + throw new CasProductException("No product zip files to include in dataset: [" + type.getName() + "]"); } @@ -121,7 +124,7 @@ public final class DataUtils implements DataDeliveryKeys { } public static String createProductZipFile(Product product, Metadata metadata, - String workingDirPath) throws Exception { + String workingDirPath) throws IOException { String productZipFileName = product.getProductName() + ".zip"; workingDirPath += workingDirPath.endsWith("/") ? "" : "/"; String productZipFilePath = workingDirPath + productZipFileName; @@ -201,7 +204,7 @@ public final class DataUtils implements DataDeliveryKeys { } private static void addMetFileToProductZip(Metadata productMet, - String metFileBaseName, ZipOutputStream out) throws Exception { + String metFileBaseName, ZipOutputStream out) throws IOException { // get the product metadata, and add its met file to the stream ByteArrayOutputStream metOut = new ByteArrayOutputStream();
http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/exceptions/CasProductException.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/exceptions/CasProductException.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/exceptions/CasProductException.java new file mode 100644 index 0000000..c6f9d9c --- /dev/null +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/exceptions/CasProductException.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.oodt.cas.product.exceptions; + +/** + * CasProductException for internal exceptions + */ +public class CasProductException extends Exception { + + public CasProductException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java index 9b4560b..534cd16 100755 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java @@ -17,26 +17,13 @@ package org.apache.oodt.cas.product.jaxrs.services; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.servlet.ServletContext; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; - import org.apache.oodt.cas.filemgr.structs.FileTransferStatus; import org.apache.oodt.cas.filemgr.structs.Product; import org.apache.oodt.cas.filemgr.structs.ProductType; import org.apache.oodt.cas.filemgr.structs.Reference; import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient; import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.product.exceptions.CasProductException; import org.apache.oodt.cas.product.jaxrs.exceptions.BadRequestException; import org.apache.oodt.cas.product.jaxrs.exceptions.NotFoundException; import org.apache.oodt.cas.product.jaxrs.resources.DatasetResource; @@ -45,6 +32,20 @@ import org.apache.oodt.cas.product.jaxrs.resources.ReferenceResource; import org.apache.oodt.cas.product.jaxrs.resources.TransferResource; import org.apache.oodt.cas.product.jaxrs.resources.TransfersResource; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.ServletContext; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; + /** * Service class that handles HTTP requests and returns file manager entities * such as {@link Reference references} and {@link Product products} as @@ -329,8 +330,7 @@ public class CasProductJaxrsService * @throws Exception if an object cannot be retrieved from the context * attribute */ - public File getContextWorkingDir() throws Exception - { + public File getContextWorkingDir() throws CasProductException { Object workingDirObject = context.getAttribute("workingDir"); if (workingDirObject != null && workingDirObject instanceof File) { @@ -340,7 +340,7 @@ public class CasProductJaxrsService String message = "Unable to get the file manager's working " + "directory from the servlet context."; LOGGER.log(Level.WARNING, message); - throw new Exception(message); + throw new CasProductException(message); } @@ -352,8 +352,7 @@ public class CasProductJaxrsService * attribute */ public XmlRpcFileManagerClient getContextClient() - throws Exception - { + throws CasProductException { // Get the file manager client from the servlet context. Object clientObject = context.getAttribute("client"); if (clientObject != null && @@ -365,6 +364,6 @@ public class CasProductJaxrsService String message = "Unable to get the file manager client from the " + "servlet context."; LOGGER.log(Level.WARNING, message); - throw new Exception(message); + throw new CasProductException(message); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java b/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java new file mode 100644 index 0000000..9a4f765 --- /dev/null +++ b/xmlps/src/main/java/org/apache/oodt/xmlps/exceptions/XmlpsException.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.oodt.xmlps.exceptions; + +/** + * XmlpsException for internally thrown exceptions. + */ +public class XmlpsException extends Exception { + + public XmlpsException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java index e24acd7..fb0e9c5 100644 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java +++ b/xmlps/src/main/java/org/apache/oodt/xmlps/mapping/MappingReader.java @@ -18,12 +18,20 @@ package org.apache.oodt.xmlps.mapping; //OODT imports + import org.apache.oodt.commons.xml.XMLUtils; +import org.apache.oodt.xmlps.exceptions.XmlpsException; import org.apache.oodt.xmlps.mapping.funcs.MappingFunc; import org.apache.oodt.xmlps.util.GenericCDEObjectFactory; -import org.w3c.dom.*; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.List; @@ -43,7 +51,7 @@ public final class MappingReader implements MappingReaderMetKeys { throw new InstantiationException("Don't construct reader objects!"); } - public static Mapping getMapping(InputStream is) throws Exception { + public static Mapping getMapping(InputStream is) throws XmlpsException { Document mappingDoc = XMLUtils.getDocumentRoot(is); Mapping map = new Mapping(); @@ -58,20 +66,20 @@ public final class MappingReader implements MappingReaderMetKeys { } - public static Mapping getMapping(URL mappingUrl) throws Exception { + public static Mapping getMapping(URL mappingUrl) throws IOException, XmlpsException { return getMapping(mappingUrl.openStream()); } - public static Mapping getMapping(String filePath) throws Exception { + public static Mapping getMapping(String filePath) throws FileNotFoundException, XmlpsException { return getMapping(new FileInputStream(filePath)); } private static void readTables(Element rootElem, Mapping map) - throws Exception { + throws XmlpsException { Element tblsElem = XMLUtils.getFirstElement(TABLES_OUTER_TAG, rootElem); if (tblsElem == null) { - throw new Exception("Unable to parse mapping XML file: [" + map.getName() + throw new XmlpsException("Unable to parse mapping XML file: [" + map.getName() + "]: reason: no defined tables tag element!"); } @@ -79,7 +87,7 @@ public final class MappingReader implements MappingReaderMetKeys { String defaultTbl = tblsElem.getAttribute("default"); // make sure that the default attribute is set if (defaultTbl == null || (defaultTbl.equals(""))) { - throw new Exception("Unable to parse mapping XML file: [" + map.getName() + throw new XmlpsException("Unable to parse mapping XML file: [" + map.getName() + "]: reason: there needs to be a default table defined " + "by the \"default\" attribute!"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java b/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java index 4ec85fe..9f27c94 100644 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java +++ b/xmlps/src/main/java/org/apache/oodt/xmlps/product/XMLPSProductHandler.java @@ -18,8 +18,10 @@ package org.apache.oodt.xmlps.product; //OODT imports + import org.apache.oodt.product.ProductException; import org.apache.oodt.product.QueryHandler; +import org.apache.oodt.xmlps.exceptions.XmlpsException; import org.apache.oodt.xmlps.mapping.DatabaseTable; import org.apache.oodt.xmlps.mapping.FieldScope; import org.apache.oodt.xmlps.mapping.Mapping; @@ -132,7 +134,7 @@ public class XMLPSProductHandler implements QueryHandler { return query; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws InstantiationException, ProductException { String usage = "XMLPSProductHandler <query>\n"; if (args.length != 1) { @@ -276,7 +278,7 @@ public class XMLPSProductHandler implements QueryHandler { } protected void translateToDomain(List<QueryElement> elemSet, - boolean selectSet) throws Exception { + boolean selectSet) throws XmlpsException { // go through each query element: use the mapping fields // to translate the names @@ -318,7 +320,7 @@ public class XMLPSProductHandler implements QueryHandler { break; QueryElement litElem = i.next(); if (!litElem.getRole().equals(XMLQueryHelper.ROLE_LITERAL)) { - throw new Exception("next query element not " + throw new XmlpsException("next query element not " + XMLQueryHelper.ROLE_LITERAL + "! role is " + litElem.getRole() + " instead!"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java ---------------------------------------------------------------------- diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java b/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java index 5f66e14..7f2987f 100644 --- a/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java +++ b/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java @@ -17,15 +17,18 @@ package org.apache.oodt.xmlps.profile; -//OODT imports +import org.apache.oodt.profile.Profile; +import org.apache.oodt.profile.ProfileException; +import org.apache.oodt.profile.handlers.ProfileHandler; +import org.apache.oodt.xmlps.exceptions.XmlpsException; import org.apache.oodt.xmlps.mapping.DatabaseTable; import org.apache.oodt.xmlps.mapping.MappingReader; import org.apache.oodt.xmlps.product.XMLPSProductHandler; -import org.apache.oodt.xmlps.profile.DBMSExecutor; import org.apache.oodt.xmlps.queryparser.Expression; import org.apache.oodt.xmlps.queryparser.HandlerQueryParser; +import org.apache.oodt.xmlquery.QueryElement; +import org.apache.oodt.xmlquery.XMLQuery; -//JDK imports import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -35,12 +38,6 @@ import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; -//OODT imports -import org.apache.oodt.profile.Profile; -import org.apache.oodt.profile.ProfileException; -import org.apache.oodt.profile.handlers.ProfileHandler; -import org.apache.oodt.xmlquery.QueryElement; -import org.apache.oodt.xmlquery.XMLQuery; /** * @@ -196,7 +193,7 @@ public class XMLPSProfileHandler extends XMLPSProductHandler implements } protected void translateToDomain(List<QueryElement> elemSet, - boolean selectSet) throws Exception { + boolean selectSet) throws XmlpsException { super.translateToDomain(elemSet, selectSet); }
