http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrClient.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrClient.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrClient.java index bd5551f..38094c6 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrClient.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrClient.java @@ -87,7 +87,9 @@ public class SolrClient { LOG.info(response); // commit changes ? - if (commit) this.commit(); + if (commit) { + this.commit(); + } LOG.info(response); return response; @@ -112,7 +114,9 @@ public class SolrClient { // build POST request String url = this.buildUpdateUrl(); - if (commit) url += "?commit=true"; + if (commit) { + url += "?commit=true"; + } String message = "<delete><query>id:"+id+"</query></delete>"; // send POST request @@ -240,7 +244,9 @@ public class SolrClient { } } // request results in JSON format - if (mimeType.equals(Parameters.MIME_TYPE_JSON)) nvps.add(new NameValuePair("wt", "json")); + if (mimeType.equals(Parameters.MIME_TYPE_JSON)) { + nvps.add(new NameValuePair("wt", "json")); + } method.setQueryString( nvps.toArray( new NameValuePair[nvps.size()] ) ); LOG.info("GET url: "+url+" query string: "+method.getQueryString()); @@ -307,7 +313,12 @@ public class SolrClient { } finally { // must release the connection even if an exception occurred method.releaseConnection(); - if (br!=null) try { br.close(); } catch (Exception ignored) {} + if (br!=null) { + try { + br.close(); + } catch (Exception ignored) { + } + } } return response.toString();
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/IngestProductCliAction.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/IngestProductCliAction.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/IngestProductCliAction.java index 6f6bf9f..53cbedb 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/IngestProductCliAction.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/IngestProductCliAction.java @@ -93,8 +93,9 @@ public class IngestProductCliAction extends FileManagerCliAction { List<String> uriRefs = Lists.newArrayList(); for (String ref : references) { URI uri = URI.create(ref); - if (!uri.getScheme().equals("stream")) - throw new IllegalArgumentException("Streaming data must use 'stream' scheme not "+uri.getScheme()); + if (!uri.getScheme().equals("stream")) { + throw new IllegalArgumentException("Streaming data must use 'stream' scheme not " + uri.getScheme()); + } uriRefs.add(uri.toString()); } references = uriRefs; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java index 66c8172..e873b8d 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java @@ -175,11 +175,13 @@ public class RemoteDataTransferer implements DataTransfer { while (true) { fileData = (byte[]) client.retrieveFile( dataStoreFile.getAbsolutePath(), offset, 1024); - if (fileData.length <= 0) - break; + if (fileData.length <= 0) { + break; + } fOut.write(fileData); - if (fileData.length < 1024) - break; + if (fileData.length < 1024) { + break; + } offset += 1024; } } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/TransferStatusTracker.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/TransferStatusTracker.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/TransferStatusTracker.java index f6a7944..95723bb 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/TransferStatusTracker.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/TransferStatusTracker.java @@ -74,8 +74,9 @@ public class TransferStatusTracker { if (transfers != null && transfers.size() > 0) { return (FileTransferStatus) transfers.get(0); - } else + } else { return null; + } } public void transferringProduct(Product product) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/LocalCache.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/LocalCache.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/LocalCache.java index dcdfa04..626be9a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/LocalCache.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/LocalCache.java @@ -117,10 +117,11 @@ public class LocalCache implements Cache { this.uniqueElementName = uniqueElementName; this.uniqueElementProductTypeNames = uniqueElementProductTypeNames; List<Product> products = new Vector<Product>(); - for (String productType : this.uniqueElementProductTypeNames) + for (String productType : this.uniqueElementProductTypeNames) { products.addAll(getProductsOverDateRange( this.rangeQueryElementName, productType, this.startOfQuery, this.endOfQuery)); + } clear(); for (Product product : products) { String value = getValueForMetadata(product, uniqueElementName); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/StdIngester.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/StdIngester.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/StdIngester.java index 828dea7..2ad6aef 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/StdIngester.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/ingest/StdIngester.java @@ -172,8 +172,9 @@ public class StdIngester implements Ingester, CoreMetKeys { // try and guess the structure if (prodFile.isDirectory()) { productStructure = Product.STRUCTURE_HIERARCHICAL; - } else + } else { productStructure = Product.STRUCTURE_FLAT; + } } // create the product @@ -235,8 +236,9 @@ public class StdIngester implements Ingester, CoreMetKeys { LOG.log(Level.WARNING, "Property: [" + propName + "] is not provided"); return false; - } else + } else { return true; + } } private void checkOrSetFileManager(URL url) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java index 7e786e8..db66eb1 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java @@ -101,8 +101,9 @@ public class FinalFileLocationExtractor extends AbstractFilemgrMetExtractor } private void scrubRefs(Product p) { - if (p.getProductReferences() == null) + if (p.getProductReferences() == null) { return; + } for (Reference r : p.getProductReferences()) { r.setDataStoreReference(""); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java index d76d0bc..bf19b42 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java @@ -160,17 +160,19 @@ public class BooleanQueryCriteria extends QueryCriteria { */ public String toString() { String query = ""; - if (operator == AND) + if (operator == AND) { query += "AND("; - else if (operator == OR) + } else if (operator == OR) { query += "OR("; - else + } else { query += "NOT("; + } for (int i = 0; i < terms.size(); i++) { query += ((QueryCriteria) terms.get(i)).toString(); - if (i < (terms.size() - 1)) + if (i < (terms.size() - 1)) { query += ", "; + } } query += ")"; return query; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java index 5fc05e9..daf9fa3 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java @@ -125,8 +125,9 @@ public class FreeTextQueryCriteria extends QueryCriteria { // filter noise words and add to values vector while (tok.hasMoreElements()) { token = tok.nextToken(); - if (!noiseWordHash.contains(token)) + if (!noiseWordHash.contains(token)) { values.add(token); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java index 242db6d..f857cbd 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java @@ -183,8 +183,9 @@ public class Product { */ public void setProductStructure(String productStructure) { //Guard clause, according to a unit test null is a valid value - if (!java.util.Arrays.asList(VALID_STRUCTURES).contains(productStructure) && productStructure != null) - throw new IllegalArgumentException("Undefined product structure: "+productStructure); + if (!java.util.Arrays.asList(VALID_STRUCTURES).contains(productStructure) && productStructure != null) { + throw new IllegalArgumentException("Undefined product structure: " + productStructure); + } this.productStructure = productStructure; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java index 257d69a..4b9d552 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java @@ -49,10 +49,11 @@ public class Query { * @param criteria */ public Query(List<QueryCriteria> criteria) { - if (criteria == null) + if (criteria == null) { this.criteria = new Vector<QueryCriteria>(); - else + } else { this.criteria = criteria; + } } /** @@ -67,8 +68,9 @@ public class Query { * The criteria to set. */ public void setCriteria(List<QueryCriteria> criteria) { - if (criteria != null) + if (criteria != null) { this.criteria = criteria; + } } public void addCriterion(QueryCriteria qc) { @@ -87,8 +89,9 @@ public class Query { for (int i = 0; i < numCriteria; i++) { QueryCriteria c = (QueryCriteria) criteria.get(i); rStr.append(c.toString()); - if (i != numCriteria - 1) + if (i != numCriteria - 1) { rStr.append(" AND "); + } } return rStr.toString(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java index 7e7c246..b041f5d 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java @@ -209,7 +209,9 @@ public class Reference { * the String name of the mimetype of this reference */ public void setMimeType(String name) { - if(name == null || (name.equals(""))) return; + if(name == null || (name.equals(""))) { + return; + } try { this.mimeType = mimeTypeRepository.forName(name); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/ComplexQuery.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/ComplexQuery.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/ComplexQuery.java index ee696e9..998b02c 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/ComplexQuery.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/ComplexQuery.java @@ -65,8 +65,9 @@ public class ComplexQuery extends Query { public void setReducedMetadata(List<String> reducedMetadata) { this.reducedMetadata = reducedMetadata; if (this.sortByMetKey != null && this.reducedMetadata != null - && !this.reducedMetadata.contains(this.sortByMetKey)) + && !this.reducedMetadata.contains(this.sortByMetKey)) { this.reducedMetadata.add(this.sortByMetKey); + } } public QueryFilter getQueryFilter() { @@ -84,8 +85,9 @@ public class ComplexQuery extends Query { public void setSortByMetKey(String sortByMetKey) { this.sortByMetKey = sortByMetKey; if (this.reducedMetadata != null && this.sortByMetKey != null - && !this.reducedMetadata.contains(this.sortByMetKey)) + && !this.reducedMetadata.contains(this.sortByMetKey)) { this.reducedMetadata.add(this.sortByMetKey); + } } public String getToStringResultFormat() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryFilter.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryFilter.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryFilter.java index 0f38412..cf9e60a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryFilter.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryFilter.java @@ -74,8 +74,9 @@ public class QueryFilter { } public void setFilterAlgor(FilterAlgor filterAlgor) { - if (filterAlgor != null) + if (filterAlgor != null) { this.filterAlgor = filterAlgor; + } } public VersionConverter getConverter() { @@ -83,8 +84,9 @@ public class QueryFilter { } public void setConverter(VersionConverter converter) { - if (converter != null) + if (converter != null) { this.converter = converter; + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResult.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResult.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResult.java index 18c983c..190e6a5 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResult.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResult.java @@ -76,46 +76,58 @@ public class QueryResult { } private static String convertMetadataToString(Metadata metadata, String format) { - if (format == null) - return concatMetadataIntoString(metadata); + if (format == null) { + return concatMetadataIntoString(metadata); + } String outputString = format; - for (String key : metadata.getAllKeys()) - outputString = outputString.replaceAll("\\$" + key, - StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key))); + for (String key : metadata.getAllKeys()) { + outputString = outputString.replaceAll("\\$" + key, + StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key))); + } return outputString; } private static String concatMetadataIntoString(Metadata metadata) { List<String> outputString = new ArrayList<String>(); - for (String key : metadata.getAllKeys()) - outputString.add(StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key))); + for (String key : metadata.getAllKeys()) { + outputString.add(StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key))); + } return StringUtils.collectionToCommaDelimitedString(outputString); } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } QueryResult other = (QueryResult) obj; if (metadata == null) { - if (other.metadata != null) + if (other.metadata != null) { return false; - } else if (!metadata.equals(other.metadata)) + } + } else if (!metadata.equals(other.metadata)) { return false; + } if (product == null) { - if (other.product != null) + if (other.product != null) { return false; - } else if (!product.equals(other.product)) + } + } else if (!product.equals(other.product)) { return false; + } if (toStringFormat == null) { - if (other.toStringFormat != null) + if (other.toStringFormat != null) { return false; - } else if (!toStringFormat.equals(other.toStringFormat)) + } + } else if (!toStringFormat.equals(other.toStringFormat)) { return false; + } return true; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResultComparator.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResultComparator.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResultComparator.java index 9552d11..a654e3a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResultComparator.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/QueryResultComparator.java @@ -45,13 +45,16 @@ public class QueryResultComparator implements Comparator<QueryResult> { public int compare(QueryResult qr1, QueryResult qr2) { String m1 = qr1.getMetadata().getMetadata(sortByMetKey); String m2 = qr2.getMetadata().getMetadata(sortByMetKey); - if (m1 == m2) + if (m1 == m2) { return 0; + } // return null last, since they are the least interesting - if (m1 == null) + if (m1 == null) { return 1; - if (m2 == null) + } + if (m2 == null) { return -1; + } return m1.compareTo(m2); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/conv/AsciiSortableVersionConverter.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/conv/AsciiSortableVersionConverter.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/conv/AsciiSortableVersionConverter.java index 23be461..41ee00e 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/conv/AsciiSortableVersionConverter.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/conv/AsciiSortableVersionConverter.java @@ -31,8 +31,9 @@ public class AsciiSortableVersionConverter implements VersionConverter { public double convertToPriority(String version) { double priority = 0; char[] versionCharArray = version.toCharArray(); - for (int i = 0, j = versionCharArray.length - 1; i < versionCharArray.length; i++, j--) + for (int i = 0, j = versionCharArray.length - 1; i < versionCharArray.length; i++, j--) { priority += (((int) versionCharArray[i]) * Math.pow(10, j)); + } return priority; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/ObjectTimeEvent.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/ObjectTimeEvent.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/ObjectTimeEvent.java index 4c16804..b429f5f 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/ObjectTimeEvent.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/ObjectTimeEvent.java @@ -47,8 +47,9 @@ public class ObjectTimeEvent<objType> extends TimeEvent { if (obj instanceof ObjectTimeEvent) { ObjectTimeEvent<?> ote = (ObjectTimeEvent<?>) obj; return super.equals(obj) && this.timeObj.equals(ote.timeObj); - } else + } else { return false; + } } public String toString() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/TimeEvent.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/TimeEvent.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/TimeEvent.java index bbc0a98..dec2f9c 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/TimeEvent.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/query/filter/TimeEvent.java @@ -68,8 +68,9 @@ public class TimeEvent implements Comparable<TimeEvent> { if (obj instanceof TimeEvent) { TimeEvent te = (TimeEvent) obj; return te.startTime == this.startTime && te.endTime == this.endTime; - } else + } else { return false; + } } public String toString() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/TypeHandler.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/TypeHandler.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/TypeHandler.java index f9f6227..fdb18d1 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/TypeHandler.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/TypeHandler.java @@ -75,8 +75,9 @@ public abstract class TypeHandler { */ public Query preQueryHandle(Query query) throws QueryFormulationException { LinkedList<QueryCriteria> qcList = new LinkedList<QueryCriteria>(); - for (QueryCriteria qc : query.getCriteria()) + for (QueryCriteria qc : query.getCriteria()) { qcList.add(this.handleQueryCriteria(qc)); + } query.setCriteria(qcList); return query; } @@ -84,13 +85,15 @@ public abstract class TypeHandler { private QueryCriteria handleQueryCriteria(QueryCriteria qc) throws QueryFormulationException { if (qc instanceof BooleanQueryCriteria) { LinkedList<QueryCriteria> qcList = new LinkedList<QueryCriteria>(); - for (QueryCriteria criteria : ((BooleanQueryCriteria) qc).getTerms()) + for (QueryCriteria criteria : ((BooleanQueryCriteria) qc).getTerms()) { qcList.add(this.handleQueryCriteria(criteria)); + } BooleanQueryCriteria bqc = new BooleanQueryCriteria(); bqc.setOperator(((BooleanQueryCriteria) qc).getOperator()); bqc.setElementName(qc.getElementName()); - for (QueryCriteria criteria : qcList) + for (QueryCriteria criteria : qcList) { bqc.addTerm(criteria); + } return bqc; }else if (qc.getElementName().equals(elementName) && qc instanceof TermQueryCriteria) { return this.handleTermQueryCriteria((TermQueryCriteria) qc); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/ValueReplaceTypeHandler.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/ValueReplaceTypeHandler.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/ValueReplaceTypeHandler.java index e04262a..2e33b12 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/ValueReplaceTypeHandler.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/type/ValueReplaceTypeHandler.java @@ -63,10 +63,12 @@ public abstract class ValueReplaceTypeHandler extends TypeHandler { */ @Override protected QueryCriteria handleRangeQueryCriteria(RangeQueryCriteria rqc) { - if (rqc.getEndValue() != null) + if (rqc.getEndValue() != null) { rqc.setEndValue(this.getCatalogValue(rqc.getEndValue())); - if (rqc.getStartValue() != null) + } + if (rqc.getStartValue() != null) { rqc.setStartValue(this.getCatalogValue(rqc.getStartValue())); + } return rqc; } @@ -75,8 +77,9 @@ public abstract class ValueReplaceTypeHandler extends TypeHandler { */ @Override protected QueryCriteria handleTermQueryCriteria(TermQueryCriteria tqc) { - if (tqc.getValue() != null) + if (tqc.getValue() != null) { tqc.setValue(this.getCatalogValue(tqc.getValue())); + } return tqc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java index 0be545d..3c2a17e 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java @@ -173,8 +173,9 @@ public class XmlRpcFileManager { .getCurrentFileTransfer(); if (status == null) { return new Hashtable<String, Object>(); - } else - return XmlRpcStructFactory.getXmlRpcFileTransferStatus(status); + } else { + return XmlRpcStructFactory.getXmlRpcFileTransferStatus(status); + } } public Vector<Hashtable<String, Object>> getCurrentFileTransfers() { @@ -183,8 +184,9 @@ public class XmlRpcFileManager { if (currentTransfers != null && currentTransfers.size() > 0) { return XmlRpcStructFactory .getXmlRpcFileTransferStatuses(currentTransfers); - } else - return new Vector<Hashtable<String, Object>>(); + } else { + return new Vector<Hashtable<String, Object>>(); + } } public double getProductPctTransferred(Hashtable<String, Object> productHash) { @@ -589,9 +591,10 @@ public class XmlRpcFileManager { } else { productTypes = new Vector<ProductType>(); for (String productTypeName : complexQuery - .getReducedProductTypeNames()) - productTypes.add(this.repositoryManager - .getProductTypeByName(productTypeName)); + .getReducedProductTypeNames()) { + productTypes.add(this.repositoryManager + .getProductTypeByName(productTypeName)); + } } // get Metadata @@ -623,9 +626,10 @@ public class XmlRpcFileManager { } // sort query results - if (complexQuery.getSortByMetKey() != null) - queryResults = sortQueryResultList(queryResults, complexQuery - .getSortByMetKey()); + if (complexQuery.getSortByMetKey() != null) { + queryResults = sortQueryResultList(queryResults, complexQuery + .getSortByMetKey()); + } return XmlRpcStructFactory.getXmlRpcQueryResults(queryResults); } catch (Exception e) { @@ -923,9 +927,10 @@ public class XmlRpcFileManager { } catch (CatalogException e) { throw new DataTransferException(e.getMessage(),e); } - } else - throw new UnsupportedOperationException( - "Moving of heirarhical and stream products not supported yet"); + } else { + throw new UnsupportedOperationException( + "Moving of heirarhical and stream products not supported yet"); + } } public boolean removeFile(String filePath) throws DataTransferException, IOException { @@ -1013,11 +1018,12 @@ public class XmlRpcFileManager { @SuppressWarnings("unused") XmlRpcFileManager manager = new XmlRpcFileManager(portNum); - for (;;) - try { - Thread.currentThread().join(); - } catch (InterruptedException ignore) { - } + for (;;) { + try { + Thread.currentThread().join(); + } catch (InterruptedException ignore) { + } + } } public boolean shutdown() { @@ -1025,8 +1031,9 @@ public class XmlRpcFileManager { this.webServer.shutdown(); this.webServer = null; return true; - } else - return false; + } else { + return false; + } } private synchronized String catalogProduct(Product p) @@ -1181,7 +1188,9 @@ public class XmlRpcFileManager { }else { m = this.getMetadata(product); } - if(this.expandProductMet) m = this.buildProductMetadata(product, m); + if(this.expandProductMet) { + m = this.buildProductMetadata(product, m); + } return this.getOrigValues(m, product.getProductType()); } catch (Exception e) { e.printStackTrace(); @@ -1196,7 +1205,9 @@ public class XmlRpcFileManager { private Metadata getMetadata(Product product) throws CatalogException { try { Metadata m = catalog.getMetadata(product); - if(this.expandProductMet) m = this.buildProductMetadata(product, m); + if(this.expandProductMet) { + m = this.buildProductMetadata(product, m); + } return this.getOrigValues(m, product.getProductType()); } catch (Exception e) { e.printStackTrace(); @@ -1268,9 +1279,10 @@ public class XmlRpcFileManager { } events = queryFilter.getFilterAlgor().filterEvents(events); List<QueryResult> filteredQueryResults = new LinkedList<QueryResult>(); - for (TimeEvent event : events) - filteredQueryResults.add(((ObjectTimeEvent<QueryResult>) event) - .getTimeObject()); + for (TimeEvent event : events) { + filteredQueryResults.add(((ObjectTimeEvent<QueryResult>) event) + .getTimeObject()); + } return filteredQueryResults; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java index a4fdf78..9bf6f1d 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java @@ -1054,9 +1054,10 @@ public class XmlRpcFileManagerClient { if (productTypeHash == null) { return null; - } else - return XmlRpcStructFactory - .getProductTypeFromXmlRpc(productTypeHash); + } else { + return XmlRpcStructFactory + .getProductTypeFromXmlRpc(productTypeHash); + } } @SuppressWarnings("unchecked") @@ -1077,9 +1078,10 @@ public class XmlRpcFileManagerClient { if (productTypeHash == null) { return null; - } else - return XmlRpcStructFactory - .getProductTypeFromXmlRpc(productTypeHash); + } else { + return XmlRpcStructFactory + .getProductTypeFromXmlRpc(productTypeHash); + } } @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/Result.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/Result.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/Result.java index 90f443a..e1b68a1 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/Result.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/Result.java @@ -38,8 +38,9 @@ public class Result { if (kind != null) { java.lang.reflect.Constructor ctor = kind.getConstructor(ARGS); this.value = ctor.newInstance(new Object[] { value }); - } else + } else { this.value = value; + } } /** http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/SecureWebServer.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/SecureWebServer.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/SecureWebServer.java index 445c052..6c7604a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/SecureWebServer.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/auth/SecureWebServer.java @@ -82,9 +82,10 @@ public final class SecureWebServer extends org.apache.xmlrpc.WebServer * */ public void addDispatcher(Dispatcher dispatcher) { - if (dispatcher == null) + if (dispatcher == null) { throw new IllegalArgumentException( - "Non-null dispatchers are illegal"); + "Non-null dispatchers are illegal"); + } dispatchers.add(dispatcher); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/CatalogSearch.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/CatalogSearch.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/CatalogSearch.java index 6dbfbfd..79d0ab7 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/CatalogSearch.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/CatalogSearch.java @@ -122,8 +122,9 @@ public class CatalogSearch { System.out.println("No product found with ID: " + filter); productFilter = ""; } - if (!productFilter.equals("")) + if (!productFilter.equals("")) { System.out.println("Filtering for " + productFilter + " products."); + } } public static void removeFilter() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java index f85853e..f1a0f88 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java @@ -113,8 +113,9 @@ public class DeleteProduct { String prodId = (String) prodId1; remover.remove(prodId); } - } else + } else { remover.remove(productId); + } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ExpImpCatalog.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ExpImpCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ExpImpCatalog.java index ef90492..982c11b 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ExpImpCatalog.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ExpImpCatalog.java @@ -154,9 +154,10 @@ public class ExpImpCatalog { .log(Level.INFO, "Source types and Dest types match: beginning processing"); } - } else - LOG.log(Level.INFO, - "Skipping type validation: catalog i/f impls being used."); + } else { + LOG.log(Level.INFO, + "Skipping type validation: catalog i/f impls being used."); + } // we'll use the get product page method for each product type // paginate through products using source product type @@ -176,9 +177,10 @@ public class ExpImpCatalog { } public void doExpImport() throws RepositoryManagerException, FileManagerException, CatalogException { - if (sourceClient == null) - throw new RuntimeException( - "Cannot request exp/imp of all product types if no filemgr url specified!"); + if (sourceClient == null) { + throw new RuntimeException( + "Cannot request exp/imp of all product types if no filemgr url specified!"); + } List sourceProductTypes = sourceClient.getProductTypes(); doExpImport(sourceProductTypes); } @@ -192,17 +194,20 @@ public class ExpImpCatalog { page = sourceClient.getFirstPage(type); } - if (page == null) - return; + if (page == null) { + return; + } exportProductsToDest(page.getPageProducts(), type); while (!page.isLastPage()) { if (this.srcCatalog != null) { page = srcCatalog.getNextPage(type, page); - } else - page = sourceClient.getNextPage(type, page); - if (page == null) - break; + } else { + page = sourceClient.getNextPage(type, page); + } + if (page == null) { + break; + } exportProductsToDest(page.getPageProducts(), type); } } @@ -373,14 +378,16 @@ public class ExpImpCatalog { if (srcCatPropFile != null) { tool = new ExpImpCatalog(srcCatPropFile, destCatPropFile, unique); - } else - tool = new ExpImpCatalog(new URL(sourceUrl), new URL(destUrl), - unique); + } else { + tool = new ExpImpCatalog(new URL(sourceUrl), new URL(destUrl), + unique); + } if (types != null && types.size() > 0) { tool.doExpImport(types); - } else - tool.doExpImport(); + } else { + tool.doExpImport(); + } } private boolean typesExist(List sourceList, List destList) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java index b842dd2..d1615e3 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java @@ -161,8 +161,9 @@ public final class MetadataDumper { MetadataDumper dumper = new MetadataDumper(fileManagerUrlStr); if (outDirPath != null) { dumper.dumpMetadata(productId, outDirPath); - } else + } else { dumper.dumpMetadata(productId); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ProductDumper.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ProductDumper.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ProductDumper.java index da98438..e606797 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ProductDumper.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/ProductDumper.java @@ -173,8 +173,9 @@ public final class ProductDumper { ProductDumper dumper = new ProductDumper(fileManagerUrlStr); if (outDirPath != null) { dumper.dumpProduct(productId, outDirPath); - } else + } else { dumper.dumpProduct(productId); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java index c1c1a0b..343408a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java @@ -188,27 +188,32 @@ public final class QueryTool { QueryType queryType = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("--lucene")) { - if (queryType != null) + if (queryType != null) { exit("ERROR: Can only perform one query at a time! \n" + usage); - if (args[++i].equals("-query")) + } + if (args[++i].equals("-query")) { queryStr = args[++i]; - else + } else { exit("ERROR: Must specify a query! \n" + usage); + } queryType = QueryType.LUCENE; }else if (args[i].equals("--sql")) { - if (queryType != null) + if (queryType != null) { exit("ERROR: Can only perform one query at a time! \n" + usage); - if (args[++i].equals("-query")) + } + if (args[++i].equals("-query")) { queryStr = args[++i]; - else + } else { exit("ERROR: Must specify a query! \n" + usage); + } for (; i < args.length; i++) { - if (args[i].equals("-sortBy")) + if (args[i].equals("-sortBy")) { sortBy = args[++i]; - else if (args[i].equals("-outputFormat")) + } else if (args[i].equals("-outputFormat")) { outputFormat = args[++i]; - else if (args[i].equals("-delimiter")) + } else if (args[i].equals("-delimiter")) { delimiter = args[++i]; + } } queryType = QueryType.SQL; }else if (args[i].equals("--url")) { @@ -216,8 +221,9 @@ public final class QueryTool { } } - if (queryStr == null || fmUrlStr == null) + if (queryStr == null || fmUrlStr == null) { exit("Must specify a query and filemgr url! \n" + usage); + } if (queryType == QueryType.LUCENE) { URL fmUrl = new URL(fmUrlStr); @@ -245,8 +251,9 @@ public final class QueryTool { complexQuery.setToStringResultFormat(outputFormat); List<QueryResult> results = new XmlRpcFileManagerClient(new URL(filemgrUrl)).complexQuery(complexQuery); StringBuilder returnString = new StringBuilder(""); - for (QueryResult qr : results) + for (QueryResult qr : results) { returnString.append(qr.toString()).append(delimiter); + } return returnString.substring(0, returnString.length() - delimiter.length()); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/RangeQueryTester.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/RangeQueryTester.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/RangeQueryTester.java index bd7c84d..3b476e4 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/RangeQueryTester.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/RangeQueryTester.java @@ -215,8 +215,9 @@ public final class RangeQueryTester { String productFile = (String) productFile1; System.out.println(productFile); } - } else + } else { System.out.println("No results found!"); + } } /** http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java index 89e1226..20ed97f 100755 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java @@ -561,8 +561,9 @@ public class SolrIndexer { private String formatDate(SimpleDateFormat format, String value) throws java.text.ParseException { // Ignore formating if its an ignore value - if (config.getIgnoreValues().contains(value.trim())) - return value; + if (config.getIgnoreValues().contains(value.trim())) { + return value; + } return solrFormat.format(format.parse(value)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/QueryUtils.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/QueryUtils.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/QueryUtils.java index 8972ea0..7ec4da9 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/QueryUtils.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/QueryUtils.java @@ -42,8 +42,9 @@ public class QueryUtils { public static String getQueryResultsAsString( List<QueryResult> queryResults, String delimiter) { StringBuilder returnString = new StringBuilder(""); - for (QueryResult qr : queryResults) + for (QueryResult qr : queryResults) { returnString.append(qr.toString()).append(delimiter); + } return returnString.substring(0, returnString.length() - delimiter.length()); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/SqlParser.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/SqlParser.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/SqlParser.java index 9d98f96..37f9a24 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/SqlParser.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/SqlParser.java @@ -78,19 +78,21 @@ public class SqlParser { public static ComplexQuery parseSqlQueryMethod(String sqlStringQueryMethod) throws QueryFormulationException { - if (!Pattern.matches("((?:SQL)|(?:sql))\\s*(.*)\\s*\\{\\s*SELECT.*FROM.*(?:WHERE.*){0,1}\\}", sqlStringQueryMethod)) + if (!Pattern.matches("((?:SQL)|(?:sql))\\s*(.*)\\s*\\{\\s*SELECT.*FROM.*(?:WHERE.*){0,1}\\}", sqlStringQueryMethod)) { throw new QueryFormulationException("Malformed SQL method"); + } try { ComplexQuery complexQuery = parseSqlQuery(stripOutSqlDefinition(sqlStringQueryMethod)); for (Expression expr : getSqlStatementArgs(sqlStringQueryMethod)) { - if (expr.getKey().toUpperCase().equals("FORMAT")) + if (expr.getKey().toUpperCase().equals("FORMAT")) { complexQuery.setToStringResultFormat(expr.getValue()); - else if (expr.getKey().toUpperCase().equals("SORT_BY")) + } else if (expr.getKey().toUpperCase().equals("SORT_BY")) { complexQuery.setSortByMetKey(expr.getValue()); - else if (expr.getKey().toUpperCase().equals("FILTER")) + } else if (expr.getKey().toUpperCase().equals("FILTER")) { complexQuery.setQueryFilter(createFilter(expr)); + } } return complexQuery; @@ -108,15 +110,18 @@ public class SqlParser { String[] fromValues = (splitSqlStatement[2].trim() + ",").split(","); ComplexQuery sq = new ComplexQuery(); List<String> selectValuesList = Arrays.asList(selectValues); - if (!selectValuesList.contains("*")) + if (!selectValuesList.contains("*")) { sq.setReducedMetadata(Arrays.asList(selectValues)); + } List<String> fromValuesList = Arrays.asList(fromValues); - if (!fromValuesList.contains("*")) + if (!fromValuesList.contains("*")) { sq.setReducedProductTypeNames(fromValuesList); + } - if (splitSqlStatement.length > 3) + if (splitSqlStatement.length > 3) { sq.addCriterion(parseStatement(toPostFix(splitSqlStatement[3] - .trim()))); + .trim()))); + } return sq; } @@ -127,10 +132,12 @@ public class SqlParser { public static String unparseSqlQuery(ComplexQuery complexQuery) throws QueryFormulationException { LinkedList<String> outputArgs = new LinkedList<String>(); - if (complexQuery.getToStringResultFormat() != null) + if (complexQuery.getToStringResultFormat() != null) { outputArgs.add("FORMAT = '" + complexQuery.getToStringResultFormat() + "'"); - if (complexQuery.getSortByMetKey() != null) + } + if (complexQuery.getSortByMetKey() != null) { outputArgs.add("SORT_BY = '" + complexQuery.getSortByMetKey() + "'"); + } if (complexQuery.getQueryFilter() != null) { String filterString = "FILTER = '" + complexQuery.getQueryFilter().getStartDateTimeMetKey() + "," @@ -141,8 +148,9 @@ public class SqlParser { outputArgs.add(filterString + "'"); } String sqlQueryString = getInfixCriteriaString(complexQuery.getCriteria()); - if (sqlQueryString != null && sqlQueryString.startsWith("(") && sqlQueryString.endsWith(")")) - sqlQueryString = sqlQueryString.substring(1, sqlQueryString.length() - 1); + if (sqlQueryString != null && sqlQueryString.startsWith("(") && sqlQueryString.endsWith(")")) { + sqlQueryString = sqlQueryString.substring(1, sqlQueryString.length() - 1); + } return "SQL (" + listToString(outputArgs) + ") { SELECT " + listToString(complexQuery.getReducedMetadata()) @@ -151,12 +159,13 @@ public class SqlParser { } public static String getInfixCriteriaString(List<QueryCriteria> criteriaList) throws QueryFormulationException { - if (criteriaList.size() > 1) + if (criteriaList.size() > 1) { return getInfixCriteriaString(new BooleanQueryCriteria(criteriaList, BooleanQueryCriteria.AND)); - else if (criteriaList.size() == 1) + } else if (criteriaList.size() == 1) { return getInfixCriteriaString(criteriaList.get(0)); - else + } else { return null; + } } public static String getInfixCriteriaString(QueryCriteria criteria) { @@ -167,14 +176,16 @@ public class SqlParser { switch(bqc.getOperator()){ case 0: returnString = "(" + getInfixCriteriaString((QueryCriteria) terms.get(0)); - for (int i = 1; i < terms.size(); i++) + for (int i = 1; i < terms.size(); i++) { returnString += " AND " + getInfixCriteriaString((QueryCriteria) terms.get(i)); + } returnString += ")"; break; case 1: returnString = "(" + getInfixCriteriaString((QueryCriteria) terms.get(0)); - for (int i = 1; i < terms.size(); i++) + for (int i = 1; i < terms.size(); i++) { returnString += " OR " + getInfixCriteriaString((QueryCriteria) terms.get(i)); + } returnString += ")"; break; case 2: @@ -192,8 +203,9 @@ public class SqlParser { String opString = rqc.getInclusive() ? "=" : ""; if (rqc.getStartValue() != null) { opString = ">" + opString + " '" + rqc.getStartValue() + "'"; - }else + }else { opString = "<" + opString + " '" + rqc.getEndValue() + "'"; + } returnString = rqc.getElementName() + " " + opString; }else if (criteria instanceof TermQueryCriteria) { TermQueryCriteria tqc = (TermQueryCriteria) criteria; @@ -219,8 +231,9 @@ public class SqlParser { if (!inExpr) { String[] args = sqlStringQueryMethod.substring(startArgs, i).trim().split("'\\s*,"); LinkedList<Expression> argsList = new LinkedList<Expression>(); - for (String arg : args) + for (String arg : args) { argsList.add(new Expression((arg = arg.trim()).endsWith("'") ? arg : (arg + "'"))); + } return argsList; } else { break; @@ -257,25 +270,29 @@ public class SqlParser { break; case ')': String value; - while (!(value = stack.pop()).equals("(")) + while (!(value = stack.pop()).equals("(")) { postFix.add(value); - if (stack.peek().equals("NOT")) + } + if (stack.peek().equals("NOT")) { postFix.add(stack.pop()); + } break; case ' ': break; default: if (statement.substring(i, i + 3).equals("AND")) { while (!stack.isEmpty() - && (stack.peek().equals("AND"))) + && (stack.peek().equals("AND"))) { postFix.add(stack.pop()); + } stack.push("AND"); i += 2; } else if (statement.substring(i, i + 2).equals("OR")) { while (!stack.isEmpty() && (stack.peek().equals("AND") || stack.peek() - .equals("OR"))) + .equals("OR"))) { postFix.add(stack.pop()); + } stack.push("OR"); i += 1; } else if (statement.substring(i, i + 3).equals("NOT")) { @@ -290,8 +307,9 @@ public class SqlParser { } } - while (!stack.isEmpty()) + while (!stack.isEmpty()) { postFix.add(stack.pop()); + } return postFix; } @@ -327,8 +345,9 @@ public class SqlParser { String arrayString = ""; if (list.size() > 0) { arrayString = list.get(0); - for (int i = 1; i < list.size(); i++) + for (int i = 1; i < list.size(); i++) { arrayString += "," + list.get(i); + } } return arrayString; } @@ -377,13 +396,15 @@ public class SqlParser { this.key = expression.substring(0, matcher.start()).trim(); this.val = this.removeTickBounds(expression.substring(matcher.end()).trim()); String opString = matcher.group(); - for (char c : opString.toCharArray()) + for (char c : opString.toCharArray()) { this.op = this.op | this.getShortValueForOp(c); + } } private String removeTickBounds(String value) { - if (value.startsWith("'") && value.endsWith("'")) + if (value.startsWith("'") && value.endsWith("'")) { value = value.substring(1, value.length() - 1); + } return value; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java index feab94c..115ec65 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java @@ -134,20 +134,26 @@ public final class XmlRpcStructFactory { public static Hashtable<String, Object> getXmlRpcComplexQuery(ComplexQuery complexQuery) { Hashtable<String, Object> complexQueryHash = getXmlRpcQuery(complexQuery); - if (complexQuery.getReducedProductTypeNames() != null) - complexQueryHash.put("reducedProductTypeNames", new Vector<String>(complexQuery.getReducedProductTypeNames())); - else + if (complexQuery.getReducedProductTypeNames() != null) { + complexQueryHash + .put("reducedProductTypeNames", new Vector<String>(complexQuery.getReducedProductTypeNames())); + } else { complexQueryHash.put("reducedProductTypeNames", new Vector<String>()); - if (complexQuery.getReducedMetadata() != null) + } + if (complexQuery.getReducedMetadata() != null) { complexQueryHash.put("reducedMetadata", new Vector<String>(complexQuery.getReducedMetadata())); - else + } else { complexQueryHash.put("reducedMetadata", new Vector<String>()); - if (complexQuery.getSortByMetKey() != null) + } + if (complexQuery.getSortByMetKey() != null) { complexQueryHash.put("sortByMetKey", complexQuery.getSortByMetKey()); - if (complexQuery.getToStringResultFormat() != null) + } + if (complexQuery.getToStringResultFormat() != null) { complexQueryHash.put("toStringResultFormat", complexQuery.getToStringResultFormat()); - if (complexQuery.getQueryFilter() != null) + } + if (complexQuery.getQueryFilter() != null) { complexQueryHash.put("queryFilter", getXmlRpcQueryFilter(complexQuery.getQueryFilter())); + } return complexQueryHash; } @@ -155,14 +161,18 @@ public final class XmlRpcStructFactory { public static ComplexQuery getComplexQueryFromXmlRpc(Hashtable<String, Object> complexQueryHash) { ComplexQuery complexQuery = new ComplexQuery(); complexQuery.setCriteria(getQueryFromXmlRpc(complexQueryHash).getCriteria()); - if (((Vector<String>) complexQueryHash.get("reducedProductTypeNames")).size() > 0) + if (((Vector<String>) complexQueryHash.get("reducedProductTypeNames")).size() > 0) { complexQuery.setReducedProductTypeNames((Vector<String>) complexQueryHash.get("reducedProductTypeNames")); - if (((Vector<String>) complexQueryHash.get("reducedMetadata")).size() > 0) + } + if (((Vector<String>) complexQueryHash.get("reducedMetadata")).size() > 0) { complexQuery.setReducedMetadata((Vector<String>) complexQueryHash.get("reducedMetadata")); + } complexQuery.setSortByMetKey((String) complexQueryHash.get("sortByMetKey")); complexQuery.setToStringResultFormat((String) complexQueryHash.get("toStringResultFormat")); - if (complexQueryHash.get("queryFilter") != null) - complexQuery.setQueryFilter(getQueryFilterFromXmlRpc((Hashtable<String, Object>) complexQueryHash.get("queryFilter"))); + if (complexQueryHash.get("queryFilter") != null) { + complexQuery.setQueryFilter( + getQueryFilterFromXmlRpc((Hashtable<String, Object>) complexQueryHash.get("queryFilter"))); + } return complexQuery; } @@ -204,22 +214,25 @@ public final class XmlRpcStructFactory { public static Vector<Hashtable<String, Object>> getXmlRpcQueryResults(List<QueryResult> queryResults) { Vector<Hashtable<String, Object>> queryResultHashVector = new Vector<Hashtable<String, Object>>(); - for (QueryResult queryResult : queryResults) + for (QueryResult queryResult : queryResults) { queryResultHashVector.add(getXmlRpcQueryResult(queryResult)); + } return queryResultHashVector; } public static List<QueryResult> getQueryResultsFromXmlRpc(Vector<Hashtable<String, Object>> queryResultHashVector) { List<QueryResult> queryResults = new Vector<QueryResult>(); - for (Hashtable<String, Object> queryResultHash : queryResultHashVector) + for (Hashtable<String, Object> queryResultHash : queryResultHashVector) { queryResults.add(getQueryResultFromXmlRpc(queryResultHash)); + } return queryResults; } public static Hashtable<String, Object> getXmlRpcQueryResult(QueryResult queryResult) { Hashtable<String, Object> queryResultHash = new Hashtable<String, Object>(); - if (queryResult.getToStringFormat() != null) + if (queryResult.getToStringFormat() != null) { queryResultHash.put("toStringFormat", queryResult.getToStringFormat()); + } queryResultHash.put("product", getXmlRpcProduct(queryResult.getProduct())); queryResultHash.put("metadata", queryResult.getMetadata().getHashtable()); return queryResultHash; @@ -470,8 +483,9 @@ public final class XmlRpcStructFactory { Hashtable<String, Object> typeHandlerHash) { TypeHandler typeHandler = GenericFileManagerObjectFactory .getTypeHandlerFromClassName((String) typeHandlerHash.get("className")); - if(typeHandler != null) - typeHandler.setElementName((String) typeHandlerHash.get("elementName")); + if(typeHandler != null) { + typeHandler.setElementName((String) typeHandlerHash.get("elementName")); + } return typeHandler; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlStructFactory.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlStructFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlStructFactory.java index 46b1a7a..71e76e5 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlStructFactory.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlStructFactory.java @@ -247,8 +247,9 @@ public final class XmlStructFactory { // Also print types without elements but just with parents ArrayList<String> allTypes = new ArrayList<String>(productTypeMap.keySet()); for(String type: subToSuperMap.keySet()) { - if(!allTypes.contains(type)) + if(!allTypes.contains(type)) { allTypes.add(type); + } } for (String typeId : allTypes) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java index f690847..c3c211d 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java @@ -70,10 +70,12 @@ public final class VersioningUtils { public static List<Reference> getReferencesFromDir(File dirRoot) { List<Reference> references; - if (dirRoot == null) + if (dirRoot == null) { throw new IllegalArgumentException("null"); - if (!dirRoot.isDirectory()) + } + if (!dirRoot.isDirectory()) { dirRoot = dirRoot.getParentFile(); + } references = new Vector<Reference>(); @@ -115,10 +117,11 @@ public final class VersioningUtils { } File[] subdirs = dir.listFiles(DIR_FILTER); - if (subdirs != null) + if (subdirs != null) { for (File subdir : subdirs) { stack.push(subdir); } + } } return references; @@ -127,10 +130,12 @@ public final class VersioningUtils { public static List<String> getURIsFromDir(File dirRoot) { List<String> uris; - if (dirRoot == null) + if (dirRoot == null) { throw new IllegalArgumentException("null"); - if (!dirRoot.isDirectory()) + } + if (!dirRoot.isDirectory()) { dirRoot = dirRoot.getParentFile(); + } uris = new Vector<String>(); @@ -152,10 +157,11 @@ public final class VersioningUtils { } File[] subdirs = dir.listFiles(DIR_FILTER); - if (subdirs != null) + if (subdirs != null) { for (File subdir : subdirs) { stack.push(subdir); } + } } return uris; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/ConfigBean.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ConfigBean.java b/grid/src/main/java/org/apache/oodt/grid/ConfigBean.java index ba7afd6..ef4ca62 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ConfigBean.java +++ b/grid/src/main/java/org/apache/oodt/grid/ConfigBean.java @@ -60,8 +60,9 @@ public class ConfigBean implements Serializable { * Message to display. */ public void setMessage(String message) { - if (message == null) + if (message == null) { throw new IllegalArgumentException("message cannot be null"); + } this.message = message; } @@ -158,8 +159,9 @@ public class ConfigBean implements Serializable { * if the administrator's not authenticated. */ private void checkAuthenticity() throws AuthenticationRequiredException { - if (isAuthentic() && configuration != null) + if (isAuthentic() && configuration != null) { return; + } message = ""; throw new AuthenticationRequiredException(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java b/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java index 3d8cd5b..8a5b0a3 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java @@ -50,13 +50,15 @@ public class ConfigServlet extends GridServlet { throws ServletException, IOException { Configuration config = getConfiguration(); // Get the singleton // configuration - if (!approveAccess(config, req, res)) + if (!approveAccess(config, req, res)) { return; // Check if the user can access this page + } ConfigBean cb = getConfigBean(req); // Get the bean cb.setMessage(""); // Clear out any message - if (!cb.isAuthentic()) + if (!cb.isAuthentic()) { throw new ServletException(new AuthenticationRequiredException()); + } boolean needSave = false; // Assume no changes for now String newPass = req.getParameter("password"); // See if she wants to change @@ -99,8 +101,9 @@ public class ConfigServlet extends GridServlet { // property if (newKey != null && newKey.length() > 0) { // And make sure it's nonempty String newVal = req.getParameter("newval"); // Got one, get its value - if (newVal == null) + if (newVal == null) { newVal = ""; // Make sure it's at least an empty string + } config.getProperties().setProperty(newKey, newVal); // Set the new // property needSave = true; // We need to save @@ -245,11 +248,15 @@ public class ConfigServlet extends GridServlet { if (newClass != null && newClass.length() > 0) { // And nonempty Server server; if (type == 'd') // If it's data + { server = new ProductServer(config, newClass); // It's a product - // server + } +// server else // otherwise it's metadata + { server = new ProfileServer(config, newClass); // Which is a profile + } // server servers.add(server); // Add it to the set of servers needSave = true; // And after all this, we need to save! http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/Configuration.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/Configuration.java b/grid/src/main/java/org/apache/oodt/grid/Configuration.java index ee5cdc6..ed82943 100755 --- a/grid/src/main/java/org/apache/oodt/grid/Configuration.java +++ b/grid/src/main/java/org/apache/oodt/grid/Configuration.java @@ -63,8 +63,9 @@ public class Configuration implements Serializable { */ public Configuration(File file) throws IOException, SAXException { this.file = file; - if (file.isFile() && file.length() > 0) + if (file.isFile() && file.length() > 0) { parse(file); + } } /** @@ -80,7 +81,9 @@ public class Configuration implements Serializable { elem.setAttribute("localhost", localhostRequired? "true" : "false"); // Add localhost attribute if (password != null && password.length > 0) // If we have a password + { elem.setAttribute("password", encode(password)); // Add passowrd attribute + } for (Object productServer : productServers) { // For each product server ProductServer ps = (ProductServer) productServer; // Get the product server @@ -209,8 +212,9 @@ public class Configuration implements Serializable { * @param password Administrator password. */ public void setPassword(byte[] password) { - if (password == null) + if (password == null) { throw new IllegalArgumentException("Non-null passwords not allowed"); + } this.password = password; } @@ -235,9 +239,12 @@ public class Configuration implements Serializable { } catch (TransformerException ex) { throw new IllegalStateException("Unexpected TransformerException: " + ex.getMessage()); } finally { - if (writer != null) try { // And if we got a writer, try ... - writer.close(); // to close it - } catch (IOException ignore) {} // Ignoring any error + if (writer != null) { + try { // And if we got a writer, try ... + writer.close(); // to close it + } catch (IOException ignore) { + } // Ignoring any error + } } } @@ -263,7 +270,9 @@ public class Configuration implements Serializable { String passwordAttr = root.getAttribute("password"); // Get the password attribute if (passwordAttr != null && passwordAttr.length() > 0) // If it's there, and non-empty + { password = decode(passwordAttr); // Then decode it + } NodeList children = root.getChildNodes(); // Get the child nodes for (int i = 0; i < children.getLength(); ++i) { // For each child node @@ -274,10 +283,14 @@ public class Configuration implements Serializable { // Keep these in separate sets? if (server instanceof ProductServer) // Is a product server? + { productServers.add(server); // Add to product servers - else if (server instanceof ProfileServer) // Is a profile server? + } else if (server instanceof ProfileServer) // Is a profile server? + { profileServers.add(server); // Add to profile servers - else throw new IllegalArgumentException("Unexpected server type " + server + " in " + file); + } else { + throw new IllegalArgumentException("Unexpected server type " + server + " in " + file); + } } else if ("properties".equals(child.getNodeName())) { // Is it a <properties>? NodeList props = child.getChildNodes(); // Get its children for (int j = 0; j < props.getLength(); ++j) { // For each child @@ -287,8 +300,10 @@ public class Configuration implements Serializable { Element propNode = (Element) node; // Great, use it as an element String key = propNode.getAttribute("key"); // Get its key attribute if (key == null || key.length() == 0) // Make sure it's there + { throw new SAXException("Required 'key' attribute missing from " - + "<property> element"); + + "<property> element"); + } properties.setProperty(key, text(propNode)); // And set it } } @@ -300,9 +315,10 @@ public class Configuration implements Serializable { && "codeBase".equals(node.getNodeName())) { Element cbNode = (Element) node; String u = cbNode.getAttribute("url"); - if (u == null || u.length() == 0) + if (u == null || u.length() == 0) { throw new SAXException("Required 'url' attribute missing from " - + "<codeBase> element"); + + "<codeBase> element"); + } try { codeBases.add(new URL(u)); } catch (MalformedURLException ex) { @@ -356,15 +372,19 @@ public class Configuration implements Serializable { */ private static void text0(Node node, StringBuffer b) { NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) + for (int i = 0; i < children.getLength(); ++i) { text0(children.item(i), b); + } short type = node.getNodeType(); - if (type == Node.CDATA_SECTION_NODE || type == Node.TEXT_NODE) + if (type == Node.CDATA_SECTION_NODE || type == Node.TEXT_NODE) { b.append(node.getNodeValue()); + } } public boolean equals(Object obj) { - if (obj == this) return true; + if (obj == this) { + return true; + } if (obj instanceof Configuration) { Configuration rhs = (Configuration) obj; return codeBases.equals(rhs.codeBases) && productServers.equals(rhs.productServers) http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/GridServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/GridServlet.java b/grid/src/main/java/org/apache/oodt/grid/GridServlet.java index 7a039ff..8f5ccdd 100755 --- a/grid/src/main/java/org/apache/oodt/grid/GridServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/GridServlet.java @@ -51,11 +51,16 @@ public abstract class GridServlet extends HttpServlet { * @throws IOException if an error occurs. */ protected Configuration getConfiguration() throws ServletException, IOException { - if (configuration != null) return configuration; + if (configuration != null) { + return configuration; + } String path = getServletContext().getInitParameter("org.apache.oodt.grid.GridServlet.config"); - if (path == null) path = getServletContext().getRealPath("/WEB-INF/config.xml"); - if (path == null) - throw new ServletException("The config.xml file can't be accessed. Are we running from a war file!??!"); + if (path == null) { + path = getServletContext().getRealPath("/WEB-INF/config.xml"); + } + if (path == null) { + throw new ServletException("The config.xml file can't be accessed. Are we running from a war file!??!"); + } File file = new File(path); Configuration c; try { @@ -64,8 +69,9 @@ public abstract class GridServlet extends HttpServlet { throw new ServletException("Cannot parse config.xml file", ex); } synchronized (GridServlet.class) { - while (configuration == null) - configuration = c; + while (configuration == null) { + configuration = c; + } } return configuration; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/LoginServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/LoginServlet.java b/grid/src/main/java/org/apache/oodt/grid/LoginServlet.java index 3fa9882..01e186a 100755 --- a/grid/src/main/java/org/apache/oodt/grid/LoginServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/LoginServlet.java @@ -38,7 +38,9 @@ public class LoginServlet extends GridServlet { */ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Configuration config = getConfiguration(); // Get configuration - if (!approveAccess(config, req, res)) return; // Do https, localhost checking first + if (!approveAccess(config, req, res)) { + return; // Do https, localhost checking first + } ConfigBean cb = getConfigBean(req); // Get bean if (cb.isAuthentic()) { // Already authentic? @@ -47,7 +49,9 @@ public class LoginServlet extends GridServlet { } String password = req.getParameter("password"); // Get submitted password - if (password == null) password = ""; // If none, use an empty string + if (password == null) { + password = ""; // If none, use an empty string + } byte[] bytes = password.getBytes(); // Get the bytes if (!Arrays.equals(config.getPassword(), bytes)) { // Compare to stored password bytes cb.setMessage("Password incorrect"); // Not equal! Set message. http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java index fdf3d61..3ea12ed 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java @@ -99,12 +99,17 @@ public class ProductQueryServlet extends QueryServlet { byte[] buf = new byte[512]; // And a byte buffer for data int num; // And a place to count data while ((num = in.read(buf)) != -1) // While we read - res.getOutputStream().write(buf, 0, num); // We write + { + res.getOutputStream().write(buf, 0, num); // We write + } res.getOutputStream().flush(); // Flush to commit response } finally { // And finally - if (in != null) try { // If we opened it - in.close(); // Close it - } catch (IOException ignore) {} // Ignoring any error during closing + if (in != null) { + try { // If we opened it + in.close(); // Close it + } catch (IOException ignore) { + } // Ignoring any error during closing + } } // Because come on, it's just closing! } // For fsck's sake! @@ -118,10 +123,13 @@ public class ProductQueryServlet extends QueryServlet { String contentType = result.getMimeType(); // Grab the content type res.setContentType(contentType); // Set it long size = result.getSize(); // Grab the size - if (size >= 0) - res.addHeader("Content-Length", String.valueOf(size)); // Don't use setContentLength(int) + if (size >= 0) { + res.addHeader("Content-Length", String.valueOf(size)); // Don't use setContentLength(int) + } if (!displayable(contentType)) // Finally, if a browser can't show it - this.suggestFilename(handler, result, res); // Then suggest a save-as filename + { + this.suggestFilename(handler, result, res); // Then suggest a save-as filename + } } /** @@ -149,7 +157,9 @@ public class ProductQueryServlet extends QueryServlet { protected void suggestFilename(QueryHandler handler, Result result, HttpServletResponse res) { String resource = result.getResourceID(); - if (resource == null || resource.length() == 0) resource = "product.dat"; + if (resource == null || resource.length() == 0) { + resource = "product.dat"; + } // suggest some names based on resource mime type String contentType = res.getContentType();
