OODT-909 create improved exceptions
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/daf0904a Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/daf0904a Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/daf0904a Branch: refs/heads/master Commit: daf0904a625d7fb52a435f3a1506c5ddd5b7cc40 Parents: 4ed2a42 Author: Tom Barber <[email protected]> Authored: Tue Oct 27 17:02:31 2015 +0000 Committer: Tom Barber <[email protected]> Committed: Tue Oct 27 17:02:31 2015 +0000 ---------------------------------------------------------------------- CHANGES.txt | 32 +++++++++++++++- .../oodt/cas/workflow/gui/WorkflowGUI.java | 3 +- .../model/repo/XmlWorkflowModelRepository.java | 37 +++++++++++-------- .../gui/util/exceptions/WorkflowException.java | 27 ++++++++++++++ .../org/apache/oodt/commons/ExecServer.java | 12 ++++-- .../oodt/commons/activity/ActivityTracker.java | 2 +- .../org/apache/oodt/commons/date/DateUtils.java | 25 +++++++------ .../commons/exceptions/CommonsException.java | 11 ++++++ .../apache/oodt/commons/exec/EnvUtilities.java | 2 +- .../org/apache/oodt/commons/util/Base64.java | 3 +- .../org/apache/oodt/commons/util/DOMParser.java | 16 ++++++-- .../org/apache/oodt/commons/util/LogInit.java | 11 ++++-- .../org/apache/oodt/commons/xml/DOMUtil.java | 7 ++-- .../cas/crawl/AutoDetectProductCrawler.java | 13 +++++-- .../cas/crawl/MetExtractorProductCrawler.java | 13 +++---- .../oodt/cas/crawl/StdProductCrawler.java | 3 +- .../cas/crawl/action/EmailNotification.java | 21 +++++------ .../oodt/cas/crawl/action/IngestAncillary.java | 3 +- .../cas/crawl/daemon/CrawlDaemonController.java | 8 ++-- .../MimeExtractorConfigReader.java | 32 +++++++++++++--- .../cas/curation/service/MetadataResource.java | 6 ++- .../curation/util/CurationXmlStructFactory.java | 11 ++++-- .../util/exceptions/CurationException.java | 11 ++++++ .../exceptions/CasMetadataException.java | 27 ++++++++++++++ .../oodt/cas/metadata/util/PathUtils.java | 39 ++++++++++---------- .../apache/oodt/pcs/tools/PCSHealthMonitor.java | 2 +- .../apache/oodt/pcs/tools/PCSLongLister.java | 5 ++- .../org/apache/oodt/pcs/tools/PCSTrace.java | 19 +++++----- .../cas/pushpull/daemon/DaemonController.java | 2 +- .../exceptions/RetrievalMethodException.java | 4 ++ .../parsers/DirStructXmlParser.java | 5 ++- .../pushpull/retrievalmethod/ListRetriever.java | 6 ++- .../pushpull/retrievalmethod/RemoteCrawler.java | 9 ++++- .../resource/exceptions/ResourceException.java | 31 ++++++++++++++++ .../cas/resource/monitor/utils/MockGmetad.java | 2 +- .../resource/system/XmlRpcResourceManager.java | 9 ++--- .../resource/system/extern/XmlRpcBatchStub.java | 4 +- .../oodt/cas/resource/tools/JobSubmitter.java | 3 +- .../cas/resource/tools/RunDirJobSubmitter.java | 18 +++++---- .../apache/oodt/cas/resource/util/Ulimit.java | 13 ++++--- .../apache/oodt/security/sso/OpenSSOImpl.java | 8 ++-- .../oodt/security/sso/opensso/SSOProxy.java | 14 +++---- .../sso/opensso/SingleSignOnException.java | 11 ++++++ .../apache/oodt/cas/product/data/DataUtils.java | 21 ++++++----- .../product/exceptions/CasProductException.java | 27 ++++++++++++++ .../jaxrs/services/CasProductJaxrsService.java | 39 ++++++++++---------- .../oodt/xmlps/exceptions/XmlpsException.java | 27 ++++++++++++++ .../oodt/xmlps/mapping/MappingReader.java | 22 +++++++---- .../oodt/xmlps/product/XMLPSProductHandler.java | 8 ++-- .../oodt/xmlps/profile/XMLPSProfileHandler.java | 17 ++++----- 50 files changed, 495 insertions(+), 206 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 4534d27..11158a9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,9 +23,37 @@ Release 0.11 - Current Development * OODT-892 Tidy up null assignments (magicaltrout) -* OODT-755 Fix error message in FM client when ingestion fails +* OODT-755 Fix error message in FM client when ingestion fails - code quality from sonar (magicaltrout) -* OODT-894 Remove inefficient constructors +* OODT-894 Remove inefficient constructors - code quality from sonar (magicaltrout) + +* OODT-909 create more explicit exceptions - code quality from sonar (magicaltrout) + +* OODT-907 remove never queries collections - code quality from sonar (magicaltrout) + +* OODT-906 remove redundant assignments - code quality from sonar (magicaltrout) + +* OODT-904 remove redundant throws - code quality from sonar (magicaltrout) + +* OODT-903 simplify flows - code quality from sonar (magicaltrout) + +* OODT-902 remove redundant modifiers from enums - code quality from sonar (magicaltrout) + +* OODT-901 resolve javadoc issues - code quality from sonar (magicaltrout) + +* OODT-900 remove boxing/unboxing etc in code - code quality from sonar (magicaltrout) + +* OODT-899 remove redundant local variables - code quality from sonar (magicaltrout) + +* OODT-898 remove redundant finals - code quality from sonar (magicaltrout) + +* OODT-897 remove module dependencies - code quality from sonar (magicaltrout) + +* OODT-896 remove interface modifers - code quality from sonar (magicaltrout) + +* OODT-895 remove redundant measure unit - code quality from sonar (magicaltrout) + +* OODT-894 tidy up inefficient constructors - code quality from sonar (magicaltrout) Release 0.10 - 08/30/2015 http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java ---------------------------------------------------------------------- diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java index 454b5fc..13ba5f0 100644 --- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java +++ b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java @@ -41,6 +41,7 @@ import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.event.WindowFocusListener; import java.io.File; +import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -74,7 +75,7 @@ public class WorkflowGUI extends JFrame { private XmlWorkflowModelRepository repo; - public WorkflowGUI() throws Exception { + public WorkflowGUI() throws IOException, IllegalAccessException, InstantiationException { this.addWindowFocusListener(new WindowFocusListener() { http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java ---------------------------------------------------------------------- diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java index f1d663b..e43a305 100644 --- a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java +++ b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java @@ -18,14 +18,24 @@ package org.apache.oodt.cas.workflow.gui.model.repo; //OODT imports + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.apache.oodt.cas.metadata.Metadata; import org.apache.oodt.cas.workflow.gui.model.ModelGraph; import org.apache.oodt.cas.workflow.gui.model.ModelNode; +import org.apache.oodt.cas.workflow.gui.util.exceptions.WorkflowException; import org.apache.oodt.commons.xml.XMLUtils; +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 org.xml.sax.SAXException; -//JDK imports import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -44,14 +54,10 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -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; + +//JDK imports /** * @@ -77,7 +83,8 @@ public class XmlWorkflowModelRepository { this.files.add(file); } - public void loadGraphs(Set<String> supportedProcessorIds) throws Exception { + public void loadGraphs(Set<String> supportedProcessorIds) + throws XPathExpressionException, WorkflowException, IOException, SAXException, ParserConfigurationException { this.graphs = new HashSet<ModelGraph>(); HashMap<String, ConfigGroup> globalConfGroups = new HashMap<String, ConfigGroup>(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -126,12 +133,12 @@ public class XmlWorkflowModelRepository { return this.files; } - public void save() throws Exception { + public void save() throws IOException, ParserConfigurationException { this.backupCurrentFiles(); this.saveGraphs(); } - private void backupCurrentFiles() throws Exception { + private void backupCurrentFiles() throws IOException { File backupDir = new File(this.workspace, ".backup"); for (File file : this.files) { FileUtils.copyFile(file, new File(backupDir, file.getName())); @@ -308,7 +315,7 @@ public class XmlWorkflowModelRepository { private ModelGraph loadGraph(List<FileBasedElement> rootElements, FileBasedElement workflowNode, Metadata staticMetadata, HashMap<String, ConfigGroup> globalConfGroups, - Set<String> supportedProcessorIds) throws Exception { + Set<String> supportedProcessorIds) throws XPathExpressionException, WorkflowException { String modelIdRef = null; String modelId = null; @@ -427,7 +434,7 @@ public class XmlWorkflowModelRepository { graph = this.findGraph(rootElements, modelIdRef, new Metadata( staticMetadata), globalConfGroups, supportedProcessorIds); if (graph == null) - throw new Exception("Workflow '" + modelIdRef + throw new WorkflowException("Workflow '" + modelIdRef + "' has not been defined in this context"); graph.setIsRef(true); graph.getModel().setStaticMetadata(new Metadata()); @@ -446,7 +453,7 @@ public class XmlWorkflowModelRepository { protected ModelGraph findGraph(List<FileBasedElement> rootElements, String modelIdRef, Metadata staticMetadata, HashMap<String, ConfigGroup> globalConfGroups, - Set<String> supportedProcessorIds) throws Exception { + Set<String> supportedProcessorIds) throws XPathExpressionException, WorkflowException { XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//*[@id = '" + modelIdRef + "']"); for (FileBasedElement rootElement : rootElements) { @@ -463,7 +470,7 @@ public class XmlWorkflowModelRepository { private void loadConfiguration(List<FileBasedElement> rootElements, FileBasedElement workflowNode, ModelNode modelNode, - HashMap<String, ConfigGroup> globalConfGroups) throws Exception { + HashMap<String, ConfigGroup> globalConfGroups) { NodeList children = workflowNode.getElement().getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node curChild = children.item(i); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/exceptions/WorkflowException.java ---------------------------------------------------------------------- diff --git a/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/exceptions/WorkflowException.java b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/exceptions/WorkflowException.java new file mode 100644 index 0000000..87edb1a --- /dev/null +++ b/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/exceptions/WorkflowException.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.workflow.gui.util.exceptions; + +/** + * Workflow Exception for internal Exceptions. + */ +public class WorkflowException extends Exception { + + public WorkflowException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java index 3c6f1d5..3a03290 100644 --- a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java +++ b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java @@ -22,8 +22,13 @@ import org.apache.oodt.commons.util.LogInit; import org.apache.oodt.commons.util.PropertyMgr; import org.apache.oodt.commons.util.XML; import org.apache.xmlrpc.XmlRpcClientLite; +import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcServer; -import org.w3c.dom.*; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -141,8 +146,6 @@ public class ExecServer { } catch (SAXException ex) { System.err.println("Error " + ex.getClass().getName() + " while attempting to parse the configuration" + " file: " + ex.getMessage()); - } catch (javax.naming.NamingException ex) { - System.err.println("Naming/directory error: " + ex.getClass().getName() + ": " + ex.getMessage()); } catch (java.lang.reflect.InvocationTargetException ex) { Throwable target = ex.getTargetException(); System.err.println("Constructor for \"" + className + "\" threw " + target.getClass().getName() + ": " @@ -313,7 +316,8 @@ public class ExecServer { * @return The return value from the method named by <var>method</var>. * @throws Exception If any error occurs. */ - public Object callLocalServerManager(int port, String user, String password, String method, List params) throws Exception { + public Object callLocalServerManager(int port, String user, String password, String method, List params) + throws IOException, XmlRpcException { XmlRpcClientLite local = new XmlRpcClientLite("localhost", port); local.setBasicAuthentication(user, password); return local.execute(method, new Vector(params)); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/activity/ActivityTracker.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/activity/ActivityTracker.java b/commons/src/main/java/org/apache/oodt/commons/activity/ActivityTracker.java index 8bd9f9f..4af6812 100644 --- a/commons/src/main/java/org/apache/oodt/commons/activity/ActivityTracker.java +++ b/commons/src/main/java/org/apache/oodt/commons/activity/ActivityTracker.java @@ -59,7 +59,7 @@ public class ActivityTracker { * * @throws Exception if an error occurs. */ - static void initializeFactories() throws Exception { + static void initializeFactories() throws IllegalAccessException, InstantiationException, ClassNotFoundException { String facNames = System.getProperty("org.apache.oodt.commons.activity.factories", System.getProperty("activity.factories", "")); List factories = new ArrayList(); for (StringTokenizer tokens = new StringTokenizer(facNames, ",|"); tokens.hasMoreTokens();) { http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/date/DateUtils.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/date/DateUtils.java b/commons/src/main/java/org/apache/oodt/commons/date/DateUtils.java index cd22509..ad854ed 100644 --- a/commons/src/main/java/org/apache/oodt/commons/date/DateUtils.java +++ b/commons/src/main/java/org/apache/oodt/commons/date/DateUtils.java @@ -19,6 +19,9 @@ package org.apache.oodt.commons.date; //JDK imports + +import org.apache.oodt.commons.exceptions.CommonsException; + import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -95,16 +98,16 @@ public class DateUtils { private DateUtils() {} - public static int getLeapSecsForDate(Calendar utcCal) throws Exception { + public static int getLeapSecsForDate(Calendar utcCal) throws CommonsException { long timeInMillis = utcCal.getTimeInMillis(); for (int i = dateAndLeapSecs.length - 1; i >= 0; i--) { if (dateAndLeapSecs[i][IndexType.DATE.index] < timeInMillis) return (int) dateAndLeapSecs[i][IndexType.LEAP_SECS.index]; } - throw new Exception("No Leap Second found for given date!"); + throw new CommonsException("No Leap Second found for given date!"); } - public static synchronized Calendar toTai(Calendar cal) throws Exception { + public static synchronized Calendar toTai(Calendar cal) throws CommonsException { Calendar taiCal = Calendar.getInstance(createTaiTimeZone(getLeapSecsForDate(cal))); taiCal.setTimeInMillis(cal.getTimeInMillis() + getLeapSecsForDate(cal) * 1000); return taiCal; @@ -116,11 +119,11 @@ public class DateUtils { return calUtc; } - private static Calendar taiToLocal(Calendar taiCal) throws Exception { + private static Calendar taiToLocal(Calendar taiCal) { return toLocal(taiToUtc(taiCal)); } - public static synchronized Calendar toLocal(Calendar cal) throws Exception { + public static synchronized Calendar toLocal(Calendar cal) { if (cal.getTimeZone().getID().equals("TAI")) { return taiToLocal(cal); } else { @@ -130,7 +133,7 @@ public class DateUtils { } } - public static synchronized Calendar toUtc(Calendar cal) throws Exception { + public static synchronized Calendar toUtc(Calendar cal) { if (cal.getTimeZone().getID().equals("TAI")) { return taiToUtc(cal); } else { @@ -140,7 +143,7 @@ public class DateUtils { } } - public static Calendar getCurrentUtcTime() throws Exception { + public static Calendar getCurrentUtcTime() { return toUtc(getCurrentLocalTime()); } @@ -148,7 +151,7 @@ public class DateUtils { return Calendar.getInstance(); } - public static Calendar getCurrentTaiTime() throws Exception { + public static Calendar getCurrentTaiTime() throws CommonsException { return toTai(getCurrentUtcTime()); } @@ -197,7 +200,7 @@ public class DateUtils { return cal; } - public static double getTimeInSecs(Calendar cal, Calendar epoch) throws Exception { + public static double getTimeInSecs(Calendar cal, Calendar epoch) throws CommonsException { return getTimeInMillis(cal, epoch) / 1000.0; } @@ -205,7 +208,7 @@ public class DateUtils { return new DecimalFormat("#.000").format(seconds); } - public static long getTimeInMillis(Calendar cal, Calendar epoch) throws Exception { + public static long getTimeInMillis(Calendar cal, Calendar epoch) throws CommonsException { long epochDiffInMilli; /** * Fixes date conversion issues preventing tests passing in the UK but working elsewhere in the world. @@ -225,7 +228,7 @@ public class DateUtils { return new SimpleTimeZone(leapSecs * 1000, "TAI"); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws ParseException, CommonsException { Calendar curTime = getCurrentLocalTime(); System.out.println("Test Time: " + toString(toCalendar(toString(toTai(toCalendar("2008-01-20T16:29:55.000Z", FormatType.UTC_FORMAT))), FormatType.TAI_FORMAT))); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/exceptions/CommonsException.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/exceptions/CommonsException.java b/commons/src/main/java/org/apache/oodt/commons/exceptions/CommonsException.java new file mode 100644 index 0000000..25804bc --- /dev/null +++ b/commons/src/main/java/org/apache/oodt/commons/exceptions/CommonsException.java @@ -0,0 +1,11 @@ +package org.apache.oodt.commons.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class CommonsException extends Exception { + + public CommonsException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java b/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java index 9e0eafd..3979f32 100644 --- a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java +++ b/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java @@ -145,7 +145,7 @@ public final class EnvUtilities { } protected static InputStream preProcessInputStream(InputStream is) - throws Exception { + throws IOException { // basically read this sucker into a BufferedReader // line by line, and replaceAll on \ with \\ // so \\\\ with \\\\\\\\ http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/util/Base64.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/Base64.java b/commons/src/main/java/org/apache/oodt/commons/util/Base64.java index f10bede..fb1c7b3 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/Base64.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/Base64.java @@ -20,6 +20,7 @@ import org.apache.oodt.commons.io.Base64EncodingOutputStream; import java.io.BufferedInputStream; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -181,7 +182,7 @@ public class Base64 { * * @param argv Command-line arguments. */ - public static void main(String[] argv) throws Exception { + public static void main(String[] argv) throws IOException { if (argv.length < 1 || argv.length > 2) { System.err.println("Usage: encode|decode [file]"); System.exit(1); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java b/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java index 38ee748..0a9ad8b 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java @@ -16,10 +16,18 @@ package org.apache.oodt.commons.util; +import org.w3c.dom.Document; +import org.xml.sax.EntityResolver; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; + import java.io.IOException; -import java.util.*; -import org.xml.sax.*; -import org.w3c.dom.*; +import java.util.Locale; + import javax.xml.parsers.DocumentBuilder; /** An XML Document Object Model parser. @@ -73,7 +81,7 @@ public class DOMParser { } /** Resets or copies the parser. */ - public void resetOrCopy() throws Exception { + public void resetOrCopy() { reset(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java b/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java index 9c43f03..41d86aa 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java @@ -15,9 +15,13 @@ package org.apache.oodt.commons.util; -import java.util.*; -import org.apache.oodt.commons.io.*; +import org.apache.oodt.commons.io.Log; +import org.apache.oodt.commons.io.LogFilter; +import org.apache.oodt.commons.io.LogListener; + import java.beans.PropertyChangeEvent; +import java.util.Properties; +import java.util.StringTokenizer; /** The <code>LogInit</code> class is intended to be used to initialize @@ -51,7 +55,8 @@ public class LogInit { @param source The default source to be included in messages. @throws Exception If the logging capability cannot be initialized. */ - public static void init(Properties props, String source) throws Exception { + public static void init(Properties props, String source) + throws ClassNotFoundException, IllegalAccessException, InstantiationException { // Set up the log event pipeline: filter -> multiplexer -> memory // log/user-specified log. First the multiplexer. LogEventMultiplexer mux = new LogEventMultiplexer(); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java b/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java index 0343d27..1abc1b0 100644 --- a/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java +++ b/commons/src/main/java/org/apache/oodt/commons/xml/DOMUtil.java @@ -18,6 +18,7 @@ package org.apache.oodt.commons.xml; +import org.apache.oodt.commons.exceptions.CommonsException; import org.w3c.dom.NodeList; import org.w3c.dom.Node; import org.w3c.dom.Element; @@ -50,11 +51,11 @@ public class DOMUtil { * @return Element "element" with Name "name"'s first occurence. */ public static Element getFirstElement(Element element, String name) - throws Exception { + throws CommonsException { NodeList n1 = element.getElementsByTagName(name); if (n1.getLength() < 1) { - throw new Exception("Element: " + element + " does not contain: " + throw new CommonsException("Element: " + element + " does not contain: " + name); } @@ -75,7 +76,7 @@ public class DOMUtil { * @return the Text inbetween the simple element tags. */ public static String getSimpleElementText(Element node, String name) - throws Exception { + throws CommonsException { Element namedElement = getFirstElement(node, name); return getSimpleElementText(namedElement); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/AutoDetectProductCrawler.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/AutoDetectProductCrawler.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/AutoDetectProductCrawler.java index 232a63d..d937e9f 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/AutoDetectProductCrawler.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/AutoDetectProductCrawler.java @@ -17,16 +17,21 @@ package org.apache.oodt.cas.crawl; //OODT imports +import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; import org.apache.oodt.cas.crawl.typedetection.MetExtractorSpec; import org.apache.oodt.cas.crawl.typedetection.MimeExtractorConfigReader; import org.apache.oodt.cas.crawl.typedetection.MimeExtractorRepo; import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys; import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; +import org.apache.oodt.cas.metadata.exceptions.NamingConventionException; import org.apache.oodt.cas.metadata.filenaming.NamingConvention; import org.apache.oodt.cas.metadata.preconditions.PreCondEvalUtils; import org.springframework.beans.factory.annotation.Required; import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; import java.util.List; import java.util.logging.Level; @@ -69,7 +74,7 @@ public class AutoDetectProductCrawler extends ProductCrawler implements private MimeExtractorRepo mimeExtractorRepo; @Override - protected Metadata getMetadataForProduct(File product) throws Exception { + protected Metadata getMetadataForProduct(File product) throws IOException, MetExtractionException { List<MetExtractorSpec> specs = this.mimeExtractorRepo .getExtractorSpecsForFile(product); Metadata metadata = new Metadata(); @@ -116,7 +121,7 @@ public class AutoDetectProductCrawler extends ProductCrawler implements @Override protected File renameProduct(File product, Metadata productMetadata) - throws Exception { + throws NamingConventionException { String namingConventionId = mimeExtractorRepo .getNamingConventionId(mimeExtractorRepo.getMimeType(product)); if (namingConventionId != null) { @@ -129,7 +134,9 @@ public class AutoDetectProductCrawler extends ProductCrawler implements } @Required - public void setMimeExtractorRepo(String mimeExtractorRepo) throws Exception { + public void setMimeExtractorRepo(String mimeExtractorRepo) + throws IllegalAccessException, CrawlerActionException, MetExtractionException, InstantiationException, + FileNotFoundException, ClassNotFoundException { this.mimeExtractorRepo = MimeExtractorConfigReader .read(mimeExtractorRepo); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java index c8e8bc4..9e66c6d 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java @@ -16,20 +16,19 @@ */ package org.apache.oodt.cas.crawl; -//OODT imports +import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; import org.apache.oodt.cas.metadata.MetExtractor; import org.apache.oodt.cas.metadata.Metadata; import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; +import org.apache.oodt.cas.metadata.exceptions.NamingConventionException; import org.apache.oodt.cas.metadata.filenaming.NamingConvention; import org.apache.oodt.cas.metadata.preconditions.PreConditionComparator; +import org.springframework.beans.factory.annotation.Required; -//JDK imports import java.io.File; import java.util.ArrayList; import java.util.List; -//Spring imports -import org.springframework.beans.factory.annotation.Required; /** * @author mattmann @@ -52,7 +51,7 @@ public class MetExtractorProductCrawler extends ProductCrawler { private String namingConventionId; @Override - protected Metadata getMetadataForProduct(File product) throws Exception { + protected Metadata getMetadataForProduct(File product) throws MetExtractionException { return metExtractor.extractMetadata(product); } @@ -70,12 +69,12 @@ public class MetExtractorProductCrawler extends ProductCrawler { @Override protected File renameProduct(File product, Metadata productMetadata) - throws Exception { + throws CrawlerActionException, NamingConventionException { if (getNamingConventionId() != null) { NamingConvention namingConvention = (NamingConvention) getApplicationContext().getBean(getNamingConventionId()); if (namingConvention == null) { - throw new Exception("NamingConvention Id '" + getNamingConventionId() + throw new CrawlerActionException("NamingConvention Id '" + getNamingConventionId() + "' is not defined"); } return namingConvention.rename(product, productMetadata); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/StdProductCrawler.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/StdProductCrawler.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/StdProductCrawler.java index b0f3e80..00e0c91 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/StdProductCrawler.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/StdProductCrawler.java @@ -18,6 +18,7 @@ package org.apache.oodt.cas.crawl; //OODT imports import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; import org.apache.oodt.cas.metadata.extractors.MetReaderExtractor; //JDK imports @@ -49,7 +50,7 @@ public class StdProductCrawler extends ProductCrawler { } @Override - protected Metadata getMetadataForProduct(File product) throws Exception { + protected Metadata getMetadataForProduct(File product) throws MetExtractionException { MetReaderExtractor extractor = new MetReaderExtractor( this.metFileExtension); return extractor.extractMetadata(product); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java index 46539ab..211165a 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java @@ -17,9 +17,18 @@ package org.apache.oodt.cas.crawl.action; //JDK imports +import com.google.common.collect.Lists; + +import org.apache.commons.lang.Validate; +import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.util.PathUtils; +import org.springframework.beans.factory.annotation.Required; + import java.io.File; import java.util.List; import java.util.Properties; + import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; @@ -28,19 +37,9 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; //Spring imports -import org.springframework.beans.factory.annotation.Required; - //Apache imports -import org.apache.commons.lang.Validate; - //OODT imports -import org.apache.oodt.cas.crawl.action.CrawlerAction; -import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.metadata.util.PathUtils; - //Google imports -import com.google.common.collect.Lists; /** * This action sends an email notification. It performs metadata and system @@ -151,7 +150,7 @@ public class EmailNotification extends CrawlerAction { this.ignoreInvalidAddresses = ignoreInvalidAddresses; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws CrawlerActionException { if (args.length != 5) { System.out.println("Usage: java " + EmailNotification.class.getName() + " <mailhost> <sender> <recipients> <subject> <message>"); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/IngestAncillary.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/IngestAncillary.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/IngestAncillary.java index 4cf0399..1e5dfbc 100755 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/IngestAncillary.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/IngestAncillary.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; //OODT imports +import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; import org.apache.oodt.cas.filemgr.ingest.Ingester; import org.apache.oodt.cas.filemgr.ingest.StdIngester; import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys; @@ -182,7 +183,7 @@ public class IngestAncillary extends FileBasedAction { this.writeBackKeyPrefix = writeBackKeyPrefix; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws CrawlerActionException { if (args.length != 6) { System.out .println("Usage: java " http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java index a6d1110..cf4ed40 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java @@ -20,16 +20,16 @@ package org.apache.oodt.cas.crawl.daemon; //OODT imports import org.apache.oodt.cas.crawl.structs.exceptions.CrawlException; +import org.apache.xmlrpc.XmlRpcClient; +import org.apache.xmlrpc.XmlRpcException; -//JDK imports import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Vector; +//JDK imports //APACHE imports -import org.apache.xmlrpc.XmlRpcClient; -import org.apache.xmlrpc.XmlRpcException; /** * @author mattmann @@ -155,7 +155,7 @@ public class CrawlDaemonController { } } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws CrawlException, InstantiationException { String avgCrawlOperation = "--getAverageCrawlTime\n"; String getMilisCrawlOperation = "--getMilisCrawling\n"; String getNumCrawlsOperation = "--getNumCrawls\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java index db39a56..307aa52 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java @@ -17,12 +17,15 @@ package org.apache.oodt.cas.crawl.typedetection; //OODT imports +import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException; +import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; import org.apache.oodt.cas.metadata.util.PathUtils; import org.apache.oodt.commons.xml.XMLUtils; //JDK imports import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.util.LinkedList; //W3C imports @@ -46,7 +49,9 @@ public final class MimeExtractorConfigReader implements throw new InstantiationException("Don't construct reader classes!"); } - public static MimeExtractorRepo read(String mapFilePath) throws Exception { + public static MimeExtractorRepo read(String mapFilePath) + throws ClassNotFoundException, FileNotFoundException, MetExtractionException, InstantiationException, + IllegalAccessException, CrawlerActionException { try { Document doc = XMLUtils.getDocumentRoot(new FileInputStream( mapFilePath)); @@ -158,18 +163,33 @@ public final class MimeExtractorConfigReader implements extractorRepo.addMetExtractorSpecs(mimeType, specs); } return extractorRepo; - } catch (Exception e) { - e.printStackTrace(); - throw e; + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw e; + } catch (InstantiationException e) { + e.printStackTrace(); + throw e; + } catch (MetExtractionException e) { + e.printStackTrace(); + throw e; + } catch (FileNotFoundException e) { + e.printStackTrace(); + throw e; + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw e; + } catch (CrawlerActionException e) { + e.printStackTrace(); + throw e; } } - private static String getNamingConventionId(Element parent) throws Exception { + private static String getNamingConventionId(Element parent) throws CrawlerActionException { NodeList namingConventions = parent .getElementsByTagName(NAMING_CONVENTION_TAG); if (namingConventions != null && namingConventions.getLength() > 0) { if (namingConventions.getLength() > 1) { - throw new Exception("Can only have 1 '" + throw new CrawlerActionException("Can only have 1 '" + NAMING_CONVENTION_TAG + "' tag per mimetype"); } Element namingConvention = (Element) namingConventions.item(0); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java ---------------------------------------------------------------------- diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java index 2cef366..045edcb 100644 --- a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java +++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java @@ -26,6 +26,7 @@ import net.sf.json.JSONSerializer; import org.apache.oodt.cas.curation.structs.ExtractorConfig; import org.apache.oodt.cas.curation.util.CurationXmlStructFactory; import org.apache.oodt.cas.curation.util.ExtractorConfigReader; +import org.apache.oodt.cas.curation.util.exceptions.CurationException; import org.apache.oodt.cas.filemgr.catalog.Catalog; import org.apache.oodt.cas.filemgr.repository.XMLRepositoryManager; import org.apache.oodt.cas.filemgr.structs.Element; @@ -50,6 +51,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; @@ -686,7 +688,9 @@ public class MetadataResource extends CurationService { } private Metadata writeProductTypeMetadata(String policy, - String productTypeName, Metadata metadata) throws Exception { + String productTypeName, Metadata metadata) + throws MalformedURLException, InstantiationException, RepositoryManagerException, UnsupportedEncodingException, + CurationException { String rootPolicyPath = this.cleanse(CurationService.config .getPolicyUploadPath()); String policyPath = new File(rootPolicyPath + policy).toURL() http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/CurationXmlStructFactory.java ---------------------------------------------------------------------- diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/CurationXmlStructFactory.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/CurationXmlStructFactory.java index 3aeb7a8..46ecbf2 100644 --- a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/CurationXmlStructFactory.java +++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/CurationXmlStructFactory.java @@ -19,6 +19,8 @@ package org.apache.oodt.cas.curation.util; //JDK imports + +import org.apache.oodt.cas.curation.util.exceptions.CurationException; import org.apache.oodt.cas.filemgr.structs.ProductType; import org.apache.oodt.cas.filemgr.util.XmlStructFactory; import org.apache.oodt.commons.xml.XMLUtils; @@ -26,6 +28,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; @@ -44,12 +47,12 @@ import java.util.List; public class CurationXmlStructFactory { public static void writeProductTypeXmlDocument( - List<ProductType> productTypes, String xmlFilePath) throws Exception { + List<ProductType> productTypes, String xmlFilePath) throws UnsupportedEncodingException, CurationException { XMLUtils.writeXmlFile(getProductTypeXmlDocument(productTypes), xmlFilePath); } public static Document getProductTypeXmlDocument( - List<ProductType> productTypes) throws Exception { + List<ProductType> productTypes) throws UnsupportedEncodingException, CurationException { Document doc = XmlStructFactory.getProductTypeXmlDocument(productTypes); // for every product type, i want to add in the versioner info and the @@ -68,7 +71,7 @@ public class CurationXmlStructFactory { } private static void augmentElement(List<ProductType> productTypes, - Element typeElem, Document doc) throws Exception { + Element typeElem, Document doc) throws UnsupportedEncodingException, CurationException { String productTypeName = typeElem.getAttribute("name"); ProductType type = getType(productTypes, productTypeName); @@ -86,7 +89,7 @@ public class CurationXmlStructFactory { for (String val : vals) { Element valElem = doc.createElement("val"); if (val == null) { - throw new Exception("Attempt to write null value " + throw new CurationException("Attempt to write null value " + "for property: [" + key + "]: val: [null]"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/exceptions/CurationException.java ---------------------------------------------------------------------- diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/exceptions/CurationException.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/exceptions/CurationException.java new file mode 100644 index 0000000..d8e1db6 --- /dev/null +++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/exceptions/CurationException.java @@ -0,0 +1,11 @@ +package org.apache.oodt.cas.curation.util.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class CurationException extends Exception { + + public CurationException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/CasMetadataException.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/CasMetadataException.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/CasMetadataException.java new file mode 100644 index 0000000..fc3597b --- /dev/null +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/CasMetadataException.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.metadata.exceptions; + +/** + * Cas Metadata Exception for internal Exceptions. + */ +public class CasMetadataException extends Exception { + + public CasMetadataException(String message){ + super(message); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/PathUtils.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/PathUtils.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/PathUtils.java index 8954f2e..b10d906 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/PathUtils.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/PathUtils.java @@ -20,7 +20,14 @@ package org.apache.oodt.cas.metadata.util; -//JDK imports +import org.apache.commons.lang.StringUtils; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.CasMetadataException; +import org.apache.oodt.commons.date.DateUtils; +import org.apache.oodt.commons.exceptions.CommonsException; +import org.apache.oodt.commons.exec.EnvUtilities; + +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -29,13 +36,6 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -//APACHE imports -import org.apache.commons.lang.StringUtils; - -//OODT imports -import org.apache.oodt.commons.date.DateUtils; -import org.apache.oodt.commons.exec.EnvUtilities; -import org.apache.oodt.cas.metadata.Metadata; /** * @author mattmann @@ -87,12 +87,13 @@ public final class PathUtils { return finalPath.toString(); } - public static String doDynamicReplacement(String string) throws Exception { + public static String doDynamicReplacement(String string) + throws ParseException, CommonsException, CasMetadataException { return doDynamicReplacement(string, null); } public static String doDynamicReplacement(String string, Metadata metadata) - throws Exception { + throws ParseException, CommonsException, CasMetadataException { return PathUtils.replaceEnvVariables(doDynamicDateReplacement( doDynamicDateRollReplacement( doDynamicDateFormatReplacement( @@ -109,7 +110,7 @@ public final class PathUtils { } public static String doDynamicDateReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws CasMetadataException, CommonsException { Pattern datePattern = Pattern .compile("\\[\\s*DATE\\s*(?:[+-]{1}[^\\.]{1,}?){0,1}\\.\\s*(?:(?:DAY)|(?:MONTH)|(?:YEAR)|(?:UTC)|(?:TAI)){1}\\s*\\]"); Matcher dateMatcher = datePattern.matcher(string); @@ -131,7 +132,7 @@ public final class PathUtils { "[\\+\\s]", "")); gc.add(GregorianCalendar.DAY_OF_YEAR, rollDays); } else - throw new Exception( + throw new CasMetadataException( "Malformed dynamic date replacement specified (no dot separator) - '" + dateString + "'"); } @@ -139,7 +140,7 @@ public final class PathUtils { // determine type and make the appropriate replacement String[] splitDate = dateString.split("\\."); if (splitDate.length < 2) - throw new Exception("No date type specified - '" + dateString + throw new CasMetadataException("No date type specified - '" + dateString + "'"); String dateType = splitDate[1].replaceAll("[\\[\\]\\s]", ""); String replacement; @@ -158,7 +159,7 @@ public final class PathUtils { } else if (dateType.equals("TAI")) { replacement = DateUtils.toString(DateUtils.toTai(gc)); } else { - throw new Exception("Invalid date type specified '" + throw new CasMetadataException("Invalid date type specified '" + dateString + "'"); } @@ -176,7 +177,7 @@ public final class PathUtils { * current UTC time */ public static String doDynamicDateRollReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws ParseException, CasMetadataException, CommonsException { Pattern dateFormatPattern = Pattern .compile("\\[\\s*DATE_ADD\\s*\\(.{1,}?,.{1,}?,.{1,}?,.{1,}?\\)\\s*\\]"); Matcher dateFormatMatcher = dateFormatPattern.matcher(string); @@ -227,7 +228,7 @@ public final class PathUtils { } public static String doDynamicDateFormatReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws ParseException, CasMetadataException, CommonsException { Pattern dateFormatPattern = Pattern .compile("\\[\\s*FORMAT\\s*\\(.{1,}?,.{1,}?,.{1,}?\\)\\s*\\]"); Matcher dateFormatMatcher = dateFormatPattern.matcher(string); @@ -265,7 +266,7 @@ public final class PathUtils { * with TAI time with format: "yyyy-MM-dd'T'HH:mm:ss.SSS-0000<leapSecs>" */ public static String doDynamicUtcToTaiDateReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws ParseException, CommonsException, CasMetadataException { Pattern utcToTaiPattern = Pattern.compile("\\[\\s*UTC_TO_TAI\\s*\\(.{1,}?\\)\\s*\\]"); Matcher matcher = utcToTaiPattern.matcher(string); while (matcher.find()) { @@ -288,7 +289,7 @@ public final class PathUtils { * with seconds between <epoch-date> and <date-string> */ public static String doDynamicDateToSecsReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws CommonsException, ParseException, CasMetadataException { Pattern utcToTaiPattern = Pattern.compile("\\[\\s*DATE_TO_SECS\\s*\\(.{1,}?\\,.{1,}?,.{1,}?\\)\\s*\\]"); Matcher matcher = utcToTaiPattern.matcher(string); while (matcher.find()) { @@ -316,7 +317,7 @@ public final class PathUtils { * with milliseconds between <epoch-date> and <date-string> */ public static String doDynamicDateToMillisReplacement(String string, - Metadata metadata) throws Exception { + Metadata metadata) throws ParseException, CommonsException, CasMetadataException { Pattern utcToTaiPattern = Pattern.compile("\\[\\s*DATE_TO_MILLIS\\s*\\(.{1,}?\\,.{1,}?,.{1,}?\\)\\s*\\]"); Matcher matcher = utcToTaiPattern.matcher(string); while (matcher.find()) { http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java index 7538984..743994e 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java @@ -182,7 +182,7 @@ public final class PCSHealthMonitor implements CoreMetKeys, } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws InstantiationException { String usage = "PCSHealthMonitor <fm url> <wm url> <rm url> <crawler xml file path> <workflow states xml file path>\n"; String fmUrlStr, wmUrlStr, rmUrlStr; String crawlerXmlFilePath, workflowStateXmlPath; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java index 496fbf0..315de3f 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java @@ -28,6 +28,7 @@ import org.apache.oodt.cas.metadata.Metadata; //JDK imports import java.io.File; +import java.io.FileNotFoundException; import java.util.Arrays; import java.util.List; import java.util.Stack; @@ -55,7 +56,7 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys { fm = new FileManagerUtils(fmUrlStr); try { this.conf = new ListingConf(new File(confFile)); - } catch (Exception e) { + } catch (FileNotFoundException e) { throw new InstantiationException(e.getMessage()); } } @@ -87,7 +88,7 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys { } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws InstantiationException { String usage = "PCSLongLister <conf file> <fmurl> [files]"; List fileList; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java index aeacaec..e86840e 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java @@ -18,20 +18,21 @@ package org.apache.oodt.pcs.tools; //JDK imports -import java.net.URL; -import java.util.Arrays; -import java.util.List; - -//OODT imports +import org.apache.oodt.cas.filemgr.structs.Product; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.workflow.structs.WorkflowInstance; import org.apache.oodt.pcs.metadata.PCSConfigMetadata; import org.apache.oodt.pcs.metadata.PCSMetadata; import org.apache.oodt.pcs.pedigree.Pedigree; import org.apache.oodt.pcs.pedigree.PedigreeTree; import org.apache.oodt.pcs.util.FileManagerUtils; import org.apache.oodt.pcs.util.WorkflowManagerUtils; -import org.apache.oodt.cas.filemgr.structs.Product; -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.workflow.structs.WorkflowInstance; + +import java.net.URL; +import java.util.Arrays; +import java.util.List; + +//OODT imports /** * @@ -190,7 +191,7 @@ public final class PCSTrace implements PCSMetadata, PCSConfigMetadata { * @param args * @throws Exception */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) { String productName = null; String workflowUrlStr = null, filemgrUrlStr = null; boolean enableNotCat = false; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonController.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonController.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonController.java index 264e7cd..88da43f 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonController.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonController.java @@ -153,7 +153,7 @@ public class DaemonController { * @throws Exception * On error! :) */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws RemoteException { String avgCrawlOperation = "--getAverageRunTime\n"; String getMilisCrawlOperation = "--getMilisCrawling\n"; String getNumCrawlsOperation = "--getNumCrawls\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java index 914ee15..b43e716 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java @@ -38,4 +38,8 @@ public class RetrievalMethodException extends PushPullFrameworkException { public RetrievalMethodException(String msg) { super(msg); } + + public RetrievalMethodException(String msg, Throwable t) { + super(msg, t); + } } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java index 34fa21d..c1e8dc9 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java @@ -20,6 +20,7 @@ package org.apache.oodt.cas.pushpull.filerestrictions.parsers; //OODT imports import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.exceptions.CasMetadataException; import org.apache.oodt.cas.metadata.util.PathUtils; import org.apache.oodt.cas.pushpull.exceptions.ParserException; import org.apache.oodt.cas.pushpull.expressions.GlobalVariables; @@ -28,6 +29,7 @@ import org.apache.oodt.cas.pushpull.expressions.Variable; import org.apache.oodt.cas.pushpull.filerestrictions.Parser; import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFile; import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFileStructure; +import org.apache.oodt.commons.exceptions.CommonsException; import org.apache.oodt.commons.xml.XMLUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -35,6 +37,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import java.io.FileInputStream; +import java.text.ParseException; import java.util.HashMap; import java.util.StringTokenizer; import java.util.logging.Level; @@ -207,7 +210,7 @@ public class DirStructXmlParser implements Parser { return input; } - private void parseVariablesXML(NodeList list) throws Exception { + private void parseVariablesXML(NodeList list) throws ParseException, CommonsException, CasMetadataException { // loop through all variable elements for (int i = 0; i < list.getLength(); i++) { http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java index 743e5f8..ccf28b1 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java @@ -24,6 +24,7 @@ import org.apache.oodt.cas.metadata.Metadata; import org.apache.oodt.cas.pushpull.config.DataFilesInfo; import org.apache.oodt.cas.pushpull.config.DownloadInfo; import org.apache.oodt.cas.pushpull.exceptions.AlreadyInDatabaseException; +import org.apache.oodt.cas.pushpull.exceptions.ParserException; import org.apache.oodt.cas.pushpull.exceptions.RetrievalMethodException; import org.apache.oodt.cas.pushpull.exceptions.ToManyFailedDownloadsException; import org.apache.oodt.cas.pushpull.exceptions.UndefinedTypeException; @@ -38,6 +39,7 @@ import org.apache.oodt.cas.pushpull.retrievalsystem.FileRetrievalSystem; //JDK imports import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.util.LinkedList; import java.util.logging.Level; import java.util.logging.Logger; @@ -59,7 +61,7 @@ public class ListRetriever implements RetrievalMethod { public void processPropFile(FileRetrievalSystem frs, Parser propFileParser, File propFile, DataFilesInfo dfi, DataFileToPropFileLinker linker) - throws Exception { + throws FileNotFoundException, ParserException, RetrievalMethodException { RemoteSite remoteSite; // parse property file @@ -97,7 +99,7 @@ public class ListRetriever implements RetrievalMethod { e.printStackTrace(); linker.markAsFailed(propFile, "Failed to download " + file + " from " + remoteSite + " : " + e.getMessage()); - throw new Exception("Uknown error accured while downloading " + throw new RetrievalMethodException("Uknown error accured while downloading " + file + " from " + remoteSite + " -- bailing out : " + e.getMessage()); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java index f4c2ca8..925a65d 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java @@ -21,9 +21,11 @@ package org.apache.oodt.cas.pushpull.retrievalmethod; //OODT imports import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException; import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.protocol.exceptions.ProtocolException; import org.apache.oodt.cas.pushpull.config.DataFilesInfo; import org.apache.oodt.cas.pushpull.config.DownloadInfo; import org.apache.oodt.cas.pushpull.exceptions.AlreadyInDatabaseException; +import org.apache.oodt.cas.pushpull.exceptions.ParserException; import org.apache.oodt.cas.pushpull.exceptions.RetrievalMethodException; import org.apache.oodt.cas.pushpull.exceptions.ToManyFailedDownloadsException; import org.apache.oodt.cas.pushpull.exceptions.UndefinedTypeException; @@ -43,6 +45,8 @@ import org.apache.oodt.cas.pushpull.retrievalsystem.FileRetrievalSystem; //JDK imports import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.net.MalformedURLException; import java.util.List; import java.util.Stack; import java.util.logging.Level; @@ -73,7 +77,8 @@ public class RemoteCrawler implements RetrievalMethod { @Override public void processPropFile(FileRetrievalSystem frs, Parser propFileParser, File propFile, DataFilesInfo dfi, DataFileToPropFileLinker linker) - throws Exception { + throws FileNotFoundException, ParserException, ProtocolException, MalformedURLException, + RetrievalMethodException { RemoteSite remoteSite; // parse property file @@ -157,7 +162,7 @@ public class RemoteCrawler implements RetrievalMethod { LOG.log(Level.WARNING, "Skipping file : " + e.getMessage()); } catch (Exception e) { linker.markAsFailed(propFile, e.getMessage()); - throw new Exception("Uknown error accured while downloading " + throw new RetrievalMethodException("Uknown error accured while downloading " + file + " from " + remoteSite + " -- bailing out : " + e.getMessage(), e); } http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/exceptions/ResourceException.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/exceptions/ResourceException.java b/resource/src/main/java/org/apache/oodt/cas/resource/exceptions/ResourceException.java new file mode 100644 index 0000000..90afdb1 --- /dev/null +++ b/resource/src/main/java/org/apache/oodt/cas/resource/exceptions/ResourceException.java @@ -0,0 +1,31 @@ +/* + * 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.resource.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class ResourceException extends Exception{ + + public ResourceException(String message){ + super(message); + } + + public ResourceException(String message, Throwable t){ + super(message, t); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/utils/MockGmetad.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/utils/MockGmetad.java b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/utils/MockGmetad.java index f41ebc3..e5a77ce 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/utils/MockGmetad.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/utils/MockGmetad.java @@ -85,7 +85,7 @@ public class MockGmetad implements Runnable { } - public static void main(String [] args) throws Exception{ + public static void main(String [] args){ String xmlPath; int serverPort; final String usage = "java MockGmetad <xml path> <port>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java index 1f73aa8..3aee637 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java @@ -18,7 +18,6 @@ package org.apache.oodt.cas.resource.system; -//OODT imports import org.apache.oodt.cas.resource.scheduler.Scheduler; import org.apache.oodt.cas.resource.structs.Job; import org.apache.oodt.cas.resource.structs.JobInput; @@ -37,6 +36,7 @@ import org.apache.xmlrpc.WebServer; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; @@ -47,9 +47,6 @@ import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; -//APACHE imports -//JDK imports - /** * @author woollard * @version $Revision$ @@ -74,7 +71,7 @@ public class XmlRpcResourceManager { /* our scheduler */ private Scheduler scheduler = null; - public XmlRpcResourceManager(int port) throws Exception { + public XmlRpcResourceManager(int port) throws IOException { // load properties from workflow manager properties file, if specified if (System.getProperty("org.apache.oodt.cas.resource.properties") != null) { String configFile = System @@ -427,7 +424,7 @@ public class XmlRpcResourceManager { return report; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws IOException { int portNum = -1; String usage = "XmlRpcResourceManager --portNum <port number for xml rpc service>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java index 5e614ae..77d7275 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java @@ -62,7 +62,7 @@ public class XmlRpcBatchStub { private static Map jobThreadMap = null; - public XmlRpcBatchStub(int port) throws Exception { + public XmlRpcBatchStub(int port) { webServerPort = port; // start up the web server @@ -181,7 +181,7 @@ public class XmlRpcBatchStub { } } - public static void main(String[] args) throws Exception { + public static void main(String[] args) { int portNum = -1; String usage = "XmlRpcBatchStub --portNum <port number for xml rpc service>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/tools/JobSubmitter.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/tools/JobSubmitter.java b/resource/src/main/java/org/apache/oodt/cas/resource/tools/JobSubmitter.java index 1c27311..16fd3bb 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/tools/JobSubmitter.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/tools/JobSubmitter.java @@ -21,6 +21,7 @@ package org.apache.oodt.cas.resource.tools; //JDK imports import java.io.File; import java.io.FileFilter; +import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; @@ -95,7 +96,7 @@ public final class JobSubmitter { return submitJob(spec); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws MalformedURLException, JobExecutionException { String resMgrUrlStr = null; String jobFilePath = null, jobFileDirPath = null; String usage = "JobSubmitter --rUrl <resource mgr url> [options]\n" http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java b/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java index 63970d5..5f32b04 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java @@ -19,22 +19,24 @@ package org.apache.oodt.cas.resource.tools; //JDK imports +import org.apache.oodt.cas.resource.structs.Job; +import org.apache.oodt.cas.resource.structs.JobInput; +import org.apache.oodt.cas.resource.structs.JobSpec; +import org.apache.oodt.cas.resource.structs.NameValueJobInput; +import org.apache.oodt.cas.resource.structs.exceptions.JobExecutionException; +import org.apache.oodt.cas.resource.system.XmlRpcResourceManagerClient; +import org.apache.oodt.cas.resource.util.JobBuilder; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; //OODT imports -import org.apache.oodt.cas.resource.structs.Job; -import org.apache.oodt.cas.resource.structs.JobInput; -import org.apache.oodt.cas.resource.structs.JobSpec; -import org.apache.oodt.cas.resource.structs.NameValueJobInput; -import org.apache.oodt.cas.resource.structs.exceptions.JobExecutionException; -import org.apache.oodt.cas.resource.system.XmlRpcResourceManagerClient; -import org.apache.oodt.cas.resource.util.JobBuilder; /** * @author cecilia @@ -123,7 +125,7 @@ public final class RunDirJobSubmitter { } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws JobExecutionException, MalformedURLException { String resMgrUrlStr = null; String jobFileName = null; String runDirFileName = null; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/resource/src/main/java/org/apache/oodt/cas/resource/util/Ulimit.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/util/Ulimit.java b/resource/src/main/java/org/apache/oodt/cas/resource/util/Ulimit.java index adba1b1..434f262 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/util/Ulimit.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/util/Ulimit.java @@ -19,6 +19,9 @@ package org.apache.oodt.cas.resource.util; //JDK imports + +import org.apache.oodt.cas.resource.exceptions.ResourceException; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -166,14 +169,14 @@ public final class Ulimit implements UlimitMetKeys { } - public static Map getUlimitPropertiesMap() throws Exception { + public static Map getUlimitPropertiesMap() throws ResourceException, IOException { Process p; try { p = Runtime.getRuntime().exec( new String[] { shell, runShellCmdOption, ulimitCommand }); } catch (IOException e) { e.printStackTrace(); - throw new Exception( + throw new ResourceException( "IOException executing ulimit command: Message: " + e.getMessage()); } @@ -197,16 +200,16 @@ public final class Ulimit implements UlimitMetKeys { return properties; } - public static List getUlimitProperties() throws Exception { + public static List getUlimitProperties() throws ResourceException, IOException { Process p; try { p = Runtime.getRuntime().exec( new String[] { shell, runShellCmdOption, ulimitCommand }); } catch (IOException e) { e.printStackTrace(); - throw new Exception( + throw new ResourceException( "IOException executing ulimit command: Message: " - + e.getMessage()); + + e.getMessage(), e); } BufferedReader in = new BufferedReader(new InputStreamReader(p .getInputStream())); http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java ---------------------------------------------------------------------- diff --git a/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java b/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java index 4145556..318ff9d 100755 --- a/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java +++ b/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java @@ -17,12 +17,13 @@ package org.apache.oodt.security.sso; -//JDK imports import org.apache.commons.codec.binary.Base64; import org.apache.oodt.security.sso.opensso.SSOMetKeys; import org.apache.oodt.security.sso.opensso.SSOProxy; +import org.apache.oodt.security.sso.opensso.SingleSignOnException; import org.apache.oodt.security.sso.opensso.UserDetails; +import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Vector; @@ -30,9 +31,6 @@ import java.util.logging.Logger; import javax.servlet.http.Cookie; -//APACHE imports -//LMMP imports - /** * * Connects to OpenSSO's authorization endpoint and authenticates a user, @@ -120,7 +118,7 @@ public class OpenSSOImpl extends AbstractWebBasedSingleSignOn implements * @throws Exception * If any error (e.g., HTTP REST error) occurs. */ - public List<String> getGroupsForUser() throws Exception { + public List<String> getGroupsForUser() throws IOException, SingleSignOnException { String token = this.getSSOToken(); if (token == null) { return Collections.EMPTY_LIST; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java ---------------------------------------------------------------------- diff --git a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java index 972fedf..7e24413 100755 --- a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java +++ b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java @@ -17,7 +17,7 @@ package org.apache.oodt.security.sso.opensso; -//JDK imports + import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; @@ -31,8 +31,6 @@ import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; -//APACHE imports - /** * * A client class to the services provided by the <a @@ -114,7 +112,7 @@ public class SSOProxy implements SSOMetKeys { } public IdentityDetails readIdentity(String username, String token) - throws Exception { + throws IOException, SingleSignOnException { HttpClient httpClient = new HttpClient(); PostMethod post = new PostMethod(IDENT_READ_ENDPOINT); LOG.log(Level.INFO, "Obtaining identity: username: [" + username @@ -127,14 +125,14 @@ public class SSOProxy implements SSOMetKeys { httpClient.executeMethod(post); if (post.getStatusCode() != HttpStatus.SC_OK) { - throw new Exception(post.getStatusLine().toString()); + throw new SingleSignOnException(post.getStatusLine().toString()); } return parseIdentityDetails(post.getResponseBodyAsString().trim()); } - public UserDetails getUserAttributes(String token) throws Exception { + public UserDetails getUserAttributes(String token) throws IOException, SingleSignOnException { HttpClient httpClient = new HttpClient(); PostMethod post = new PostMethod(IDENT_ATTR_ENDPOINT); LOG.log(Level.INFO, "Obtaining user attributes: token: [" + token @@ -145,7 +143,7 @@ public class SSOProxy implements SSOMetKeys { httpClient.executeMethod(post); if (post.getStatusCode() != HttpStatus.SC_OK) { - throw new Exception(post.getStatusLine().toString()); + throw new SingleSignOnException(post.getStatusLine().toString()); } return parseUserDetails(post.getResponseBodyAsString().trim()); @@ -282,7 +280,7 @@ public class SSOProxy implements SSOMetKeys { return details; } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws IOException, SingleSignOnException { String usage = "SSOProxy <cmd> [args]\n\n" + "Where cmd is one of:\n" + "authenticate <user> <pass>\n" + "identity <user> <token>\n" + "attributes <token>\nlogout <token>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/daf0904a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SingleSignOnException.java ---------------------------------------------------------------------- diff --git a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SingleSignOnException.java b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SingleSignOnException.java new file mode 100644 index 0000000..bed65e7 --- /dev/null +++ b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SingleSignOnException.java @@ -0,0 +1,11 @@ +package org.apache.oodt.security.sso.opensso; + +/** + * Created by bugg on 27/10/15. + */ +public class SingleSignOnException extends Exception { + + public SingleSignOnException(String message) { + super(message); + } +}
