http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java index 22c58d0..13f902e 100755 --- a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java @@ -86,7 +86,9 @@ public abstract class QueryServlet extends GridServlet { public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { try { XMLQuery query = getQuery(req, res); // Get the query - if (query == null) return; // No query? My favorite case, right here! + if (query == null) { + return; // No query? My favorite case, right here! + } Configuration config = getConfiguration(); // Get the current configuration. updateProperties(config); // Using it, update the system properties @@ -129,18 +131,28 @@ public abstract class QueryServlet extends GridServlet { String xmlq = req.getParameter("xmlq"); // Grab any xmlq String q = req.getParameter("q"); // Grab any q String unp = req.getParameter("unp"); // And grab any unp (pronounced "unp") - if (xmlq == null) xmlq = ""; // No xmlq? Use epsilon - if (q == null) q = ""; // No q? Use lambda - if (unp == null) unp = ""; // Use some other greek letter for empty str + if (xmlq == null) { + xmlq = ""; // No xmlq? Use epsilon + } + if (q == null) { + q = ""; // No q? Use lambda + } + if (unp == null) { + unp = ""; // Use some other greek letter for empty str + } String[] mimes = req.getParameterValues("mime"); // Grab any mimes - if (mimes == null) mimes = EMPTY_STRING_ARRAY; // None? Use empty array + if (mimes == null) { + mimes = EMPTY_STRING_ARRAY; // None? Use empty array + } - if (xmlq.length() > 0) try { // Was there an xmlq? - return new XMLQuery(xmlq); // Use it in its entirety, ignoring the rest - } catch (SAXException ex) { // Can't parse it? - res.sendError(HttpServletResponse.SC_BAD_REQUEST, // Then that's a bad ... - "cannot parse xmlq: " + ex.getMessage()); // ... request, which I hate - return null; // so flag it with a null + if (xmlq.length() > 0) { + try { // Was there an xmlq? + return new XMLQuery(xmlq); // Use it in its entirety, ignoring the rest + } catch (SAXException ex) { // Can't parse it? + res.sendError(HttpServletResponse.SC_BAD_REQUEST, // Then that's a bad ... + "cannot parse xmlq: " + ex.getMessage()); // ... request, which I hate + return null; // so flag it with a null + } } else if (q.length() > 0) { // Was there a q? boolean unparsed = "true".equals(unp); // If so, was there also an unp? return new XMLQuery(q, "wgq", "Web Grid Query", // Use it to make an XMLQuery @@ -182,7 +194,9 @@ public abstract class QueryServlet extends GridServlet { for (Iterator i = handlers.iterator(); i.hasNext();) { // Now, for each handler InstantiedHandler handler = (InstantiedHandler) i.next(); // Grab the handler if (!servers.contains(handler.getServer())) // Does its server still exist? - i.remove(); // If not, remove the handler + { + i.remove(); // If not, remove the handler + } } } @@ -193,7 +207,9 @@ public abstract class QueryServlet extends GridServlet { */ private synchronized void updateProperties(Configuration config) { if (properties != null) { // Any old properties? - if (properties.equals(config.getProperties())) return; // Yes, any changes? No? Then done. + if (properties.equals(config.getProperties())) { + return; // Yes, any changes? No? Then done. + } for (Object o : properties.keySet()) { System.getProperties().remove(o); // and remove it. }
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/Server.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/Server.java b/grid/src/main/java/org/apache/oodt/grid/Server.java index e4299a6..84185e1 100755 --- a/grid/src/main/java/org/apache/oodt/grid/Server.java +++ b/grid/src/main/java/org/apache/oodt/grid/Server.java @@ -84,9 +84,9 @@ public abstract class Server implements Serializable { InstantiationException, IllegalAccessException { List urlList = configuration.getCodeBases(); Class clazz; - if (urlList.isEmpty()) + if (urlList.isEmpty()) { clazz = Class.forName(className); - else { + } else { URL[] urls = (URL[]) urlList.toArray(new URL[urlList.size()]); URLClassLoader loader = new URLClassLoader(urls, getClass() .getClassLoader()); @@ -117,8 +117,9 @@ public abstract class Server implements Serializable { } public boolean equals(Object obj) { - if (obj == this) + if (obj == this) { return true; + } if (obj instanceof Server) { Server rhs = (Server) obj; return className.equals(rhs.className); @@ -146,12 +147,13 @@ public abstract class Server implements Serializable { String className = elem.getAttribute("className"); // Replace with a factory some day... - if ("product".equals(type)) + if ("product".equals(type)) { return new ProductServer(configuration, className); - else if ("profile".equals(type)) + } else if ("profile".equals(type)) { return new ProfileServer(configuration, className); - else + } else { throw new SAXException("unknown server type `" + type + "'"); + } } /** Configuration. */ http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/AbstractMetExtractor.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/AbstractMetExtractor.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/AbstractMetExtractor.java index 05a9b52..49f44c8 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/AbstractMetExtractor.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/AbstractMetExtractor.java @@ -68,8 +68,9 @@ public abstract class AbstractMetExtractor implements MetExtractor { * @see org.apache.oodt.cas.metadata.MetExtractor#extractMetadata(java.io.File) */ public Metadata extractMetadata(File f) throws MetExtractionException { - if (f == null || !f.exists()) + if (f == null || !f.exists()) { throw new MetExtractionException("File '" + f + "' does not exist"); + } return this.extrMetadata(this.safeGetCanonicalFile(f)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java index 62d3c9a..6dfcd6f 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java @@ -56,16 +56,18 @@ public class Metadata { * Metadata to add metadata from */ public void addMetadata(Metadata metadata) { - for (String key : metadata.getAllKeys()) + for (String key : metadata.getAllKeys()) { this.addMetadata(key, metadata.getAllMetadata(key)); + } } public void addMetadata(String group, Metadata metadata) { if (group == null) { this.addMetadata(metadata); } else { - for (String key : metadata.getAllKeys()) + for (String key : metadata.getAllKeys()) { this.addMetadata(group + "/" + key, metadata.getAllMetadata(key)); + } } } @@ -75,16 +77,18 @@ public class Metadata { * @param metadata */ public void replaceMetadata(Metadata metadata) { - for (String key : metadata.getAllKeys()) + for (String key : metadata.getAllKeys()) { this.replaceMetadata(key, metadata.getAllMetadata(key)); + } } public void replaceMetadata(String group, Metadata metadata) { if (group == null) { this.replaceMetadata(metadata); } else { - for (String key : metadata.getAllKeys()) + for (String key : metadata.getAllKeys()) { this.replaceMetadata(group + "/" + key, metadata.getAllMetadata(key)); + } } } @@ -145,10 +149,11 @@ public class Metadata { public void removeMetadata(String key) { Group removeGroup = this.getGroup(key, false); if (removeGroup != null && removeGroup.hasValues()) { - if (removeGroup.getChildren().size() > 0) + if (removeGroup.getChildren().size() > 0) { removeGroup.clearValues(); - else + } else { removeGroup.getParent().removeChild(removeGroup.getName()); + } } } @@ -158,8 +163,9 @@ public class Metadata { */ public void removeMetadataGroup(String group) { Group removeGroup = this.getGroup(group, false); - if (removeGroup != null && removeGroup.getChildren().size() > 0) + if (removeGroup != null && removeGroup.getChildren().size() > 0) { removeGroup.getParent().removeChild(removeGroup.getName()); + } } /** @@ -196,8 +202,9 @@ public class Metadata { public Metadata getSubMetadata(String group) { Metadata m = new Metadata(); Group newRoot = this.getGroup(group, false); - if (newRoot != null) + if (newRoot != null) { m.root.addChildren(newRoot.clone().getChildren()); + } return m; } @@ -210,10 +217,11 @@ public class Metadata { */ public String getMetadata(String key) { Group group = this.getGroup(key, false); - if (group != null) + if (group != null) { return group.getValue(); - else + } else { return null; + } } /** @@ -225,10 +233,11 @@ public class Metadata { */ public List<String> getAllMetadata(String key) { Group group = this.getGroup(key, false); - if (group != null) + if (group != null) { return new Vector<String>(group.getValues()); - else + } else { return null; + } } /** @@ -240,10 +249,11 @@ public class Metadata { */ public List<String> getKeys(String group) { Group foundGroup = this.getGroup(group); - if (foundGroup != null) + if (foundGroup != null) { return this.getKeys(foundGroup); - else + } else { return new Vector<String>(); + } } /** @@ -257,9 +267,11 @@ public class Metadata { protected List<String> getKeys(Group group) { Vector<String> keys = new Vector<String>(); - for (Group child : group.getChildren()) - if (child.hasValues()) + for (Group child : group.getChildren()) { + if (child.hasValues()) { keys.add(child.getFullPath()); + } + } return keys; } @@ -272,10 +284,11 @@ public class Metadata { */ public List<String> getAllKeys(String group) { Group foundGroup = this.getGroup(group); - if (foundGroup != null) + if (foundGroup != null) { return this.getAllKeys(foundGroup); - else + } else { return new Vector<String>(); + } } /** @@ -290,8 +303,9 @@ public class Metadata { protected List<String> getAllKeys(Group group) { Vector<String> keys = new Vector<String>(); for (Group child : group.getChildren()) { - if (child.hasValues()) + if (child.hasValues()) { keys.add(child.getFullPath()); + } keys.addAll(this.getAllKeys(child)); } return keys; @@ -308,8 +322,9 @@ public class Metadata { stack.add(this.root); while (!stack.empty()) { Group curGroup = stack.pop(); - if (curGroup.getName().equals(key) && curGroup.hasValues()) - keys.add(curGroup.getFullPath()); + if (curGroup.getName().equals(key) && curGroup.hasValues()) { + keys.add(curGroup.getFullPath()); + } stack.addAll(curGroup.getChildren()); } return keys; @@ -322,8 +337,9 @@ public class Metadata { */ public List<String> getValues() { Vector<String> values = new Vector<String>(); - for (String key : this.getKeys()) + for (String key : this.getKeys()) { values.addAll(this.getAllMetadata(key)); + } return values; } @@ -336,8 +352,9 @@ public class Metadata { */ public List<String> getValues(String group) { Vector<String> values = new Vector<String>(); - for (String key : this.getKeys(group)) + for (String key : this.getKeys(group)) { values.addAll(this.getAllMetadata(key)); + } return values; } @@ -348,8 +365,9 @@ public class Metadata { */ public List<String> getAllValues() { Vector<String> values = new Vector<String>(); - for (String key : this.getAllKeys()) + for (String key : this.getAllKeys()) { values.addAll(this.getAllMetadata(key)); + } return values; } @@ -362,8 +380,9 @@ public class Metadata { */ public List<String> getAllValues(String group) { Vector<String> values = new Vector<String>(); - for (String key : this.getAllKeys(group)) + for (String key : this.getAllKeys(group)) { values.addAll(this.getAllMetadata(key)); + } return values; } @@ -413,8 +432,9 @@ public class Metadata { protected List<String> getGroups(Group group) { Vector<String> groupNames = new Vector<String>(); - for (Group child : group.getChildren()) + for (Group child : group.getChildren()) { groupNames.add(child.getName()); + } return groupNames; } @@ -423,16 +443,18 @@ public class Metadata { } protected Group getGroup(String key, boolean create) { - if (key == null) + if (key == null) { return this.root; + } StringTokenizer tokenizer = new StringTokenizer(key, "/"); Group curGroup = this.root; while (tokenizer.hasMoreTokens()) { String groupName = tokenizer.nextToken(); Group childGroup = curGroup.getChild(groupName); if (childGroup == null) { - if (!create) + if (!create) { return null; + } childGroup = new Group(groupName); curGroup.addChild(childGroup); } @@ -465,10 +487,11 @@ public class Metadata { } public String getFullPath() { - if (this.parent != null && !this.parent.getName().equals(ROOT_GROUP_NAME)) + if (this.parent != null && !this.parent.getName().equals(ROOT_GROUP_NAME)) { return this.parent.getFullPath() + "/" + this.name; - else + } else { return this.name; + } } public Group getParent() { @@ -502,10 +525,11 @@ public class Metadata { } public String getValue() { - if (this.hasValues()) + if (this.hasValues()) { return this.values.get(0); - else + } else { return null; + } } public List<String> getValues() { @@ -518,8 +542,9 @@ public class Metadata { } public void addChildren(List<Group> children) { - for (Group child : children) + for (Group child : children) { this.addChild(child); + } } public List<Group> getChildren() { @@ -538,8 +563,9 @@ public class Metadata { public Group clone() { Group clone = new Group(this.name); clone.setValues(this.values); - for (Group child : this.children.values()) + for (Group child : this.children.values()) { clone.addChild(child.clone()); + } return clone; } @@ -552,8 +578,9 @@ public class Metadata { public Hashtable<String, Object> getHashtable() { Hashtable<String, Object> table = new Hashtable<String, Object>(); - for (String key : this.getAllKeys()) + for (String key : this.getAllKeys()) { table.put(key, this.getAllMetadata(key)); + } return table; } @@ -561,9 +588,11 @@ public class Metadata { if (obj instanceof Metadata) { Metadata compMet = (Metadata) obj; if (this.getKeys().equals(compMet.getKeys())) { - for (String key : this.getKeys()) - if (!this.getAllMetadata(key).equals(compMet.getAllMetadata(key))) + for (String key : this.getKeys()) { + if (!this.getAllMetadata(key).equals(compMet.getAllMetadata(key))) { return false; + } + } return true; } else { return false; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/SerializableMetadata.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/SerializableMetadata.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/SerializableMetadata.java index a47c8be..f7827df 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/SerializableMetadata.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/SerializableMetadata.java @@ -77,8 +77,9 @@ public class SerializableMetadata extends Metadata implements Serializable { public SerializableMetadata(String xmlEncoding, boolean useCDATA) throws InstantiationException { super(); - if (xmlEncoding == null) + if (xmlEncoding == null) { throw new InstantiationException("xmlEncoding cannot be null"); + } this.xmlEncoding = xmlEncoding; this.useCDATA = useCDATA; } @@ -177,10 +178,11 @@ public class SerializableMetadata extends Metadata implements Serializable { for (String key : this.getAllKeys()) { Element metadataElem = document.createElement("keyval"); Element keyElem = document.createElement("key"); - if (this.useCDATA) + if (this.useCDATA) { keyElem.appendChild(document.createCDATASection(key)); - else + } else { keyElem.appendChild(document.createTextNode(URLEncoder.encode(key, this.xmlEncoding))); + } metadataElem.appendChild(keyElem); @@ -192,12 +194,13 @@ public class SerializableMetadata extends Metadata implements Serializable { throw new Exception("Attempt to write null value " + "for property: [" + key + "]: val: [null]"); } - if (this.useCDATA) + if (this.useCDATA) { valElem.appendChild(document - .createCDATASection(value)); - else + .createCDATASection(value)); + } else { valElem.appendChild(document.createTextNode(URLEncoder - .encode(value, this.xmlEncoding))); + .encode(value, this.xmlEncoding))); + } metadataElem.appendChild(valElem); } root.appendChild(metadataElem); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternConfigReader.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternConfigReader.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternConfigReader.java index 8bc749c..128e376 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternConfigReader.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternConfigReader.java @@ -63,8 +63,9 @@ public final class ExternConfigReader implements MetExtractorConfigReader, .getAttribute(WORKING_DIR_ATTR))); String metFileExt = PathUtils.replaceEnvVariables(execElement .getAttribute(MET_FILE_EXT_ATTR)); - if (!metFileExt.equals("")) - config.setMetFileExt(metFileExt); + if (!metFileExt.equals("")) { + config.setMetFileExt(metFileExt); + } Element binPathElem = XMLUtils.getFirstElement( EXTRACTOR_BIN_PATH_TAG, execElement); String binPath = XMLUtils.getSimpleElementText(binPathElem); @@ -91,19 +92,21 @@ public final class ExternConfigReader implements MetExtractorConfigReader, String argStr; if (Boolean.valueOf( argElem.getAttribute(IS_DATA_FILE_ATTR) - .toLowerCase())) - argStr = DATA_FILE_PLACE_HOLDER; - else if (Boolean.valueOf( + .toLowerCase())) { + argStr = DATA_FILE_PLACE_HOLDER; + } else if (Boolean.valueOf( argElem.getAttribute(IS_MET_FILE_ATTR) - .toLowerCase())) - argStr = MET_FILE_PLACE_HOLDER; - else - argStr = XMLUtils.getSimpleElementText(argElem); + .toLowerCase())) { + argStr = MET_FILE_PLACE_HOLDER; + } else { + argStr = XMLUtils.getSimpleElementText(argElem); + } String appendExt; if (!(appendExt = argElem.getAttribute(APPEND_EXT_ATTR)) - .equals("")) - argStr += "." + appendExt; + .equals("")) { + argStr += "." + appendExt; + } if (Boolean.valueOf( argElem.getAttribute(ENV_REPLACE_ATTR))) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternMetExtractor.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternMetExtractor.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternMetExtractor.java index 238d1e9..084b243 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternMetExtractor.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/ExternMetExtractor.java @@ -66,8 +66,9 @@ public class ExternMetExtractor extends CmdLineMetExtractor implements // determine working directory String workingDirPath = ((ExternalMetExtractorConfig) this.config) .getWorkingDirPath(); - if (workingDirPath == null || workingDirPath.equals("")) - workingDirPath = file.getParentFile().getAbsolutePath(); + if (workingDirPath == null || workingDirPath.equals("")) { + workingDirPath = file.getParentFile().getAbsolutePath(); + } File workingDir = new File(workingDirPath); // determine met file path @@ -81,16 +82,18 @@ public class ExternMetExtractor extends CmdLineMetExtractor implements commandLineList.add(((ExternalMetExtractorConfig) this.config) .getExtractorBinPath()); if (((ExternalMetExtractorConfig) this.config).getArgList() != null - && ((ExternalMetExtractorConfig) this.config).getArgList().length > 0) - commandLineList.addAll(Arrays - .asList(((ExternalMetExtractorConfig) this.config) - .getArgList())); + && ((ExternalMetExtractorConfig) this.config).getArgList().length > 0) { + commandLineList.addAll(Arrays + .asList(((ExternalMetExtractorConfig) this.config) + .getArgList())); + } String[] commandLineArgs = new String[commandLineList.size()]; - for (int i = 0; i < commandLineList.size(); i++) - commandLineArgs[i] = StringUtils.replace(StringUtils.replace( - (String) commandLineList.get(i), MET_FILE_PLACE_HOLDER, - metFilePath), DATA_FILE_PLACE_HOLDER, file - .getAbsolutePath()); + for (int i = 0; i < commandLineList.size(); i++) { + commandLineArgs[i] = StringUtils.replace(StringUtils.replace( + (String) commandLineList.get(i), MET_FILE_PLACE_HOLDER, + metFilePath), DATA_FILE_PLACE_HOLDER, file + .getAbsolutePath()); + } // generate metadata file LOG.log(Level.INFO, "Generating met file for product file: [" http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/FilenameTokenConfig.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/FilenameTokenConfig.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/FilenameTokenConfig.java index 815023d..01c7cc1 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/FilenameTokenConfig.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/FilenameTokenConfig.java @@ -85,8 +85,9 @@ public class FilenameTokenConfig implements MetExtractorConfig { PGEGroup substrOffsetGroup = this.conf.getPgeSpecificGroups().get( SUBSTRING_OFFSET_GROUP); Metadata met = new Metadata(); - if (substrOffsetGroup == null) + if (substrOffsetGroup == null) { return met; + } String filename = file.getName(); for (PGEVector vec : substrOffsetGroup.getVectors().values()) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/MetReaderExtractor.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/MetReaderExtractor.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/MetReaderExtractor.java index fd6ce2f..a9a9875 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/MetReaderExtractor.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/extractors/MetReaderExtractor.java @@ -78,11 +78,12 @@ public class MetReaderExtractor extends CmdLineMetExtractor { // .met file // for the given product file String extension = this.metFileExt; - if (this.config != null) - extension = ((MetReaderConfig) this.config) - .getProperty( - "org.apache.oodt.cas.metadata.extractors.MetReader.metFileExt", - this.metFileExt); + if (this.config != null) { + extension = ((MetReaderConfig) this.config) + .getProperty( + "org.apache.oodt.cas.metadata.extractors.MetReader.metFileExt", + this.metFileExt); + } String metFileFullPath = file.getAbsolutePath() + "." + extension; LOG.log(Level.INFO, "Reading metadata from " + metFileFullPath); // now read the met file and return it http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java index f57af04..9a05ce3 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java @@ -52,10 +52,11 @@ public class MimeTypeComparator extends PreConditionComparator<String> { throws PreconditionComparatorException { try { String tikaMimeType = this.mimeTypeUtils.getMimeType(product); - if (tikaMimeType == null && useMagic) + if (tikaMimeType == null && useMagic) { tikaMimeType = this.mimeTypeUtils - .getMimeTypeByMagic(MimeTypeUtils - .readMagicHeader(new FileInputStream(product))); + .getMimeTypeByMagic(MimeTypeUtils + .readMagicHeader(new FileInputStream(product))); + } return tikaMimeType.compareTo(mimeType); } catch (Throwable e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/PreConditionComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/PreConditionComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/PreConditionComparator.java index 66dfd66..04995fd 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/PreConditionComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/PreConditionComparator.java @@ -63,9 +63,10 @@ public abstract class PreConditionComparator<CompareType> implements SpringSetId public boolean passes(File product) { try { - if (fileExtension != null) + if (fileExtension != null) { product = new File(product.getAbsolutePath() + "." - + this.fileExtension); + + this.fileExtension); + } return eval(this.type, this.performCheck(product, this.compareItem)); } catch (Exception e) { return false; @@ -100,14 +101,15 @@ public abstract class PreConditionComparator<CompareType> implements SpringSetId private static boolean eval(String opKey, int preconditionResult) throws MetExtractionException { opKey = opKey.toUpperCase(); - if (preconditionResult == 0) + if (preconditionResult == 0) { return EQUAL_TO.equals(opKey); - else if (preconditionResult > 0) + } else if (preconditionResult > 0) { return NOT_EQUAL_TO.equals(opKey) || GREATER_THAN.equals(opKey); - else if (preconditionResult < 0) + } else if (preconditionResult < 0) { return NOT_EQUAL_TO.equals(opKey) || LESS_THAN.equals(opKey); - else + } else { throw new MetExtractionException("evalType is not a valid type"); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/RegExExcludeComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/RegExExcludeComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/RegExExcludeComparator.java index bb39ab1..69fba01 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/RegExExcludeComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/RegExExcludeComparator.java @@ -41,8 +41,9 @@ public class RegExExcludeComparator extends PreConditionComparator<String> { if (compareItem != null && !compareItem.trim().equals("") && Pattern.matches(compareItem.toLowerCase(), file - .getAbsolutePath().toLowerCase())) - return 0; + .getAbsolutePath().toLowerCase())) { + return 0; + } return 1; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java index 51bba2a..d078082 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java @@ -104,8 +104,9 @@ public final class MimeTypeUtils { * mime type. */ public static String cleanMimeType(String origType) { - if (origType == null) + if (origType == null) { return null; + } // take the origType and split it on ';' String[] tokenizedMimeType = origType.split(SEPARATOR); @@ -310,10 +311,11 @@ public final class MimeTypeUtils { public String getSuperTypeForMimeType(String mimeType) { try { MediaType mediaType = this.mimeTypes.getMediaTypeRegistry().getSupertype(this.mimeTypes.forName(mimeType).getType()); - if (mediaType != null) - return mediaType.getType() + "/" + mediaType.getSubtype(); - else - return null; + if (mediaType != null) { + return mediaType.getType() + "/" + mediaType.getSubtype(); + } else { + return null; + } }catch (Exception e) { LOG.log(Level.WARNING, "Failed to get super-type for mimetype " + mimeType + " : " + e.getMessage()); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 b10d906..f70e29f 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 @@ -71,9 +71,11 @@ public final class PathUtils { && metadata.getMetadata(data.getFieldName()) != null) { List valList = metadata.getAllMetadata(data.getFieldName()); var = (String) valList.get(0); - if (expand) - for (int j = 1; j < valList.size(); j++) + if (expand) { + for (int j = 1; j < valList.size(); j++) { var += DELIMITER + (String) valList.get(j); + } + } } else { var = EnvUtilities.getEnv(data.getFieldName()); } @@ -131,17 +133,19 @@ public final class PathUtils { dotIndex), metadata).replaceAll( "[\\+\\s]", "")); gc.add(GregorianCalendar.DAY_OF_YEAR, rollDays); - } else + } else { throw new CasMetadataException( - "Malformed dynamic date replacement specified (no dot separator) - '" - + dateString + "'"); + "Malformed dynamic date replacement specified (no dot separator) - '" + + dateString + "'"); + } } // determine type and make the appropriate replacement String[] splitDate = dateString.split("\\."); - if (splitDate.length < 2) + if (splitDate.length < 2) { throw new CasMetadataException("No date type specified - '" + dateString - + "'"); + + "'"); + } String dateType = splitDate[1].replaceAll("[\\[\\]\\s]", ""); String replacement; if (dateType.equals("DAY")) { @@ -203,18 +207,19 @@ public final class PathUtils { Date date = new SimpleDateFormat(dateFormat).parse(dateString); Calendar calendar = (Calendar) Calendar.getInstance().clone(); calendar.setTime(date); - if (addUnits.equals("hr") || addUnits.equals("hour")) - calendar.add(Calendar.HOUR_OF_DAY, addAmount); - else if (addUnits.equals("min") || addUnits.equals("minute")) - calendar.add(Calendar.MINUTE, addAmount); - else if (addUnits.equals("sec") || addUnits.equals("second")) - calendar.add(Calendar.SECOND, addAmount); - else if (addUnits.equals("day")) - calendar.add(Calendar.DAY_OF_YEAR, addAmount); - else if (addUnits.equals("mo") || addUnits.equals("month")) - calendar.add(Calendar.MONTH, addAmount); - else if (addUnits.equals("yr") || addUnits.equals("year")) - calendar.add(Calendar.YEAR, addAmount); + if (addUnits.equals("hr") || addUnits.equals("hour")) { + calendar.add(Calendar.HOUR_OF_DAY, addAmount); + } else if (addUnits.equals("min") || addUnits.equals("minute")) { + calendar.add(Calendar.MINUTE, addAmount); + } else if (addUnits.equals("sec") || addUnits.equals("second")) { + calendar.add(Calendar.SECOND, addAmount); + } else if (addUnits.equals("day")) { + calendar.add(Calendar.DAY_OF_YEAR, addAmount); + } else if (addUnits.equals("mo") || addUnits.equals("month")) { + calendar.add(Calendar.MONTH, addAmount); + } else if (addUnits.equals("yr") || addUnits.equals("year")) { + calendar.add(Calendar.YEAR, addAmount); + } String newDateString = new SimpleDateFormat(dateFormat).format(calendar.getTime()); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java index ff22071..e0ac86d 100644 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java +++ b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java @@ -81,12 +81,13 @@ public class DatasetExtractor { public List<String> getDapUrls() { List<String> urls = null; - if (this.q.contains(FINDALL)) + if (this.q.contains(FINDALL)) { urls = this.allUrls; - else if (this.q.contains(FINDSOME)) + } else if (this.q.contains(FINDSOME)) { urls = this.getFindSome(); - else if (this.q.contains(FINDQUERY)) + } else if (this.q.contains(FINDQUERY)) { urls = this.getFindQuery(); + } return urls; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java b/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java index ef1da78..0292660 100644 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java +++ b/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java @@ -67,9 +67,15 @@ public class OpendapProfileElementExtractor { attTable = das.getAttributeTable(varname); // make variable names case insensitive - if(attTable == null) attTable = das.getAttributeTable(varname.toLowerCase()); - if(attTable == null) attTable = das.getAttributeTable(varname.toUpperCase()); - if(attTable == null) throw new NoSuchAttributeException("Att table for ["+varname+"] is null!"); + if(attTable == null) { + attTable = das.getAttributeTable(varname.toLowerCase()); + } + if(attTable == null) { + attTable = das.getAttributeTable(varname.toUpperCase()); + } + if(attTable == null) { + throw new NoSuchAttributeException("Att table for [" + varname + "] is null!"); + } } catch (NoSuchAttributeException e) { e.printStackTrace(); LOG.log(Level.WARNING, "Error extracting attribute table for element: [" http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileChecker.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileChecker.java b/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileChecker.java index 8451807..1996381 100644 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileChecker.java +++ b/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileChecker.java @@ -102,7 +102,9 @@ public class ProfileChecker { private static boolean checkResourceAttribute(String name, String value, boolean mandatory, StringBuilder sb) { sb.append("\n\tResource Attribute '").append(name).append("' = "); if (!StringUtils.hasText(value) || value.equalsIgnoreCase("null")) { - if (mandatory) return false; // bad value + if (mandatory) { + return false; // bad value + } } else { sb.append(value); } @@ -133,19 +135,27 @@ public class ProfileChecker { boolean first = true; for (String value : values) { if (!StringUtils.hasText(value) || value.equalsIgnoreCase("null")) { - if (mandatory) ok = false; // invalid value for this profile element + if (mandatory) { + ok = false; // invalid value for this profile element + } } else { - if (!first) sb.append(", "); + if (!first) { + sb.append(", "); + } sb.append(value); first = false; } } } else { - if (mandatory) ok = false; // no values found for this profile element + if (mandatory) { + ok = false; // no values found for this profile element + } } } else { - if (mandatory) ok = false; // no profile element found + if (mandatory) { + ok = false; // no profile element found + } } return ok; @@ -163,7 +173,9 @@ public class ProfileChecker { for (String resLocation : resLocations) { String[] parts = resLocation.split("\\|"); // regular expression of ProfileUtils.CHAR - if (parts[1].equals(mimeType)) return parts[0]; + if (parts[1].equals(mimeType)) { + return parts[0]; + } } // resource location not found http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java b/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java index d795dbc..c17b274 100644 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java +++ b/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java @@ -277,7 +277,9 @@ public class ProfileUtils { } } // only save profile elements with one or more values - if (epe.getValues().size()>0) profElements.put(name, epe); + if (epe.getValues().size()>0) { + profElements.put(name, epe); + } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/core/src/main/java/org/apache/oodt/pcs/listing/ListingConf.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/listing/ListingConf.java b/pcs/core/src/main/java/org/apache/oodt/pcs/listing/ListingConf.java index 4d86e04..31e21f8 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/listing/ListingConf.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/listing/ListingConf.java @@ -61,8 +61,9 @@ public class ListingConf { } catch (PGEConfigFileException e) { throw new InstantiationException(e.getMessage()); } finally { - if (this.conf == null) + if (this.conf == null) { throw new InstantiationException("Configuration is null!"); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTree.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTree.java b/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTree.java index f57b7da..bb10f27 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTree.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTree.java @@ -39,8 +39,9 @@ public class PedigreeTree { public int getNumLevels() { if (root != null) { return traverse(root, 0) + 1; - } else + } else { return 0; + } } public PedigreeTreeNode getRoot() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTreeNode.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTreeNode.java b/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTreeNode.java index 481671d..f3dd71d 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTreeNode.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/pedigree/PedigreeTreeNode.java @@ -65,8 +65,9 @@ public class PedigreeTreeNode { } public int getNumChildren() { - if (this.children == null) + if (this.children == null) { return 0; + } return this.children.size(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/core/src/main/java/org/apache/oodt/pcs/query/AbstractPCSQuery.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/query/AbstractPCSQuery.java b/pcs/core/src/main/java/org/apache/oodt/pcs/query/AbstractPCSQuery.java index 1bf259b..40c24b8 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/query/AbstractPCSQuery.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/query/AbstractPCSQuery.java @@ -52,8 +52,9 @@ public abstract class AbstractPCSQuery implements PCSQuery { */ protected String getElemId(String elemName) { Element elem = fm.safeGetElementByName(elemName); - if (elem == null) + if (elem == null) { return null; + } return elem.getElementId(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 bfea4b4..14c8eb7 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 @@ -294,8 +294,9 @@ public final class PCSHealthMonitor implements CoreMetKeys, private List getProductHealth() { if (getFmUp()) { return this.fm.safeGetTopNProducts(TOP_N_PRODUCTS); - } else + } else { return new Vector(); + } } private List getJobStatusHealth() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java b/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java index 67db072..efbe3c1 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java @@ -73,8 +73,9 @@ public class WorkflowManagerUtils { } public List<WorkflowInstance> safeGetWorkflowInstances() { - if (!isConnected()) + if (!isConnected()) { return Collections.EMPTY_LIST; + } try { return this.client.getWorkflowInstances(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEGroup.java ---------------------------------------------------------------------- diff --git a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEGroup.java b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEGroup.java index b4cb93e..9012fb2 100644 --- a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEGroup.java +++ b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEGroup.java @@ -155,57 +155,65 @@ public class PGEGroup { public PGEScalar getScalar(String name) { if (this.scalars != null) { return this.scalars.get(name); - } else + } else { return null; + } } public PGEVector getVector(String name) { if (this.vectors != null) { return this.vectors.get(name); - } else + } else { return null; + } } public PGEMatrix getMatrix(String name) { if (this.matrixs != null) { return this.matrixs.get(name); - } else + } else { return null; + } } public PGEGroup getGroup(String name) { if (this.groups != null) { return this.groups.get(name); - } else + } else { return null; + } } public int getNumScalars() { if (this.scalars != null) { return this.scalars.size(); - } else + } else { return 0; + } } public int getNumVectors() { if (this.vectors != null) { return this.vectors.size(); - } else + } else { return 0; + } } public int getNumMatrixs() { if (this.matrixs != null) { return this.matrixs.size(); - } else + } else { return 0; + } } public int getNumGroups() { if (this.groups != null) { return this.groups.size(); - } else + } else { return 0; + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java ---------------------------------------------------------------------- diff --git a/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java b/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java index cb43eef..3478dc2 100644 --- a/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java +++ b/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java @@ -221,8 +221,9 @@ public class HealthResource extends PCSService { .getProductTypeId())); p.setProductReferences(fm.safeGetProductReferences(p)); Metadata prodMet = fm.safeGetMetadata(p); - if (prodMet == null) + if (prodMet == null) { prodMet = new Metadata(); + } Map<String, Object> fileOutput = new HashMap<String, Object>(); fileOutput.put("filepath", fm.getFilePath(p)); fileOutput.put("receivedTime", prodMet.getMetadata("CAS." @@ -253,9 +254,10 @@ public class HealthResource extends PCSService { break; } } - if (!found) + if (!found) { throw new ResourceNotFoundException( "No ingest crawler found with name: [" + crawlerName[0] + "]"); + } } else { for (CrawlerHealth ch : (List<CrawlerHealth>) (List<?>) report .getCrawlerHealthStatus()) { @@ -278,10 +280,11 @@ public class HealthResource extends PCSService { break; } } - if (!found) + if (!found) { throw new ResourceNotFoundException( "Unable to find any jobs with associated state: [" + jobState[0] - + "]"); + + "]"); + } } else { for (JobHealthStatus js : (List<JobHealthStatus>) (List<?>) report .getJobHealthStatus()) { @@ -322,9 +325,10 @@ public class HealthResource extends PCSService { break; } } - if (!found) + if (!found) { throw new ResourceNotFoundException( "Unable to find any crawlers with name: [" + crawlerName[0] + "]"); + } } else { for (CrawlerStatus cs : (List<CrawlerStatus>) (List<?>) report .getCrawlerStatus()) { @@ -355,11 +359,13 @@ public class HealthResource extends PCSService { stubs.add(this.encodeDaemonStatus(bStatus)); } daemonOutput.put("stubs", stubs); - } else + } else { throw new ResourceNotFoundException( "Resource Manager not running so no batch stubs to check."); - } else + } + } else { throw new ResourceNotFoundException("Daemon not found"); + } } else { daemonOutput.put("fm", this.encodeDaemonStatus(report.getFmStatus())); daemonOutput.put("wm", this.encodeDaemonStatus(report.getWmStatus())); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pcs/services/src/main/java/org/apache/oodt/pcs/services/PedigreeResource.java ---------------------------------------------------------------------- diff --git a/pcs/services/src/main/java/org/apache/oodt/pcs/services/PedigreeResource.java b/pcs/services/src/main/java/org/apache/oodt/pcs/services/PedigreeResource.java index b8b3eb0..3f5e979 100644 --- a/pcs/services/src/main/java/org/apache/oodt/pcs/services/PedigreeResource.java +++ b/pcs/services/src/main/java/org/apache/oodt/pcs/services/PedigreeResource.java @@ -97,10 +97,12 @@ public class PedigreeResource extends PCSService { private String encodePedigreeAsJson(PedigreeTree up, PedigreeTree down) { Map<String, Object> output = new HashMap<String, Object>(); - if (up != null) + if (up != null) { output.put("upstream", this.encodePedigreeTreeAsJson(up.getRoot())); - if (down != null) + } + if (down != null) { output.put("downstream", this.encodePedigreeTreeAsJson(down.getRoot())); + } JSONObject json = new JSONObject(); json.put("pedigree", output); return json.toString(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pge/src/main/java/org/apache/oodt/cas/pge/PGETaskInstance.java ---------------------------------------------------------------------- diff --git a/pge/src/main/java/org/apache/oodt/cas/pge/PGETaskInstance.java b/pge/src/main/java/org/apache/oodt/cas/pge/PGETaskInstance.java index bef0be2..1cca03e 100644 --- a/pge/src/main/java/org/apache/oodt/cas/pge/PGETaskInstance.java +++ b/pge/src/main/java/org/apache/oodt/cas/pge/PGETaskInstance.java @@ -459,9 +459,10 @@ public class PGETaskInstance implements WorkflowTaskInstance { } } } - if (outputMetadata.getAllKeys().size() > 0) - this.writeFromMetadata(outputMetadata, createdFile.getAbsolutePath() - + "." + this.pgeMetadata.getMetadata(MET_FILE_EXT)); + if (outputMetadata.getAllKeys().size() > 0) { + this.writeFromMetadata(outputMetadata, createdFile.getAbsolutePath() + + "." + this.pgeMetadata.getMetadata(MET_FILE_EXT)); + } } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pge/src/main/java/org/apache/oodt/cas/pge/metadata/PgeMetadata.java ---------------------------------------------------------------------- diff --git a/pge/src/main/java/org/apache/oodt/cas/pge/metadata/PgeMetadata.java b/pge/src/main/java/org/apache/oodt/cas/pge/metadata/PgeMetadata.java index 34e0c24..017911b 100644 --- a/pge/src/main/java/org/apache/oodt/cas/pge/metadata/PgeMetadata.java +++ b/pge/src/main/java/org/apache/oodt/cas/pge/metadata/PgeMetadata.java @@ -298,8 +298,9 @@ public class PgeMetadata { Validate.notNull(key, "key cannot be null"); List<String> keyPath = Lists.newArrayList(); - while (keyLinkMap.containsKey(key)) + while (keyLinkMap.containsKey(key)) { keyPath.add(key = keyLinkMap.get(key)); + } return keyPath; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pge/src/main/java/org/apache/oodt/cas/pge/util/XmlHelper.java ---------------------------------------------------------------------- diff --git a/pge/src/main/java/org/apache/oodt/cas/pge/util/XmlHelper.java b/pge/src/main/java/org/apache/oodt/cas/pge/util/XmlHelper.java index 0bdc74c..4e0dc4c 100644 --- a/pge/src/main/java/org/apache/oodt/cas/pge/util/XmlHelper.java +++ b/pge/src/main/java/org/apache/oodt/cas/pge/util/XmlHelper.java @@ -443,17 +443,19 @@ public class XmlHelper { try { while ((value = PathUtils .doDynamicReplacement(value, inputMetadata)).contains("[") - && envReplaceRecur) - ; + && envReplaceRecur) { + ; + } if (value.toUpperCase().matches( - "^\\s*SQL\\s*\\(.*\\)\\s*\\{.*\\}\\s*$")) - value = QueryUtils - .getQueryResultsAsString(new XmlRpcFileManagerClient( - new URL(inputMetadata - .getMetadata(QUERY_FILE_MANAGER_URL - .getName()))) - .complexQuery(SqlParser - .parseSqlQueryMethod(value))); + "^\\s*SQL\\s*\\(.*\\)\\s*\\{.*\\}\\s*$")) { + value = QueryUtils + .getQueryResultsAsString(new XmlRpcFileManagerClient( + new URL(inputMetadata + .getMetadata(QUERY_FILE_MANAGER_URL + .getName()))) + .complexQuery(SqlParser + .parseSqlQueryMethod(value))); + } return value; } catch (Exception e) { throw new PGEException("Failed to parse value: " + value, e); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pge/src/main/java/org/apache/oodt/cas/pge/writers/MetadataKeyReplacerTemplateWriter.java ---------------------------------------------------------------------- diff --git a/pge/src/main/java/org/apache/oodt/cas/pge/writers/MetadataKeyReplacerTemplateWriter.java b/pge/src/main/java/org/apache/oodt/cas/pge/writers/MetadataKeyReplacerTemplateWriter.java index cbdd74a..e7225c6 100644 --- a/pge/src/main/java/org/apache/oodt/cas/pge/writers/MetadataKeyReplacerTemplateWriter.java +++ b/pge/src/main/java/org/apache/oodt/cas/pge/writers/MetadataKeyReplacerTemplateWriter.java @@ -69,8 +69,9 @@ public class MetadataKeyReplacerTemplateWriter extends if (metadata.isMultiValued(key)) { List<String> values = metadata.getAllMetadata(key); replaceVal = StringUtils.join(values, separator); - } else + } else { replaceVal = metadata.getMetadata(key); + } processedTemplate = processedTemplate.replaceAll("\\$" + key, replaceVal); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pge/src/main/java/org/apache/oodt/cas/pge/writers/metlist/MetadataListPcsMetFileWriter.java ---------------------------------------------------------------------- diff --git a/pge/src/main/java/org/apache/oodt/cas/pge/writers/metlist/MetadataListPcsMetFileWriter.java b/pge/src/main/java/org/apache/oodt/cas/pge/writers/metlist/MetadataListPcsMetFileWriter.java index e664379..f5fa039 100644 --- a/pge/src/main/java/org/apache/oodt/cas/pge/writers/metlist/MetadataListPcsMetFileWriter.java +++ b/pge/src/main/java/org/apache/oodt/cas/pge/writers/metlist/MetadataListPcsMetFileWriter.java @@ -63,21 +63,25 @@ public class MetadataListPcsMetFileWriter extends PcsMetFileWriter { for (int i = 0; i < metadataNodeList.getLength(); i++) { Element metadataElement = (Element) metadataNodeList.item(i); String key = metadataElement.getAttribute(KEY_ATTR); - if (key.equals("")) - key = PathUtils.doDynamicReplacement(metadataElement.getAttribute(KEY_GEN_ATTR), inputMetadata); + if (key.equals("")) { + key = PathUtils.doDynamicReplacement(metadataElement.getAttribute(KEY_GEN_ATTR), inputMetadata); + } String val = metadataElement.getAttribute(VAL_ATTR); - if (val.equals("")) - val = metadataElement.getTextContent(); + if (val.equals("")) { + val = metadataElement.getTextContent(); + } if (val != null && !val.equals("")) { - if (!metadataElement.getAttribute(ENV_REPLACE_ATTR).toLowerCase().equals("false")) - val = PathUtils.doDynamicReplacement(val, inputMetadata); + if (!metadataElement.getAttribute(ENV_REPLACE_ATTR).toLowerCase().equals("false")) { + val = PathUtils.doDynamicReplacement(val, inputMetadata); + } String[] vals; if (metadataElement.getAttribute(SPLIT_ATTR).toLowerCase().equals("false")) { vals = new String[] { val }; } else { String delimiter = metadataElement.getAttribute("delimiter"); - if (delimiter == null || delimiter.equals("")) - delimiter = ","; + if (delimiter == null || delimiter.equals("")) { + delimiter = ","; + } vals = (val + delimiter).split(delimiter); } metadata.replaceMetadata(key, Arrays.asList(vals)); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java index 3159996..1c839d2 100644 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java +++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java @@ -80,9 +80,10 @@ public abstract class AbstractCrawlLister implements OFSNListHandler { protected File[] crawlFiles(File dirRoot, boolean recur, boolean crawlForDirs) { - if (dirRoot == null || ((!dirRoot.exists()))) + if (dirRoot == null || ((!dirRoot.exists()))) { throw new IllegalArgumentException("dir root: [" + dirRoot - + "] is null or non existant!"); + + "] is null or non existant!"); + } List<File> fileList = new Vector<File>(); @@ -104,10 +105,11 @@ public abstract class AbstractCrawlLister implements OFSNListHandler { if (recur) { File[] subdirs = dir.listFiles(DIR_FILTER); - if (subdirs != null) + if (subdirs != null) { for (File subdir : subdirs) { stack.push(subdir); } + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java index 3b5ffbe..89bfdb5 100644 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java +++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java @@ -57,15 +57,17 @@ public class OFSNFileHandlerConfiguration { public String getHandlerType(String handlerName) { if (this.handlerTable.containsKey(handlerName)) { return this.handlerTable.get(handlerName).getType(); - } else + } else { return null; + } } public String getHandlerClass(String handlerName) { if (this.handlerTable.containsKey(handlerName)) { return this.handlerTable.get(handlerName).getClassName(); - } else + } else { return null; + } } public List<OFSNHandlerConfig> getHandlerConfigs() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java index bd119d6..20944f3 100644 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java +++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java @@ -77,41 +77,41 @@ public class URLGetHandler extends AbstractCrawlLister implements OFSNGetHandler public void configure(Properties prop) { if (prop != null) { - if (prop.getProperty(PROD_SERVER_HOSTNAME) != null) - this.prodServerHostname = prop.getProperty(PROD_SERVER_HOSTNAME); - else { + if (prop.getProperty(PROD_SERVER_HOSTNAME) != null) { + this.prodServerHostname = prop.getProperty(PROD_SERVER_HOSTNAME); + } else { LOG.warning("Configuration property ["+PROD_SERVER_HOSTNAME+"] not specified, using default"); this.prodServerHostname = DEFAULT_PROD_SERVER_HOSTNAME; } LOG.info("Property ["+PROD_SERVER_HOSTNAME+"] set with value ["+this.prodServerHostname+"]"); - if (prop.getProperty(PROD_SERVER_PORT) != null) - this.prodServerPort = prop.getProperty(PROD_SERVER_PORT); - else { + if (prop.getProperty(PROD_SERVER_PORT) != null) { + this.prodServerPort = prop.getProperty(PROD_SERVER_PORT); + } else { LOG.warning("Configuration property ["+PROD_SERVER_PORT+"] not specified, using default"); this.prodServerPort = DEFAULT_PROD_SERVER_PORT; } LOG.info("Property ["+PROD_SERVER_PORT+"] set with value ["+this.prodServerPort+"]"); - if (prop.getProperty(PROD_SERVER_CONTEXT) != null) - this.prodServerContext = prop.getProperty(PROD_SERVER_CONTEXT); - else { + if (prop.getProperty(PROD_SERVER_CONTEXT) != null) { + this.prodServerContext = prop.getProperty(PROD_SERVER_CONTEXT); + } else { LOG.warning("Configuration property ["+PROD_SERVER_CONTEXT+"] not specified, using default"); this.prodServerContext = DEFAULT_PROD_SERVER_CONTEXT; } LOG.info("Property ["+PROD_SERVER_CONTEXT+"] set with value ["+this.prodServerContext+"]"); - if (prop.getProperty(PRODUCT_ROOT) != null) - this.productRoot = prop.getProperty(PRODUCT_ROOT); - else { + if (prop.getProperty(PRODUCT_ROOT) != null) { + this.productRoot = prop.getProperty(PRODUCT_ROOT); + } else { LOG.warning("Configuration property ["+PRODUCT_ROOT+"] not specified, using default"); this.productRoot = DEFAULT_PRODUCT_ROOT; } LOG.info("Property ["+PRODUCT_ROOT+"] set with value ["+this.productRoot+"]"); - if (prop.getProperty(RETURN_TYPE) != null) - this.returnType = prop.getProperty(RETURN_TYPE); - else { + if (prop.getProperty(RETURN_TYPE) != null) { + this.returnType = prop.getProperty(RETURN_TYPE); + } else { LOG.warning("Configuration property ["+RETURN_TYPE+"] not specified, using default"); this.returnType = DEFAULT_RETURN_TYPE; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java b/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java index 36c03b8..fba28c8 100644 --- a/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java +++ b/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java @@ -61,9 +61,13 @@ final class ChunkedProductInputStream extends InputStream { */ public int read() throws IOException { checkOpen(); // Make sure the stream's open - if (eof) throw new IOException("End of file"); // Already reached EOF? You lose. + if (eof) { + throw new IOException("End of file"); // Already reached EOF? You lose. + } fetchBlock(); // Get a block. - if (eof) return -1; // No more blocks? Signal EOF. + if (eof) { + return -1; // No more blocks? Signal EOF. + } return block[blockIndex++]; // Yield next byte (promoted) from block. } @@ -81,14 +85,20 @@ final class ChunkedProductInputStream extends InputStream { */ public int read(byte[] b, int offset, int length) throws IOException { checkOpen(); // Check if open - if (offset < 0 || offset > b.length || length < 0 || (offset + length) > b.length || (offset + length) < 0) - throw new IllegalArgumentException("Illegal offset=" + offset + "/length=" + length - + " for byte array of length " + b.length); - else if (length == 0) // Want zero? - return 0; // Then you get zero - if (eof) throw new IOException("End of file"); // Already reached EOF? You lose. + if (offset < 0 || offset > b.length || length < 0 || (offset + length) > b.length || (offset + length) < 0) { + throw new IllegalArgumentException("Illegal offset=" + offset + "/length=" + length + + " for byte array of length " + b.length); + } else if (length == 0) // Want zero? + { + return 0; // Then you get zero + } + if (eof) { + throw new IOException("End of file"); // Already reached EOF? You lose. + } fetchBlock(); // Get a block. - if (eof) return -1; // No more blocks? Signal EOF. + if (eof) { + return -1; // No more blocks? Signal EOF. + } int amount = Math.min(length, block.length - blockIndex); // Return requested amount or whatever's left System.arraycopy(block, blockIndex, b, offset, amount); // Transfer blockIndex += amount; // Advance @@ -101,18 +111,20 @@ final class ChunkedProductInputStream extends InputStream { * @throws IOException if an error occurs. */ private void fetchBlock() throws IOException { - if (block == null || blockIndex == block.length) try { // No block, or current block exhausted? - if (productIndex == size) { // No more blocks left to get? - block = null; // Drop current block - eof = true; // Signal EOF - } else { // Otherwise there are more blocks - int x=(int)Math.min(BLOCK_SIZE, size - productIndex); // Can only fetch so much - block = retriever.retrieveChunk(id, productIndex, x); // Get x's worth of data - blockIndex = 0; // Start at block's beginning - productIndex += block.length; // Advance product index by block size + if (block == null || blockIndex == block.length) { + try { // No block, or current block exhausted? + if (productIndex == size) { // No more blocks left to get? + block = null; // Drop current block + eof = true; // Signal EOF + } else { // Otherwise there are more blocks + int x = (int) Math.min(BLOCK_SIZE, size - productIndex); // Can only fetch so much + block = retriever.retrieveChunk(id, productIndex, x); // Get x's worth of data + blockIndex = 0; // Start at block's beginning + productIndex += block.length; // Advance product index by block size } - } catch (ProductException ex) { + } catch (ProductException ex) { throw new IOException(ex.getMessage()); + } } } @@ -171,7 +183,9 @@ final class ChunkedProductInputStream extends InputStream { * @throws IOException if the stream's closed. */ private void checkOpen() throws IOException { - if (open) return; + if (open) { + return; + } throw new IOException("Stream closed"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/product/src/main/java/org/apache/oodt/xmlquery/LargeResult.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/xmlquery/LargeResult.java b/product/src/main/java/org/apache/oodt/xmlquery/LargeResult.java index e05414e..316650d 100644 --- a/product/src/main/java/org/apache/oodt/xmlquery/LargeResult.java +++ b/product/src/main/java/org/apache/oodt/xmlquery/LargeResult.java @@ -92,9 +92,10 @@ public class LargeResult extends Result { Object value = null; InputStream in = null; try { - if (size > Integer.MAX_VALUE) - throw new IllegalStateException("Cannot use getValue() for this product, result is too large; " - + "use LargeResult.getInputStream instead"); + if (size > Integer.MAX_VALUE) { + throw new IllegalStateException("Cannot use getValue() for this product, result is too large; " + + "use LargeResult.getInputStream instead"); + } int sizeToRead = (int) size; byte[] buf = new byte[sizeToRead]; int index = 0; @@ -103,7 +104,9 @@ public class LargeResult extends Result { while ((num = in.read(buf, index, sizeToRead)) != -1) { index += num; sizeToRead -= num; - if (sizeToRead == 0) break; + if (sizeToRead == 0) { + break; + } } // OK, this sucks. Sucks sucks sucks. Look, getValue is not to @@ -117,9 +120,12 @@ public class LargeResult extends Result { } catch (IOException ex) { throw new IllegalStateException("Unexpected IOException: " + ex.getMessage()); } finally { - if (in != null) try { + if (in != null) { + try { in.close(); - } catch (IOException ignore) {} + } catch (IOException ignore) { + } + } } return value; } @@ -148,10 +154,11 @@ public class LargeResult extends Result { * @return The MIME type. */ private static String transformMimeType(Result result) { - if ("application/vnd.jpl.large-product".equals(result.mimeType)) - return (String) result.value; - else - return result.mimeType + " 0"; + if ("application/vnd.jpl.large-product".equals(result.mimeType)) { + return (String) result.value; + } else { + return result.mimeType + " 0"; + } } /** Serial version unique ID. */ http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java index c80f628..42304a6 100644 --- a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java @@ -64,8 +64,9 @@ public class EnumeratedProfileElement extends ProfileElement { public EnumeratedProfileElement(Profile profile, String name, String id, String desc, String type, String unit, List<?> synonyms, boolean obligation, int maxOccurrence, String comment, List<?> values) { super(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, comment); - if (values.contains(null)) - throw new IllegalArgumentException("Null item in 'values' not allowed for enumerated profile elements"); + if (values.contains(null)) { + throw new IllegalArgumentException("Null item in 'values' not allowed for enumerated profile elements"); + } this.values = values; } @@ -74,7 +75,9 @@ public class EnumeratedProfileElement extends ProfileElement { } protected void addValues(Node node) throws DOMException { - if (values == null) return; + if (values == null) { + return; + } for (Object value : values) { Element e = node.getOwnerDocument().createElement("elemValue"); e.appendChild(node.getOwnerDocument().createCDATASection((String) value)); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/Profile.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Profile.java b/profile/src/main/java/org/apache/oodt/profile/Profile.java index 255c649..cc0dc16 100644 --- a/profile/src/main/java/org/apache/oodt/profile/Profile.java +++ b/profile/src/main/java/org/apache/oodt/profile/Profile.java @@ -71,17 +71,21 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc List<Profile> profiles = new ArrayList<Profile>(); if ("profile".equals(root.getNodeName())) // The root is a <profile>, so add the single profile to the list. - profiles.add(factory.createProfile((Element) root)); - else if ("profiles".equals(root.getNodeName())) { + { + profiles.add(factory.createProfile((Element) root)); + } else if ("profiles".equals(root.getNodeName())) { // The root is a <profiles>, so add each <profile> to the list. NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); - if ("profile".equals(node.getNodeName())) - profiles.add(factory.createProfile((Element) node)); + if ("profile".equals(node.getNodeName())) { + profiles.add(factory.createProfile((Element) node)); + } } - } else throw new IllegalArgumentException("Expected a <profiles> or <profile> top level element but got " - + root.getNodeName()); + } else { + throw new IllegalArgumentException("Expected a <profiles> or <profile> top level element but got " + + root.getNodeName()); + } return profiles; } @@ -144,17 +148,18 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc * @param root The <profile> element. */ public Profile(Node root, ObjectFactory factory) { - if (!root.getNodeName().equals("profile")) - throw new IllegalArgumentException("Construct a Profile from a <profile> element, not a <" - + root.getNodeName() + ">"); + if (!root.getNodeName().equals("profile")) { + throw new IllegalArgumentException("Construct a Profile from a <profile> element, not a <" + + root.getNodeName() + ">"); + } NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); - if ("profAttributes".equals(node.getNodeName())) - profAttr = factory.createProfileAttributes((Element) node); - else if ("resAttributes".equals(node.getNodeName())) - resAttr = factory.createResourceAttributes(this, (Element) node); - else if ("profElement".equals(node.getNodeName())) { + if ("profAttributes".equals(node.getNodeName())) { + profAttr = factory.createProfileAttributes((Element) node); + } else if ("resAttributes".equals(node.getNodeName())) { + resAttr = factory.createResourceAttributes(this, (Element) node); + } else if ("profElement".equals(node.getNodeName())) { ProfileElement element = ProfileElement.createProfileElement((Element) node, this, factory); elements.put(element.getName(), element); } @@ -170,7 +175,9 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc public Profile(ProfileAttributes profAttr, ResourceAttributes resAttr) { this.profAttr = profAttr; this.resAttr = resAttr; - if (this.resAttr != null) this.resAttr.profile = this; + if (this.resAttr != null) { + this.resAttr.profile = this; + } } public int hashCode() { @@ -178,8 +185,12 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc } public boolean equals(Object rhs) { - if (rhs == this) return true; - if (rhs == null || !(rhs instanceof Profile)) return false; + if (rhs == this) { + return true; + } + if (rhs == null || !(rhs instanceof Profile)) { + return false; + } Profile obj = (Profile) rhs; return profAttr.equals(obj.profAttr); } @@ -307,10 +318,11 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc Element profile = doc.createElement("profile"); profile.appendChild(profAttr.toXML(doc)); profile.appendChild(resAttr.toXML(doc)); - if (withElements) + if (withElements) { for (ProfileElement profileElement : elements.values()) { profile.appendChild((profileElement).toXML(doc)); } + } return profile; } @@ -373,8 +385,9 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc BufferedReader reader = new BufferedReader(new FileReader(argv[0])); char[] buf = new char[512]; int num; - while ((num = reader.read(buf)) != -1) - b.append(buf, 0, num); + while ((num = reader.read(buf)) != -1) { + b.append(buf, 0, num); + } reader.close(); Profile p = new Profile(b.toString()); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java b/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java index fca45dd..c79e5f6 100644 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java +++ b/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java @@ -56,24 +56,25 @@ public class ProfileAttributes implements Serializable, Cloneable, Comparable, D NodeList childNodes = root.getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node node = childNodes.item(i); - if ("profId".equals(node.getNodeName())) - id = XML.unwrappedText(node); - else if ("profVersion".equals(node.getNodeName())) - version = XML.unwrappedText(node); - else if ("profType".equals(node.getNodeName())) - type = XML.unwrappedText(node); - else if ("profStatusId".equals(node.getNodeName())) - statusID = XML.unwrappedText(node); - else if ("profSecurityType".equals(node.getNodeName())) - securityType = XML.unwrappedText(node); - else if ("profParentId".equals(node.getNodeName())) - parent = XML.unwrappedText(node); - else if ("profChildId".equals(node.getNodeName())) - children.add(XML.unwrappedText(node)); - else if ("profRegAuthority".equals(node.getNodeName())) - regAuthority = XML.unwrappedText(node); - else if ("profRevisionNote".equals(node.getNodeName())) - revisionNotes.add(XML.unwrappedText(node)); + if ("profId".equals(node.getNodeName())) { + id = XML.unwrappedText(node); + } else if ("profVersion".equals(node.getNodeName())) { + version = XML.unwrappedText(node); + } else if ("profType".equals(node.getNodeName())) { + type = XML.unwrappedText(node); + } else if ("profStatusId".equals(node.getNodeName())) { + statusID = XML.unwrappedText(node); + } else if ("profSecurityType".equals(node.getNodeName())) { + securityType = XML.unwrappedText(node); + } else if ("profParentId".equals(node.getNodeName())) { + parent = XML.unwrappedText(node); + } else if ("profChildId".equals(node.getNodeName())) { + children.add(XML.unwrappedText(node)); + } else if ("profRegAuthority".equals(node.getNodeName())) { + regAuthority = XML.unwrappedText(node); + } else if ("profRevisionNote".equals(node.getNodeName())) { + revisionNotes.add(XML.unwrappedText(node)); + } } } @@ -108,8 +109,12 @@ public class ProfileAttributes implements Serializable, Cloneable, Comparable, D } public boolean equals(Object rhs) { - if (rhs == this) return true; - if (rhs == null || !(rhs instanceof ProfileAttributes)) return false; + if (rhs == this) { + return true; + } + if (rhs == null || !(rhs instanceof ProfileAttributes)) { + return false; + } return ((ProfileAttributes) rhs).id.equals(id); }
