http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java index e1420ee..d7fce0f 100644 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java @@ -69,41 +69,45 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara List<String> values = new ArrayList<String>(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); - if ("elemId".equals(node.getNodeName())) - id = XML.unwrappedText(node); - else if ("elemName".equals(node.getNodeName())) - name = XML.unwrappedText(node); - else if ("elemDesc".equals(node.getNodeName())) - desc = XML.unwrappedText(node); - else if ("elemType".equals(node.getNodeName())) - type = XML.unwrappedText(node); - else if ("elemUnit".equals(node.getNodeName())) - unit = XML.unwrappedText(node); - else if ("elemEnumFlag".equals(node.getNodeName())) - ranged = "F".equals(XML.unwrappedText(node)); - else if ("elemSynonym".equals(node.getNodeName())) - synonyms.add(XML.unwrappedText(node)); - else if ("elemObligation".equals(node.getNodeName())) { + if ("elemId".equals(node.getNodeName())) { + id = XML.unwrappedText(node); + } else if ("elemName".equals(node.getNodeName())) { + name = XML.unwrappedText(node); + } else if ("elemDesc".equals(node.getNodeName())) { + desc = XML.unwrappedText(node); + } else if ("elemType".equals(node.getNodeName())) { + type = XML.unwrappedText(node); + } else if ("elemUnit".equals(node.getNodeName())) { + unit = XML.unwrappedText(node); + } else if ("elemEnumFlag".equals(node.getNodeName())) { + ranged = "F".equals(XML.unwrappedText(node)); + } else if ("elemSynonym".equals(node.getNodeName())) { + synonyms.add(XML.unwrappedText(node)); + } else if ("elemObligation".equals(node.getNodeName())) { String value = XML.unwrappedText(node); obligation = "Required".equals(value) || "T".equals(value); - } else if ("elemMaxOccurrence".equals(node.getNodeName())) - try { - maxOccurrence = Integer.parseInt(XML.unwrappedText(node)); - } catch (NumberFormatException ignore) {} - else if ("elemComment".equals(node.getNodeName())) - comments = XML.unwrappedText(node); - else if ("elemValue".equals(node.getNodeName())) { + } else if ("elemMaxOccurrence".equals(node.getNodeName())) { + try { + maxOccurrence = Integer.parseInt(XML.unwrappedText(node)); + } catch (NumberFormatException ignore) { + } + } else if ("elemComment".equals(node.getNodeName())) { + comments = XML.unwrappedText(node); + } else if ("elemValue".equals(node.getNodeName())) { values.add(text(node)); - } else if ("elemMinValue".equals(node.getNodeName())) - try { - min = XML.unwrappedText(node); - gotMin = true; - } catch (NumberFormatException ignore) {} - else if ("elemMaxValue".equals(node.getNodeName())) - try { - max = XML.unwrappedText(node); - gotMax = true; - } catch (NumberFormatException ignore) {} + } else if ("elemMinValue".equals(node.getNodeName())) { + try { + min = XML.unwrappedText(node); + gotMin = true; + } catch (NumberFormatException ignore) { + } + } else if ("elemMaxValue".equals(node.getNodeName())) { + try { + max = XML.unwrappedText(node); + gotMax = true; + } catch (NumberFormatException ignore) { + } + } } if (ranged) { if (gotMin && gotMax) { @@ -112,9 +116,10 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara } return factory.createUnspecifiedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, comments); - } else - return factory.createEnumeratedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, - maxOccurrence, comments, values); + } else { + return factory.createEnumeratedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, + maxOccurrence, comments, values); + } } /** @@ -158,8 +163,12 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara } public boolean equals(Object rhs) { - if (rhs == this) return true; - if (rhs == null || !(rhs instanceof ProfileElement)) return false; + if (rhs == this) { + return true; + } + if (rhs == null || !(rhs instanceof ProfileElement)) { + return false; + } ProfileElement obj = (ProfileElement) rhs; return profile.equals(obj.profile) && name.equals(obj.name); } @@ -178,10 +187,12 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara public int compareTo(Object rhs) { ProfileElement obj = (ProfileElement) rhs; - if (profile.compareTo(obj.profile) < 0) - return -1; - if (profile.compareTo(obj.profile) == 0) - return name.compareTo(obj.name); + if (profile.compareTo(obj.profile) < 0) { + return -1; + } + if (profile.compareTo(obj.profile) == 0) { + return name.compareTo(obj.name); + } return 1; } @@ -415,12 +426,16 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara XML.addNonNull(profElement, "elemType", type); XML.addNonNull(profElement, "elemUnit", unit); XML.add(profElement, "elemEnumFlag", isEnumerated()? "T" : "F"); - if (withValues) addValues(profElement); + if (withValues) { + addValues(profElement); + } XML.add(profElement, "elemSynonym", synonyms); - if (isObligatory()) - XML.add(profElement, "elemObligation","Required"); - if (getMaxOccurrence() >= 0) - XML.add(profElement, "elemMaxOccurrence", String.valueOf(getMaxOccurrence())); + if (isObligatory()) { + XML.add(profElement, "elemObligation", "Required"); + } + if (getMaxOccurrence() >= 0) { + XML.add(profElement, "elemMaxOccurrence", String.valueOf(getMaxOccurrence())); + } XML.add(profElement, "elemComment", comments); return profElement; } @@ -563,8 +578,9 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara return; } NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) - text0(b, children.item(i)); + for (int i = 0; i < children.getLength(); ++i) { + text0(b, children.item(i)); + } } }
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java b/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java index c27ed77..d0b1e55 100644 --- a/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java +++ b/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java @@ -75,44 +75,45 @@ public class ResourceAttributes implements Serializable, Cloneable, Comparable<O NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); - if ("Identifier".equals(node.getNodeName())) - identifier = XML.unwrappedText(node); - else if ("Title".equals(node.getNodeName())) - title = XML.unwrappedText(node); - else if ("Format".equals(node.getNodeName())) - formats.add(XML.unwrappedText(node)); - else if ("Description".equals(node.getNodeName())) - description = XML.unwrappedText(node); - else if ("Creator".equals(node.getNodeName())) - creators.add(XML.unwrappedText(node)); - else if ("Subject".equals(node.getNodeName())) - subjects.add(XML.unwrappedText(node)); - else if ("Publisher".equals(node.getNodeName())) - publishers.add(XML.unwrappedText(node)); - else if ("Contributor".equals(node.getNodeName())) - contributors.add(XML.unwrappedText(node)); - else if ("Date".equals(node.getNodeName())) - dates.add(XML.unwrappedText(node)); - else if ("Type".equals(node.getNodeName())) - types.add(XML.unwrappedText(node)); - else if ("Source".equals(node.getNodeName())) - sources.add(XML.unwrappedText(node)); - else if ("Language".equals(node.getNodeName())) - languages.add(XML.unwrappedText(node)); - else if ("Relation".equals(node.getNodeName())) - relations.add(XML.unwrappedText(node)); - else if ("Coverage".equals(node.getNodeName())) - coverages.add(XML.unwrappedText(node)); - else if ("Rights".equals(node.getNodeName())) - rights.add(XML.unwrappedText(node)); - else if ("resContext".equals(node.getNodeName())) - contexts.add(XML.unwrappedText(node)); - else if ("resAggregation".equals(node.getNodeName())) - aggregation = XML.unwrappedText(node); - else if ("resClass".equals(node.getNodeName())) - clazz = XML.unwrappedText(node); - else if ("resLocation".equals(node.getNodeName())) - locations.add(XML.unwrappedText(node)); + if ("Identifier".equals(node.getNodeName())) { + identifier = XML.unwrappedText(node); + } else if ("Title".equals(node.getNodeName())) { + title = XML.unwrappedText(node); + } else if ("Format".equals(node.getNodeName())) { + formats.add(XML.unwrappedText(node)); + } else if ("Description".equals(node.getNodeName())) { + description = XML.unwrappedText(node); + } else if ("Creator".equals(node.getNodeName())) { + creators.add(XML.unwrappedText(node)); + } else if ("Subject".equals(node.getNodeName())) { + subjects.add(XML.unwrappedText(node)); + } else if ("Publisher".equals(node.getNodeName())) { + publishers.add(XML.unwrappedText(node)); + } else if ("Contributor".equals(node.getNodeName())) { + contributors.add(XML.unwrappedText(node)); + } else if ("Date".equals(node.getNodeName())) { + dates.add(XML.unwrappedText(node)); + } else if ("Type".equals(node.getNodeName())) { + types.add(XML.unwrappedText(node)); + } else if ("Source".equals(node.getNodeName())) { + sources.add(XML.unwrappedText(node)); + } else if ("Language".equals(node.getNodeName())) { + languages.add(XML.unwrappedText(node)); + } else if ("Relation".equals(node.getNodeName())) { + relations.add(XML.unwrappedText(node)); + } else if ("Coverage".equals(node.getNodeName())) { + coverages.add(XML.unwrappedText(node)); + } else if ("Rights".equals(node.getNodeName())) { + rights.add(XML.unwrappedText(node)); + } else if ("resContext".equals(node.getNodeName())) { + contexts.add(XML.unwrappedText(node)); + } else if ("resAggregation".equals(node.getNodeName())) { + aggregation = XML.unwrappedText(node); + } else if ("resClass".equals(node.getNodeName())) { + clazz = XML.unwrappedText(node); + } else if ("resLocation".equals(node.getNodeName())) { + locations.add(XML.unwrappedText(node)); + } } } @@ -176,8 +177,12 @@ public class ResourceAttributes implements Serializable, Cloneable, Comparable<O } public boolean equals(Object rhs) { - if (rhs == this) return true; - if (rhs == null || !(rhs instanceof ResourceAttributes)) return false; + if (rhs == this) { + return true; + } + if (rhs == null || !(rhs instanceof ResourceAttributes)) { + return false; + } return ((ResourceAttributes) rhs).identifier.equals(identifier); } @@ -230,12 +235,14 @@ public class ResourceAttributes implements Serializable, Cloneable, Comparable<O public URI getURI() { String identification; if (identifier == null || identifier.length() == 0) { - if (locations.isEmpty()) - identification = null; - else - identification = (String) locations.get(0); - } else - identification = identifier; + if (locations.isEmpty()) { + identification = null; + } else { + identification = (String) locations.get(0); + } + } else { + identification = identifier; + } return identification == null? UNKNOWN_URI : URI.create(identification); } @@ -564,10 +571,14 @@ public class ResourceAttributes implements Serializable, Cloneable, Comparable<O XML.add(root, "Coverage", coverages); XML.add(root, "Rights", rights); List<String> contexts = new ArrayList<String>(this.contexts); - if (contexts.isEmpty()) contexts.add("UNKNOWN"); + if (contexts.isEmpty()) { + contexts.add("UNKNOWN"); + } XML.add(root, "resContext", contexts); XML.addNonNull(root, "resAggregation", aggregation); - if(clazz==null) clazz="UNKNOWN"; + if(clazz==null) { + clazz = "UNKNOWN"; + } XML.addNonNull(root, "resClass", clazz); XML.add(root, "resLocation", locations); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/Utility.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Utility.java b/profile/src/main/java/org/apache/oodt/profile/Utility.java index 0abb44b..86ac062 100644 --- a/profile/src/main/java/org/apache/oodt/profile/Utility.java +++ b/profile/src/main/java/org/apache/oodt/profile/Utility.java @@ -52,12 +52,16 @@ class Utility { static void addProperty(Model model, Resource resource, Property property, Object value, ProfileAttributes profAttr, URI uri) { - if (value == null || value.toString().length() == 0) return; + if (value == null || value.toString().length() == 0) { + return; + } Object obj; if (value instanceof Collection) { Collection<?> collection = (Collection<?>) value; - if (collection.isEmpty()) return; + if (collection.isEmpty()) { + return; + } Bag bag = model.createBag(uri + "_" + property.getLocalName() + "_bag"); for (Object aCollection : collection) { bag.add(aCollection); @@ -104,7 +108,9 @@ class Utility { } private static void addPotentiallyNullReifiedStatement(Resource reification, Property property, Object value) { - if (value == null || value.toString().length() == 0) return; + if (value == null || value.toString().length() == 0) { + return; + } reification.addProperty(property, value.toString()); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java b/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java index f630417..72be8da 100755 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java @@ -53,7 +53,9 @@ public abstract class DatabaseProfileManager implements ProfileManager * @throws DOMException If an error occurs. */ private static void add(Node node, String name, String value) throws DOMException { - if (value == null) return; + if (value == null) { + return; + } XML.add(node, name, value.trim()); } @@ -260,7 +262,9 @@ public abstract class DatabaseProfileManager implements ProfileManager // get connection String url = props.getProperty("org.apache.oodt.util.JDBC_DB.url", "jdbc:oracle:@"); String database = props.getProperty("org.apache.oodt.util.JDBC_DB.database"); - if(database != null) url += database; + if(database != null) { + url += database; + } Connection conn = DriverManager.getConnection(url, props.getProperty("org.apache.oodt.util.JDBC_DB.user"), http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/ConstantExpression.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/ConstantExpression.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/ConstantExpression.java index d441053..6998c9e 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/ConstantExpression.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/ConstantExpression.java @@ -40,10 +40,11 @@ class ConstantExpression implements WhereExpression { } public Result result(SearchableResourceAttributes resAttr, Map elements) { - if (value) - return new MatchingResult(new HashSet(elements.values())); - else - return FalseResult.INSTANCE; + if (value) { + return new MatchingResult(new HashSet(elements.values())); + } else { + return FalseResult.INSTANCE; + } } public WhereExpression simplify() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java index 8994028..188d47f 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java @@ -91,7 +91,9 @@ final public class LightweightProfileServer implements ProfileHandler { // Get the list of profiles from the cache, if it's there. profiles = (List) cache.get(url); - if (profiles != null) return; + if (profiles != null) { + return; + } // It wasn't in the cache, so create a parser to parse the file. We only // deal with correct files, so turn on validation and install an error @@ -157,7 +159,9 @@ final public class LightweightProfileServer implements ProfileHandler { * @return a {@link Profile} value. */ public Profile get(String profID) { - if (profID == null) return null; + if (profID == null) { + return null; + } Profile rc = null; for (Object profile : profiles) { Profile p = (Profile) profile; @@ -221,10 +225,11 @@ final public class LightweightProfileServer implements ProfileHandler { } // If there's nothing on the stack, we're given nothing, so give back everything. - if (stack.size() == 0) - return new ConstantExpression(true); - else if (stack.size() > 1) - throw new IllegalStateException("Imbalanced expression in query"); + if (stack.size() == 0) { + return new ConstantExpression(true); + } else if (stack.size() > 1) { + throw new IllegalStateException("Imbalanced expression in query"); + } // Simplify/optimize the where-expression and return it. return ((WhereExpression) stack.pop()).simplify(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/OperatorExpression.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/OperatorExpression.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/OperatorExpression.java index c046019..51c18d5 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/OperatorExpression.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/OperatorExpression.java @@ -40,8 +40,9 @@ class OperatorExpression implements WhereExpression { * @param operator What operator to use */ public OperatorExpression(String value, String name, String operator) { - if (Arrays.binarySearch(VALID_OPERATORS, operator) < 0) - throw new IllegalArgumentException("Invalid operator \"" + operator + "\""); + if (Arrays.binarySearch(VALID_OPERATORS, operator) < 0) { + throw new IllegalArgumentException("Invalid operator \"" + operator + "\""); + } this.name = name; this.value = value; @@ -62,7 +63,9 @@ class OperatorExpression implements WhereExpression { SearchableProfileElement element = (SearchableProfileElement) elements.get(name); // Nope. We can only give a false result. - if (element == null) return FalseResult.INSTANCE; + if (element == null) { + return FalseResult.INSTANCE; + } // Yep. Ask the element to yield the result. return element.result(value, operator); @@ -76,22 +79,23 @@ class OperatorExpression implements WhereExpression { public WhereExpression negate() { String negated; - if (operator.equals("EQ")) - negated = "NE"; - else if (operator.equals("NE")) - negated = "EQ"; - else if (operator.equals("LT")) - negated = "GE"; - else if (operator.equals("GT")) - negated = "LE"; - else if (operator.equals("LE")) - negated = "GT"; - else if (operator.equals("LIKE")) - negated = "NE"; - else if (operator.equals("NOTLIKE")) - negated = "EQ"; - else - negated = "LT"; + if (operator.equals("EQ")) { + negated = "NE"; + } else if (operator.equals("NE")) { + negated = "EQ"; + } else if (operator.equals("LT")) { + negated = "GE"; + } else if (operator.equals("GT")) { + negated = "LE"; + } else if (operator.equals("LE")) { + negated = "GT"; + } else if (operator.equals("LIKE")) { + negated = "NE"; + } else if (operator.equals("NOTLIKE")) { + negated = "EQ"; + } else { + negated = "LT"; + } return new OperatorExpression(value, name, negated); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableEnumeratedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableEnumeratedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableEnumeratedProfileElement.java index 67168b0..85f93b6 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableEnumeratedProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableEnumeratedProfileElement.java @@ -37,11 +37,13 @@ public class SearchableEnumeratedProfileElement extends EnumeratedProfileElement Result rc = FalseResult.INSTANCE; if (operator.equals("EQ") || operator.equals("LE") || operator.equals("GE") || operator.equals("LIKE")) { - if (values.contains(value)) - rc = new MatchingResult(this); + if (values.contains(value)) { + rc = new MatchingResult(this); + } } else if (operator.equals("NE") || operator.equals("NOTLIKE")) { - if (!values.contains(value)) - rc = new MatchingResult(this); + if (!values.contains(value)) { + rc = new MatchingResult(this); + } } return rc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableRangedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableRangedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableRangedProfileElement.java index e8ae0f6..b2125f6 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableRangedProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableRangedProfileElement.java @@ -37,17 +37,29 @@ public class SearchableRangedProfileElement extends RangedProfileElement impleme Result rc = FalseResult.INSTANCE; double numeric = Double.parseDouble(value); if (operator.equals("EQ") || operator.equals("LIKE")) { - if (Double.parseDouble(min) <= numeric && numeric <= Double.parseDouble(max)) rc = new MatchingResult(this); + if (Double.parseDouble(min) <= numeric && numeric <= Double.parseDouble(max)) { + rc = new MatchingResult(this); + } } else if (operator.equals("NE") || operator.equals("NOTLIKE")) { - if (numeric < Double.parseDouble(min) || numeric > Double.parseDouble(max)) rc = new MatchingResult(this); + if (numeric < Double.parseDouble(min) || numeric > Double.parseDouble(max)) { + rc = new MatchingResult(this); + } } else if (operator.equals("LT")) { - if (numeric > Double.parseDouble(min)) rc = new MatchingResult(this); + if (numeric > Double.parseDouble(min)) { + rc = new MatchingResult(this); + } } else if (operator.equals("GT")) { - if (numeric < Double.parseDouble(max)) rc = new MatchingResult(this); + if (numeric < Double.parseDouble(max)) { + rc = new MatchingResult(this); + } } else if (operator.equals("LE")) { - if (numeric >= Double.parseDouble(min)) rc = new MatchingResult(this); + if (numeric >= Double.parseDouble(min)) { + rc = new MatchingResult(this); + } } else { - if (numeric <= Double.parseDouble(max)) rc = new MatchingResult(this); + if (numeric <= Double.parseDouble(max)) { + rc = new MatchingResult(this); + } } return rc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java index d5fc3a0..77786e1 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java @@ -42,80 +42,87 @@ public class SearchableResourceAttributes extends ResourceAttributes { * @return a <code>Result</code> value. */ public Result result(String name, String value, String operator) { - if ("Identifier".equals(name)) - return computeResult(identifier, value, operator); - else if ("Title".equals(name)) - return computeResult(title, value, operator); - else if ("Format".equals(name)) - return computeResult(formats, value, operator); - else if ("Description".equals(name)) - return computeResult(description, value, operator); - else if ("Creator".equals(name)) - return computeResult(creators, value, operator); - else if ("Subject".equals(name)) - return computeResult(subjects, value, operator); - else if ("Publisher".equals(name)) - return computeResult(publishers, value, operator); - else if ("Contributor".equals(name)) - return computeResult(contributors, value, operator); - else if ("Date".equals(name)) - return computeResult(dates, value, operator); - else if ("Type".equals(name)) - return computeResult(types, value, operator); - else if ("Source".equals(name)) - return computeResult(sources, value, operator); - else if ("Language".equals(name)) - return computeResult(languages, value, operator); - else if ("Relation".equals(name)) - return computeResult(relations, value, operator); - else if ("Coverage".equals(name)) - return computeResult(coverages, value, operator); - else if ("Rights".equals(name)) - return computeResult(rights, value, operator); - else if ("resContext".equals(name)) - return computeResult(contexts, value, operator); - else if ("resClass".equals(name)) - return computeResult(clazz, value, operator); - else if ("resLocation".equals(name)) - return computeResult(locations, value, operator); - else - throw new IllegalArgumentException("Unknown attribute \"" + name + "\""); + if ("Identifier".equals(name)) { + return computeResult(identifier, value, operator); + } else if ("Title".equals(name)) { + return computeResult(title, value, operator); + } else if ("Format".equals(name)) { + return computeResult(formats, value, operator); + } else if ("Description".equals(name)) { + return computeResult(description, value, operator); + } else if ("Creator".equals(name)) { + return computeResult(creators, value, operator); + } else if ("Subject".equals(name)) { + return computeResult(subjects, value, operator); + } else if ("Publisher".equals(name)) { + return computeResult(publishers, value, operator); + } else if ("Contributor".equals(name)) { + return computeResult(contributors, value, operator); + } else if ("Date".equals(name)) { + return computeResult(dates, value, operator); + } else if ("Type".equals(name)) { + return computeResult(types, value, operator); + } else if ("Source".equals(name)) { + return computeResult(sources, value, operator); + } else if ("Language".equals(name)) { + return computeResult(languages, value, operator); + } else if ("Relation".equals(name)) { + return computeResult(relations, value, operator); + } else if ("Coverage".equals(name)) { + return computeResult(coverages, value, operator); + } else if ("Rights".equals(name)) { + return computeResult(rights, value, operator); + } else if ("resContext".equals(name)) { + return computeResult(contexts, value, operator); + } else if ("resClass".equals(name)) { + return computeResult(clazz, value, operator); + } else if ("resLocation".equals(name)) { + return computeResult(locations, value, operator); + } else { + throw new IllegalArgumentException("Unknown attribute \"" + name + "\""); + } } private Result computeResult(String a, String b, String op) { int c = a.compareTo(b); boolean t; - if ("EQ".equals(op) || "LIKE".equals(op)) - t = c == 0; - else if ("GE".equals(op)) - t = c >= 0; - else if ("GT".equals(op)) - t = c > 0; - else if ("LE".equals(op)) - t = c <= 0; - else if ("LT".equals(op)) - t = c < 0; - else if ("NE".equals(op) || "NOTLIKE".equals(op)) - t = c != 0; - else - throw new IllegalArgumentException("Unknown relational operator \"" + op + "\""); - if (t) - return new MatchingResult(new HashSet(profile.getProfileElements().values())); - else - return FalseResult.INSTANCE; + if ("EQ".equals(op) || "LIKE".equals(op)) { + t = c == 0; + } else if ("GE".equals(op)) { + t = c >= 0; + } else if ("GT".equals(op)) { + t = c > 0; + } else if ("LE".equals(op)) { + t = c <= 0; + } else if ("LT".equals(op)) { + t = c < 0; + } else if ("NE".equals(op) || "NOTLIKE".equals(op)) { + t = c != 0; + } else { + throw new IllegalArgumentException("Unknown relational operator \"" + op + "\""); + } + if (t) { + return new MatchingResult(new HashSet(profile.getProfileElements().values())); + } else { + return FalseResult.INSTANCE; + } } private Result computeResult(List a, String b, String op) { - if (a == null || a.isEmpty()) return FalseResult.INSTANCE; + if (a == null || a.isEmpty()) { + return FalseResult.INSTANCE; + } Result f = FalseResult.INSTANCE; Result t = new MatchingResult(new HashSet(profile.getProfileElements().values())); Result rc = f; - if ("EQ".equals(op) || "LIKE".equals(op)) - if (a.contains(b)) rc = t; - else if ("NE".equals(op) || "NOTLIKE".equals(op)) - if (!a.contains(b)) rc = t; - else if ("LT".equals(op) || "GT".equals(op) || "LE".equals(op) || "GE".equals(op)) { + if ("EQ".equals(op) || "LIKE".equals(op)) { + if (a.contains(b)) { + rc = t; + } else if ("NE".equals(op) || "NOTLIKE".equals(op)) { + if (!a.contains(b)) { + rc = t; + } else if ("LT".equals(op) || "GT".equals(op) || "LE".equals(op) || "GE".equals(op)) { for (Object anA : a) { String value = (String) anA; rc = computeResult(value, b, op); @@ -123,7 +130,11 @@ public class SearchableResourceAttributes extends ResourceAttributes { break; } } - } else throw new IllegalArgumentException("Unknown relational operator \"" + op + "\""); + } else { + throw new IllegalArgumentException("Unknown relational operator \"" + op + "\""); + } + } + } return rc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java index f3921c3..b276d14 100644 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java +++ b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java @@ -66,9 +66,10 @@ public class BasicProtocolVerifier implements ProtocolVerifier { protocol.cdHome(); // Verify again at home directory - if (home == null || !home.equals(protocol.pwd())) - throw new ProtocolException( - "Home directory not the same after cd"); + if (home == null || !home.equals(protocol.pwd())) { + throw new ProtocolException( + "Home directory not the same after cd"); + } } catch (Exception e) { LOG.log(Level.SEVERE, "Protocol " + protocol.getClass().getCanonicalName() http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java index d55b08b..06663e1 100644 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java +++ b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java @@ -168,14 +168,15 @@ public class CommonsNetFtpProtocol implements Protocol { + " : " + e.getMessage(), e); } finally { // close output stream - if (os != null) - try { - os.close(); - } catch (Exception e) { - toFile.delete(); - throw new ProtocolException("Failed to close outputstream : " - + e.getMessage(), e); - } + if (os != null) { + try { + os.close(); + } catch (Exception e) { + toFile.delete(); + throw new ProtocolException("Failed to close outputstream : " + + e.getMessage(), e); + } + } } } @@ -196,8 +197,9 @@ public class CommonsNetFtpProtocol implements Protocol { */ public void cd(ProtocolFile file) throws ProtocolException { try { - if (!ftp.changeWorkingDirectory(file.getPath())) - throw new Exception("Directory change method returned false"); + if (!ftp.changeWorkingDirectory(file.getPath())) { + throw new Exception("Directory change method returned false"); + } } catch (Exception e) { throw new ProtocolException("Failed to cd to " + file.getPath() + " : " + e.getMessage()); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java index dba31cb..1146b19 100644 --- a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java +++ b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java @@ -70,9 +70,10 @@ public class HttpProtocol implements Protocol { } if (!HttpUtils - .isDirectory(httpFile.getLink(), file.getPath())) + .isDirectory(httpFile.getLink(), file.getPath())) { throw new ProtocolException(file - + " is not a directory (mime type must be text/html)"); + + " is not a directory (mime type must be text/html)"); + } this.currentFile = httpFile; } catch (Exception e) { throw new ProtocolException("Failed to cd to " + file + " : " @@ -131,18 +132,20 @@ public class HttpProtocol implements Protocol { throw new ProtocolException("Failed to get file '" + fromFile + "' : " + e.getMessage(), e); } finally { - if (in != null) + if (in != null) { try { in.close(); } catch (Exception e) { // log failure } - if (out != null) + } + if (out != null) { try { out.close(); } catch (Exception e) { // log failure } + } } } @@ -321,14 +324,16 @@ public class HttpProtocol implements Protocol { public static void main(String[] args) throws Exception { String urlString = null, downloadToDir = null; for (int i = 0; i < args.length; i++) { - if (args[i].equals("--url")) + if (args[i].equals("--url")) { urlString = args[++i]; - else if (args[i].equals("--downloadToDir")) + } else if (args[i].equals("--downloadToDir")) { downloadToDir = args[++i]; + } } - if (urlString == null) + if (urlString == null) { throw new Exception("Must specify a url to download: --url <url>"); + } URL url = new URL(urlString); ProtocolFile urlFile = new HttpFile(url.getPath(), false, url); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/util/HttpUtils.java ---------------------------------------------------------------------- diff --git a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/util/HttpUtils.java b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/util/HttpUtils.java index 5788262..9a35934 100644 --- a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/util/HttpUtils.java +++ b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/util/HttpUtils.java @@ -93,8 +93,9 @@ public class HttpUtils { // Read in link StringBuilder sb = new StringBuilder(""); - while (scanner.hasNext()) - sb.append(scanner.nextLine()); + while (scanner.hasNext()) { + sb.append(scanner.nextLine()); + } return sb.toString(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java b/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java index e5fdf5f..290f3ea 100644 --- a/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java +++ b/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java @@ -84,11 +84,12 @@ public class ImapsProtocol implements Protocol { public synchronized void cd(ProtocolFile file) throws ProtocolException { try { String remotePath = file.getPath(); - if (remotePath.startsWith("/")) + if (remotePath.startsWith("/")) { remotePath = remotePath.substring(1); - if (remotePath.trim().equals("")) + } + if (remotePath.trim().equals("")) { homeFolder = currentFolder = store.getDefaultFolder(); - else { + } else { homeFolder = currentFolder = store.getFolder(remotePath); } } catch (Exception e) { @@ -158,8 +159,9 @@ public class ImapsProtocol implements Protocol { } private synchronized void decrementConnections() { - if (connectCalls > 0) + if (connectCalls > 0) { connectCalls--; + } } public synchronized void get(ProtocolFile fromFile, File toFile) @@ -196,21 +198,24 @@ public class ImapsProtocol implements Protocol { ps.print("From:"); Address[] senders = message.getFrom(); - for (Address address : senders) + for (Address address : senders) { ps.print(" " + address.toString()); + } ps.print("\nTo:"); Set<Address> recipients = new LinkedHashSet<Address>(Arrays.asList(message .getAllRecipients())); - for (Address address : recipients) + for (Address address : recipients) { ps.print(" " + address.toString()); + } ps.println("\nSubject: " + message.getSubject()); ps.println("----- ~ Message ~ -----"); String content = this.getContentFromHTML(message); - if (content.equals("")) + if (content.equals("")) { content = this.getContentFromPlainText(message); + } ps.println(content); ps.close(); @@ -237,8 +242,9 @@ public class ImapsProtocol implements Protocol { } // changedDir = false; } catch (Exception e) { - if (!currentFolder.getFullName().equals("")) + if (!currentFolder.getFullName().equals("")) { throw new ProtocolException("Failed to ls : " + e.getMessage(), e); + } } finally { try { closeFolder(currentFolder); @@ -266,8 +272,9 @@ public class ImapsProtocol implements Protocol { } } } catch (Exception e) { - if (!currentFolder.getFullName().equals("")) + if (!currentFolder.getFullName().equals("")) { throw new ProtocolException("Failed to ls : " + e.getMessage(), e); + } } finally { try { closeFolder(currentFolder); @@ -281,8 +288,9 @@ public class ImapsProtocol implements Protocol { throws ProtocolException { try { String pwd = currentFolder.getFullName(); - if (!pwd.equals("") && !pwd.startsWith("/")) + if (!pwd.equals("") && !pwd.startsWith("/")) { pwd = "/" + pwd; + } return new ProtocolFile(pwd, true); } catch (Exception e) { throw new ProtocolException("Failed to pwd : " + e.getMessage(), e); @@ -311,12 +319,14 @@ public class ImapsProtocol implements Protocol { } else if (p.isMimeType("multipart/*")) { Multipart mp = (Multipart) p.getContent(); int count = mp.getCount(); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { content.append(getContentFromPlainText(mp.getBodyPart(i))); + } } else { Object obj = p.getContent(); - if (obj instanceof Part) + if (obj instanceof Part) { content.append(getContentFromPlainText((Part) p.getContent())); + } } return content.toString().replaceAll(" \\r\\n", "").replaceAll(" \\n", ""); } @@ -327,8 +337,9 @@ public class ImapsProtocol implements Protocol { if (p.isMimeType("multipart/*")) { Multipart mp = (Multipart) p.getContent(); int count = mp.getCount(); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { content.append(getContentFromHTML(mp.getBodyPart(i))); + } } else if (p.isMimeType("text/html")) { HtmlParser parser = new HtmlParser(); Metadata met = new Metadata(); @@ -339,8 +350,9 @@ public class ImapsProtocol implements Protocol { content.append(handler.toString()); } else { Object obj = p.getContent(); - if (obj instanceof Part) + if (obj instanceof Part) { content.append(getContentFromHTML((Part) p.getContent())); + } } return content.toString(); } @@ -362,8 +374,9 @@ public class ImapsProtocol implements Protocol { } private synchronized void closeFolder(Folder folder) { - if (openCalls > 0) + if (openCalls > 0) { openCalls--; + } if (openCalls <= 0) { try { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java ---------------------------------------------------------------------- diff --git a/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java b/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java index c2fda6a..b3a83b9 100644 --- a/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java +++ b/protocol/imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java @@ -30,8 +30,9 @@ public class ImapsProtocolFactory implements ProtocolFactory { private ImapsProtocol imapsClient; public ImapsProtocol newInstance() { - if (this.imapsClient == null) + if (this.imapsClient == null) { this.imapsClient = new ImapsProtocol(); + } return this.imapsClient; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/Config.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/Config.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/Config.java index 790f51b..10a55ed 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/Config.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/Config.java @@ -308,8 +308,9 @@ public class Config implements ConfigMetKeys { this.writeMetFile = Boolean.getBoolean(WRITE_MET_FILE); String timeoutString = PropertiesUtils.getProperties( PROTOCOL_TIMEOUT_MS, new String[] { "600000" })[0]; - if (timeoutString == null) + if (timeoutString == null) { timeoutString = "0"; + } pi.setDownloadTimeout(Long.parseLong(timeoutString)); pi.setPageSize(Integer.parseInt(PropertiesUtils.getProperties( PROTOCOL_PAGE_SIZE, new String[] { "8" })[0])); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/DaemonInfo.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/DaemonInfo.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/DaemonInfo.java index 98a21a9..34966eb 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/DaemonInfo.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/DaemonInfo.java @@ -52,24 +52,29 @@ public class DaemonInfo { DataFilesInfo dfi) throws ParseException { this.runOnReboot = runOnReboot; if (firstRunDateTimeString != null - && !firstRunDateTimeString.equals("")) - this.firstRunDateTime = utcFormat.parse(firstRunDateTimeString); - else - this.firstRunDateTime = new Date(); - if (period != null && !period.equals("")) - this.timeIntervalInMilliseconds = Long.parseLong(period.substring( - 0, period.length() - 1)) - * this.getMillisecondsInMetric((period.charAt(period - .length() - 1) + "").toLowerCase()); - else - this.timeIntervalInMilliseconds = -1; - if (epsilon != null && !epsilon.equals("")) - this.epsilonInMilliseconds = Long.parseLong(epsilon.substring(0, - epsilon.length() - 1)) - * this.getMillisecondsInMetric((epsilon.charAt(epsilon - .length() - 1) + "").toLowerCase()); - else - this.epsilonInMilliseconds = -1; + && !firstRunDateTimeString.equals("")) { + this.firstRunDateTime = utcFormat.parse(firstRunDateTimeString); + } else { + this.firstRunDateTime = new Date(); + } + if (period != null && !period.equals("")) { + this.timeIntervalInMilliseconds = Long.parseLong(period.substring( + 0, period.length() - 1)) + * this.getMillisecondsInMetric((period.charAt(period + .length() - 1) + "") + .toLowerCase()); + } else { + this.timeIntervalInMilliseconds = -1; + } + if (epsilon != null && !epsilon.equals("")) { + this.epsilonInMilliseconds = Long.parseLong(epsilon.substring(0, + epsilon.length() - 1)) + * this.getMillisecondsInMetric((epsilon.charAt(epsilon + .length() - 1) + "") + .toLowerCase()); + } else { + this.epsilonInMilliseconds = -1; + } this.pfi = pfi; this.dfi = dfi; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/PropFilesInfo.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/PropFilesInfo.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/PropFilesInfo.java index ad7aba8..87054dc 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/PropFilesInfo.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/PropFilesInfo.java @@ -64,8 +64,9 @@ public class PropFilesInfo { public LinkedList<File> getDownloadInfoPropFiles() { LinkedList<File> returnList = new LinkedList<File>(); - for (Entry<File, Parser> entry : this.fileToParserMap.entrySet()) + for (Entry<File, Parser> entry : this.fileToParserMap.entrySet()) { returnList.add(entry.getKey()); + } return returnList; } @@ -81,15 +82,17 @@ public class PropFilesInfo { public Parser getParserForFile(File propFile) { Parser parser = this.fileToParserMap == null ? null : this.fileToParserMap.get(propFile); - if (parser == null) + if (parser == null) { parser = this.getParserForFilename(propFile.getName()); + } return parser; } public Parser getParserForFilename(String propFilename) { for (RegExpAndParser pattern : patterns) { - if (pattern.isAcceptedByPattern(propFilename)) + if (pattern.isAcceptedByPattern(propFilename)) { return pattern.getParser(); + } } return null; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/ProtocolInfo.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/ProtocolInfo.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/ProtocolInfo.java index 2972d0b..a499021 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/ProtocolInfo.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/ProtocolInfo.java @@ -138,10 +138,11 @@ public class ProtocolInfo implements ConfigParserMetKeys { } public void setPageSize(int pgSize) { - if (pgSize != -1) - this.pgSize = pgSize; - else - this.pgSize = Integer.MAX_VALUE; + if (pgSize != -1) { + this.pgSize = pgSize; + } else { + this.pgSize = Integer.MAX_VALUE; + } } public LinkedList<Class<ProtocolFactory>> getProtocolClassesForProtocolType( http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java index aa72487..7806cd5 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java @@ -79,8 +79,9 @@ public class RemoteSpecs implements ConfigParserMetKeys { // check if set to active (skip otherwise) if (PathUtils.replaceEnvVariables( ((Element) daemonNode).getAttribute(ACTIVE_ATTR)) - .equals("no")) + .equals("no")) { continue; + } DaemonInfo di = null; @@ -90,11 +91,12 @@ public class RemoteSpecs implements ConfigParserMetKeys { .getAttribute(ALIAS_ATTR)); RemoteSite dataFilesRemoteSite = this.siteInfo .getSiteByAlias(siteAlias); - if (dataFilesRemoteSite == null) + if (dataFilesRemoteSite == null) { throw new ConfigException("Alias '" + siteAlias + "' in SiteInfo file '" + remoteSpecsFile.getAbsolutePath() + "' has not been defined"); + } // get RUNINFO element NodeList runInfoList = ((Element) daemonNode) @@ -109,8 +111,9 @@ public class RemoteSpecs implements ConfigParserMetKeys { runOnReboot = (runInfo.getAttribute(RUNONREBOOT_ATTR) .toLowerCase().equals("yes")); epsilon = runInfo.getAttribute(EPSILON_ATTR); - if (epsilon.equals("")) + if (epsilon.equals("")) { epsilon = "0s"; + } } // get PROPINFO elements @@ -146,12 +149,13 @@ public class RemoteSpecs implements ConfigParserMetKeys { .replaceEnvVariables(((Element) propFilesNode) .getAttribute(PARSER_ATTR))))); } - } else + } else { throw new ConfigException( "No propFiles element specified for deamon with alias '" + siteAlias + "' in RemoteSpecs file '" + remoteSpecsFile.getAbsolutePath() + "'"); + } // get DOWNLOADINFO element if given NodeList downloadInfoList = ((Element) propInfoNode) @@ -175,16 +179,18 @@ public class RemoteSpecs implements ConfigParserMetKeys { .equals("yes"); RemoteSite propFilesRemoteSite = this.siteInfo .getSiteByAlias(propFilesAlias); - if (propFilesRemoteSite == null) + if (propFilesRemoteSite == null) { throw new ConfigException("Alias '" + propFilesAlias + "' in RemoteSpecs file '" + remoteSpecsFile.getAbsolutePath() + "' has not been defined"); + } String regExp = ((Element) downloadInfo) .getAttribute(REG_EXP_ATTR); - if (regExp.equals("")) + if (regExp.equals("")) { regExp = propFilesRegExp; + } NodeList propsList = ((Element) propInfoNode) .getElementsByTagName(PROP_FILE_TAG); HashMap<File, Parser> propFileToParserMap = new HashMap<File, Parser>(); @@ -226,11 +232,12 @@ public class RemoteSpecs implements ConfigParserMetKeys { pfi.setDeleteOnSuccess(deleteOnSuccess); } - } else + } else { throw new ConfigException( "No propInfo element specified for deamon with alias '" + siteAlias + "' in RemoteSpecs file '" + remoteSpecsFile.getAbsolutePath() + "'"); + } // get DATAINFO elements NodeList dataInfoList = ((Element) daemonNode) @@ -264,11 +271,12 @@ public class RemoteSpecs implements ConfigParserMetKeys { dfi = new DataFilesInfo(queryElement, new DownloadInfo( dataFilesRemoteSite, renamingConv, deleteFromServer, stagingArea, allowAliasOverride)); - } else + } else { throw new ConfigException( "No dataInfo element specified for deamon with alias '" + siteAlias + "' in RemoteSpecs file '" + remoteSpecsFile.getAbsolutePath() + "'"); + } daemonInfoList.add(new DaemonInfo(firstRunDateTimeString, period, epsilon, runOnReboot, pfi, dfi)); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java index 797a1da..8cedd59 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java @@ -66,10 +66,11 @@ public class SiteInfo { LinkedList<RemoteSite> remoteSites = new LinkedList<RemoteSite>(); if (alias != null) { RemoteSite rs = this.aliasAndRemoteSite.get(alias); - if (rs != null) - remoteSites.add(rs); - else if (url != null && username != null & password != null) - remoteSites.add(new RemoteSite(alias, url, username, password)); + if (rs != null) { + remoteSites.add(rs); + } else if (url != null && username != null & password != null) { + remoteSites.add(new RemoteSite(alias, url, username, password)); + } } else if (url != null) { Set<Entry<String, RemoteSite>> set = this.aliasAndRemoteSite .entrySet(); @@ -80,16 +81,18 @@ public class SiteInfo { && (username == null || rs.getUsername().equals( username)) && (password == null || rs.getPassword().equals( - password))) - remoteSites.add(rs); + password))) { + remoteSites.add(rs); + } } catch (URISyntaxException e) { LOG.log(Level.SEVERE, "Could not convert URL to URI Message: "+e.getMessage()); } } if (remoteSites.size() == 0) { - if (username != null && password != null) - remoteSites.add(new RemoteSite(url.toString(), url, - username, password)); + if (username != null && password != null) { + remoteSites.add(new RemoteSite(url.toString(), url, + username, password)); + } } } else if (username != null) { Set<Entry<String, RemoteSite>> set = this.aliasAndRemoteSite @@ -98,16 +101,18 @@ public class SiteInfo { RemoteSite rs = entry.getValue(); if (rs.getUsername().equals(username) && (password == null || rs.getPassword().equals( - password))) - remoteSites.add(rs); + password))) { + remoteSites.add(rs); + } } } else if (password != null) { Set<Entry<String, RemoteSite>> set = this.aliasAndRemoteSite .entrySet(); for (Entry<String, RemoteSite> entry : set) { RemoteSite rs = entry.getValue(); - if (rs.getPassword().equals(password)) - remoteSites.add(rs); + if (rs.getPassword().equals(password)) { + remoteSites.add(rs); + } } } return remoteSites; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java index 6fd2f72..42c5f6a 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java @@ -192,8 +192,9 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, if ((timeTilNextRun = Daemon.this.calculateTimeTilNextRun()) != 0 && !(Daemon.this.beforeToday(daemonInfo .getFirstRunDateTime()) && daemonInfo - .runOnReboot())) + .runOnReboot())) { sleep(timeTilNextRun); + } for (keepRunning = true; keepRunning;) { long startTime = System.currentTimeMillis(); @@ -262,11 +263,11 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, GregorianCalendar gcStartDateTime = new GregorianCalendar(); gcStartDateTime.setTime(daemonInfo.getFirstRunDateTime()); long diff = now.getTimeInMillis() - gcStartDateTime.getTimeInMillis(); - if (Math.abs(diff) <= daemonInfo.getEpsilonInMilliseconds()) + if (Math.abs(diff) <= daemonInfo.getEpsilonInMilliseconds()) { return 0; - else if (diff < 0) + } else if (diff < 0) { return gcStartDateTime.getTimeInMillis() - now.getTimeInMillis(); - else if (daemonInfo.getTimeIntervalInMilliseconds() == 0) { + } else if (daemonInfo.getTimeIntervalInMilliseconds() == 0) { return 0; } else { int numOfPeriods = (int) (diff / daemonInfo @@ -283,13 +284,15 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, } private void notifyDaemonListenerOfStart() { - if (this.daemonListener != null) + if (this.daemonListener != null) { this.daemonListener.daemonStarting(this); + } } private void notifyDaemonListenerOfFinish() { - if (this.daemonListener != null) + if (this.daemonListener != null) { this.daemonListener.daemonFinished(this); + } } private void sleep(long length) { @@ -457,8 +460,9 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, public String getQueryMetadataElementName() { String element = this.daemonInfo.getDataFilesInfo() .getQueryMetadataElementName(); - if (element == null || element.equals("")) + if (element == null || element.equals("")) { element = "Filename"; + } return this.daemonInfo.getDataFilesInfo().getQueryMetadataElementName(); } @@ -541,10 +545,11 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, boolean waitForCrawlNotification = false; for (int i = 0; i < args.length; ++i) { - if (args[i].equals("--rmiPort")) + if (args[i].equals("--rmiPort")) { rmiPort = Integer.parseInt(args[++i]); - else if (args[i].equals("--waitForNotification")) + } else if (args[i].equals("--waitForNotification")) { waitForCrawlNotification = true; + } } LocateRegistry.createRegistry(rmiPort); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 88da43f..6c3621d 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 @@ -197,8 +197,9 @@ public class DaemonController { } else if (operation.equals("--isRunning")) { boolean running = controller.isRunning(); System.out.println(running ? "Yes" : "No"); - } else + } else { throw new IllegalArgumentException("Unknown Operation!"); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonLauncher.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonLauncher.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonLauncher.java index da42f3d..5eb2a61 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonLauncher.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonLauncher.java @@ -130,8 +130,9 @@ public class DaemonLauncher implements DaemonLauncherMBean { } private synchronized int getNextDaemonId() { - while (this.dm.getUsedIDs().contains(++this.nextDaemonId)) + while (this.dm.getUsedIDs().contains(++this.nextDaemonId)) { ; + } return this.nextDaemonId; } @@ -147,8 +148,9 @@ public class DaemonLauncher implements DaemonLauncherMBean { LOG.log(Level.INFO, "Killing current Daemons . . ."); this.nextDaemonId = 0; for (Daemon daemon : this.activeDaemonList) { - if (!daemon.getHasBeenToldToQuit()) + if (!daemon.getHasBeenToldToQuit()) { daemon.quit(); + } } activeDaemonList.clear(); } @@ -169,12 +171,13 @@ public class DaemonLauncher implements DaemonLauncherMBean { LinkedList<File> sitesFiles = new LinkedList<File>(); for (int i = 0; i < args.length; ++i) { - if (args[i].equals("--rmiRegistryPort")) + if (args[i].equals("--rmiRegistryPort")) { rmiRegPort = Integer.parseInt(args[++i]); - else if (args[i].equals("--propertiesFile")) + } else if (args[i].equals("--propertiesFile")) { propertiesFile = new File(args[++i]); - else if (args[i].equals("--remoteSpecsFile")) + } else if (args[i].equals("--remoteSpecsFile")) { sitesFiles.add(new File(args[++i])); + } } DaemonLauncher daemonLauncher = new DaemonLauncher(rmiRegPort, http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java index 9e99ab5..04de6dc 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java @@ -74,10 +74,11 @@ public class DaemonManager implements DaemonListener { } public void daemonFinished(Daemon daemon) { - if (daemon.equals(this.runningDaemon)) + if (daemon.equals(this.runningDaemon)) { this.startNextOnWaitingList(); - else + } else { this.waitingList.remove(daemon); + } } public synchronized HashSet<Integer> getUsedIDs() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java index 7d56680..41e0162 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java @@ -76,8 +76,9 @@ public class Method { return false; } return true; - } else + } else { return false; + } } public void addArg(Variable v) { @@ -113,10 +114,11 @@ public class Method { // System.out.println("ch = " + ch); if ((ch <= 'Z' && ch >= 'A') || (ch <= 'z' && ch >= 'a') - || (ch <= '9' && ch >= '0') || ch == '_') + || (ch <= '9' && ch >= '0') || ch == '_') { variable.append(ch); - else + } else { break; + } } if (globalVar) { @@ -138,10 +140,11 @@ public class Method { int k = i + 1; for (; k < infixArray.length; k++) { char ch = infixArray[k]; - if (ch <= '9' && ch >= '0') + if (ch <= '9' && ch >= '0') { variableIntString.append(ch); - else + } else { break; + } } output.addLast(new Variable(null, new Integer( variableIntString.toString()))); @@ -152,10 +155,11 @@ public class Method { int l = i + 1; for (; l < infixArray.length; l++) { char ch = infixArray[l]; - if (ch != '"') + if (ch != '"') { variableString.append(ch); - else + } else { break; + } } output .addLast(new Variable(null, variableString @@ -178,8 +182,9 @@ public class Method { case ')': while (!stack.empty()) { ValidInput vi = stack.pop(); - if (vi.toString().charAt(0) == '(') + if (vi.toString().charAt(0) == '(') { break; + } output.addLast(vi); } break; @@ -189,8 +194,9 @@ public class Method { } } - while (!stack.empty()) + while (!stack.empty()) { output.addLast(stack.pop()); + } return output; } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java index 949aab8..38f5ecb 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java @@ -482,8 +482,9 @@ public class FileRestrictions { vfDoesNotExist = true; lastFileIsDir = file.isDir(); file = file.getParentFile(); - if (file == null) + if (file == null) { break; + } } return !(file == null || (vfDoesNotExist && ((lastFileIsDir && !vf .allowNewDirs()) || (!lastFileIsDir && !vf.allowNewFiles())))); @@ -505,11 +506,12 @@ public class FileRestrictions { LinkedList<String> stringList = new LinkedList<String>(); for (VirtualFile child : children) { String currentPath = curPath + "/" + child.getRegExp(); - if (!child.isDir()) + if (!child.isDir()) { stringList.add(currentPath); - else + } else { stringList - .addAll(toStringList(child.getChildren(), currentPath)); + .addAll(toStringList(child.getChildren(), currentPath)); + } } return stringList; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java index c49f35a..8c30779 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java @@ -79,13 +79,15 @@ public class VirtualFile { vf.addChild(this); } else if (st.countTokens() > 0) { this.regExp = st.nextToken(); - if (path.startsWith("/")) + if (path.startsWith("/")) { VirtualFile.createRootDir().addChild(this); + } } else { this.copy(VirtualFile.createRootDir()); } - } else + } else { this.copy(VirtualFile.createRootDir()); + } } public VirtualFile(VirtualFile root, String path, boolean isDir) { @@ -106,10 +108,12 @@ public class VirtualFile { } this.regExp = curRegExp; vf.addChild(this); - } else + } else { this.copy(root); - } else + } + } else { this.copy(root); + } } public static VirtualFile createRootDir() { @@ -120,8 +124,9 @@ public class VirtualFile { public VirtualFile getRootDir() { VirtualFile vf = this; - while (vf.getParentFile() != null) + while (vf.getParentFile() != null) { vf = vf.getParentFile(); + } return vf; } @@ -131,8 +136,9 @@ public class VirtualFile { newFile.children.addAll(vf1.children); newFile.children.addAll(vf2.children); return newFile; - } else + } else { return null; + } } public void addChild(VirtualFile vf) { @@ -141,10 +147,11 @@ public class VirtualFile { vf.isDir); if (existingChildWithSameName == null) { children.add(vf); - if (vf.isDir()) + if (vf.isDir()) { allowNewDirs = false; - else + } else { allowNewFiles = false; + } vf.parent = this; } else { vf.copy(existingChildWithSameName); @@ -160,8 +167,9 @@ public class VirtualFile { for (VirtualFile vf : children) { // System.out.println("GETCHILD: " + regExp + " " + vf.regExp); if ((regExp.equals(vf.regExp) || Pattern.matches(vf.regExp, regExp)) - && vf.isDir == isDirectory) + && vf.isDir == isDirectory) { return vf; + } } return null; } @@ -176,8 +184,9 @@ public class VirtualFile { while (st.hasMoreTokens()) { String curRegExp = st.nextToken(); if (st.hasMoreTokens()) { - if ((vf = vf.getChild(curRegExp, true)) == null) + if ((vf = vf.getChild(curRegExp, true)) == null) { return null; + } } else { return vf.getChild(curRegExp, isDirectory); } @@ -190,8 +199,9 @@ public class VirtualFile { } public String getAbsolutePath() { - if (regExp == null) + if (regExp == null) { return null; + } StringBuilder path = new StringBuilder(this.regExp); VirtualFile parent = this.parent; while (parent != null) { @@ -211,16 +221,18 @@ public class VirtualFile { public void setNoDirs(boolean noDirs) { if (this.isDir) { - if (noDirs) + if (noDirs) { allowNewDirs = false; + } this.noDirs = noDirs; } } public void setNoFiles(boolean noFiles) { if (this.isDir) { - if (noFiles) + if (noFiles) { allowNewFiles = false; + } this.noFiles = noFiles; } } @@ -261,8 +273,9 @@ public class VirtualFile { if (obj instanceof VirtualFile) { VirtualFile compareFile = (VirtualFile) obj; if (compareFile.getRegExp().equals(regExp) - && compareFile.isDir() == this.isDir) + && compareFile.isDir() == this.isDir) { return true; + } } return false; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java index cc148f5..2ff73a9 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java @@ -51,12 +51,14 @@ public class ClassNoaaEmailParser implements Parser { VirtualFile root = VirtualFile.createRootDir(); Scanner s = new Scanner(emailFile); StringBuffer sb = new StringBuffer(""); - while (s.hasNextLine()) - sb.append(s.nextLine()).append("\n"); + while (s.hasNextLine()) { + sb.append(s.nextLine()).append("\n"); + } - if (!validEmail(sb.toString())) - throw new ParserException( - "Email not a IASI data processed notification email"); + if (!validEmail(sb.toString())) { + throw new ParserException( + "Email not a IASI data processed notification email"); + } Pattern cdPattern = Pattern.compile("\\s*cd\\s{1,}.{1,}?(?:\\s|$)"); Matcher cdMatcher = cdPattern.matcher(sb); @@ -108,9 +110,11 @@ public class ClassNoaaEmailParser implements Parser { String[] containsStrings = (System.getProperties() .getProperty("org.apache.oodt.cas.pushpull.filerestrictions.parsers.class.noaa.email.parser.contains.exprs") + ",").split(","); - for (String containsString : containsStrings) - if (!email.contains(containsString)) - return false; + for (String containsString : containsStrings) { + if (!email.contains(containsString)) { + return false; + } + } return true; } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 55836e6..a6094fc 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 @@ -144,15 +144,17 @@ public class DirStructXmlParser implements Parser { if ((ch <= 'Z' && ch >= 'A') || (ch <= 'z' && ch >= 'a') || (ch <= '9' && ch >= '0') - || ch == '_') - variable.append(ch); - else - break; + || ch == '_') { + variable.append(ch); + } else { + break; + } } Variable v = GlobalVariables.hashMap.get(variable .toString()); - if (v == null) - throw new Exception("No variable defined with name '" + variable.toString() + "'"); + if (v == null) { + throw new Exception("No variable defined with name '" + variable.toString() + "'"); + } input = input.replaceFirst("\\$\\{" + variable + "\\}", v.toString()); i = i + v.toString().length(); } @@ -168,10 +170,11 @@ public class DirStructXmlParser implements Parser { char ch = input.substring(j, j + 1).charAt(0); if ((ch <= 'Z' && ch >= 'A') || (ch <= 'z' && ch >= 'a') - || (ch <= '9' && ch >= '0') || ch == '_') - method.append(ch); - else - break; + || (ch <= '9' && ch >= '0') || ch == '_') { + method.append(ch); + } else { + break; + } } if (input.substring(j, j + 1).charAt(0) == '(') { @@ -261,8 +264,9 @@ public class DirStructXmlParser implements Parser { // determine if variable is an Integer or a String if (type.equals("int")) { variable.setValue(Integer.valueOf(value)); - } else - variable.setValue(value); + } else { + variable.setValue(value); + } // store Variable in list of Variables GlobalVariables.hashMap.put(variable.getName(), variable); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java index 6fff6d8..753e09c 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java @@ -128,10 +128,12 @@ public class RenamingConvention { private static String replace(String theString, String theValueToBeReplaced, String whatToReplaceWith) { - if (theValueToBeReplaced == null || theValueToBeReplaced.equals("")) + if (theValueToBeReplaced == null || theValueToBeReplaced.equals("")) { return theString; - if (whatToReplaceWith == null) + } + if (whatToReplaceWith == null) { whatToReplaceWith = ""; + } return theString.replace(theValueToBeReplaced, whatToReplaceWith); }
