http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/SimpleCharStream.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/SimpleCharStream.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/SimpleCharStream.java index 3872048..f1ff115 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/SimpleCharStream.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/SimpleCharStream.java @@ -96,17 +96,19 @@ public class SimpleCharStream bufpos = maxNextCharInd = 0; available = tokenBegin; } - else if (tokenBegin < 0) + else if (tokenBegin < 0) { bufpos = maxNextCharInd = 0; - else + } else { ExpandBuff(false); + } } - else if (available > tokenBegin) + else if (available > tokenBegin) { available = bufsize; - else if ((tokenBegin - available) < 2048) + } else if ((tokenBegin - available) < 2048) { ExpandBuff(true); - else + } else { available = tokenBegin; + } } int i; @@ -116,14 +118,16 @@ public class SimpleCharStream inputStream.close(); throw new java.io.IOException(); } - else + else { maxNextCharInd += i; + } } catch(java.io.IOException e) { --bufpos; backup(0); - if (tokenBegin == -1) + if (tokenBegin == -1) { tokenBegin = bufpos; + } throw e; } } @@ -154,8 +158,9 @@ public class SimpleCharStream { prevCharIsLF = true; } - else + else { line += (column = 1); + } } switch (c) @@ -185,14 +190,16 @@ public class SimpleCharStream { --inBuf; - if (++bufpos == bufsize) + if (++bufpos == bufsize) { bufpos = 0; + } return buffer[bufpos]; } - if (++bufpos >= maxNextCharInd) + if (++bufpos >= maxNextCharInd) { FillBuff(); + } char c = buffer[bufpos]; @@ -244,8 +251,9 @@ public class SimpleCharStream public void backup(int amount) { inBuf += amount; - if ((bufpos -= amount) < 0) + if ((bufpos -= amount) < 0) { bufpos += bufsize; + } } /** Constructor. */ @@ -387,11 +395,12 @@ public class SimpleCharStream /** Get token literal value. */ public String GetImage() { - if (bufpos >= tokenBegin) + if (bufpos >= tokenBegin) { return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else + } else { return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); + new String(buffer, 0, bufpos + 1); + } } /** Get the suffix. */ @@ -399,9 +408,9 @@ public class SimpleCharStream { char[] ret = new char[len]; - if ((bufpos + 1) >= len) + if ((bufpos + 1) >= len) { System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else + } else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); @@ -455,10 +464,11 @@ public class SimpleCharStream while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) { bufline[j] = newLine++; - else + } else { bufline[j] = newLine; + } } }
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java index 9d9b757..2220f4e 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java @@ -67,10 +67,12 @@ public class SerializedCatalogRepository implements CatalogRepository { throws CatalogRepositoryException { LOG.log(Level.INFO, "Deleting Catalog: '" + catalogUrn + "' . . . "); boolean catalogFileDelete = this.getCatalogFile(catalogUrn).delete(); - if (!catalogFileDelete) - throw new CatalogRepositoryException("Failed to deserialize catalog '" + catalogUrn + "', delete files returned false"); - else - LOG.log(Level.INFO, "Successfully deleting Catalog: '" + catalogUrn + "'"); + if (!catalogFileDelete) { + throw new CatalogRepositoryException( + "Failed to deserialize catalog '" + catalogUrn + "', delete files returned false"); + } else { + LOG.log(Level.INFO, "Successfully deleting Catalog: '" + catalogUrn + "'"); + } } /* @@ -125,8 +127,9 @@ public class SerializedCatalogRepository implements CatalogRepository { try { //serialize Catalog new Serializer().serializeObject(catalog, (catalogOut = new FileOutputStream(this.getCatalogFileWorker(catalog.getId())))); - if (this.getCatalogFile(catalog.getId()).exists()) - FileUtils.copyFile(this.getCatalogFile(catalog.getId()), this.getCatalogFileBkup(catalog.getId()), true); + if (this.getCatalogFile(catalog.getId()).exists()) { + FileUtils.copyFile(this.getCatalogFile(catalog.getId()), this.getCatalogFileBkup(catalog.getId()), true); + } FileUtils.copyFile(this.getCatalogFileWorker(catalog.getId()), this.getCatalogFile(catalog.getId()), true); this.getCatalogFileWorker(catalog.getId()).delete(); this.getCatalogFileBkup(catalog.getId()).delete(); @@ -145,8 +148,9 @@ public class SerializedCatalogRepository implements CatalogRepository { try { //serialize URLs new Serializer().serializeObject(urls, (urlsOut = new FileOutputStream(this.getClassLoaderUrlsFileWorker()))); - if (this.getClassLoaderUrlsFile().exists()) - FileUtils.copyFile(this.getClassLoaderUrlsFile(), this.getClassLoaderUrlsFileBkup(), true); + if (this.getClassLoaderUrlsFile().exists()) { + FileUtils.copyFile(this.getClassLoaderUrlsFile(), this.getClassLoaderUrlsFileBkup(), true); + } FileUtils.copyFile(this.getClassLoaderUrlsFileWorker(), this.getClassLoaderUrlsFile(), true); this.getClassLoaderUrlsFileWorker().delete(); this.getClassLoaderUrlsFileBkup().delete(); @@ -162,10 +166,12 @@ public class SerializedCatalogRepository implements CatalogRepository { public List<PluginURL> deserializePluginURLs() throws CatalogRepositoryException { FileInputStream urlsIn = null; try { - if (this.getClassLoaderUrlsFile().exists()) - return new Serializer().deserializeObject(List.class, (urlsIn = new FileInputStream(this.getClassLoaderUrlsFile()))); - else - return Collections.emptyList(); + if (this.getClassLoaderUrlsFile().exists()) { + return new Serializer() + .deserializeObject(List.class, (urlsIn = new FileInputStream(this.getClassLoaderUrlsFile()))); + } else { + return Collections.emptyList(); + } }catch (Exception e) { throw new CatalogRepositoryException("Failed to Deserialized All ClassLoader URLs from '" + this.storageDir + "' : " + e.getMessage(), e); }finally { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java index e5c8890..9622b18 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java @@ -252,8 +252,9 @@ public class XmlRpcCommunicationChannelClient extends AbstractCommunicationChann is = new FileInputStream(new File(fromUrl.getPath())); int offset = 0; int numBytes; - while ((numBytes = is.read(buf, offset, chunkSize)) != -1) - this.transferFile(new File(toURL.getPath()).getAbsolutePath(), buf, offset, numBytes); + while ((numBytes = is.read(buf, offset, chunkSize)) != -1) { + this.transferFile(new File(toURL.getPath()).getAbsolutePath(), buf, offset, numBytes); + } } catch (FileNotFoundException e) { throw new CatalogException("Transfer URL Failed: "+ e.getMessage(), e); } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelServer.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelServer.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelServer.java index 4655bf4..d4b92a7 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelServer.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelServer.java @@ -142,10 +142,11 @@ public class XmlRpcCommunicationChannelServer extends FileOutputStream fOut = null; try { File outFile = new File(filePath); - if (outFile.exists()) - fOut = new FileOutputStream(outFile, true); - else - fOut = new FileOutputStream(outFile, false); + if (outFile.exists()) { + fOut = new FileOutputStream(outFile, true); + } else { + fOut = new FileOutputStream(outFile, false); + } fOut.write(fileData, (int) offset, (int) numBytes); } finally { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/TransactionId.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/TransactionId.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/TransactionId.java index f3f1835..7e5d934 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/TransactionId.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/TransactionId.java @@ -58,12 +58,13 @@ public abstract class TransactionId<NativeType> { } public boolean equals(Object obj) { - if (obj instanceof TransactionId<?>) - return this.toString().equals(obj.toString()); - else if (obj instanceof String) - return this.toString().equals((String) obj); - else - return false; + if (obj instanceof TransactionId<?>) { + return this.toString().equals(obj.toString()); + } else if (obj instanceof String) { + return this.toString().equals((String) obj); + } else { + return false; + } } protected abstract NativeType fromString(String stringId); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionary.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionary.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionary.java index 9b7fdb8..b5e8688 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionary.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionary.java @@ -38,8 +38,9 @@ public class WorkflowManagerDictionary implements Dictionary { public TermBucket lookup(Metadata metadata) { if (metadata.getMetadata("ProductType") != null && metadata.getAllMetadata("ProductType").contains("Workflows")) { TermBucket workflowBucket = new TermBucket("Workflows"); - for (Object key : metadata.getHashtable().keySet()) - workflowBucket.addTerm(new Term((String) key, metadata.getAllMetadata((String) key))); + for (Object key : metadata.getHashtable().keySet()) { + workflowBucket.addTerm(new Term((String) key, metadata.getAllMetadata((String) key))); + } return workflowBucket; }else { return null; @@ -49,8 +50,9 @@ public class WorkflowManagerDictionary implements Dictionary { public Metadata reverseLookup(TermBucket termBucket) { Metadata metadata = new Metadata(); if (termBucket.getName().equals("Workflows")) { - for (Term term : termBucket.getTerms()) - metadata.addMetadata(term.getName(), term.getValues()); + for (Term term : termBucket.getTerms()) { + metadata.addMetadata(term.getName(), term.getValues()); + } } return metadata; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java index 52e8e78..175419a 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java @@ -77,10 +77,11 @@ public class DataSourceIndex implements Index, IngestService, QueryService { conn = this.dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(transaction_id) AS numTransIds FROM transactions"); - if (rs.next()) - return rs.getInt("numTransIds"); - else - throw new Exception("Failed to query for number of transactions"); + if (rs.next()) { + return rs.getInt("numTransIds"); + } else { + throw new Exception("Failed to query for number of transactions"); + } }catch (Exception e) { throw new CatalogIndexException("Failed to get number of transactions : " + e.getMessage(), e); }finally { @@ -253,14 +254,22 @@ public class DataSourceIndex implements Index, IngestService, QueryService { try { conn = this.dataSource.getConnection(); stmt = conn.createStatement(); - for (TermBucket termBucket : termBuckets) - for (Term term : termBucket.getTerms()) - for (String value : term.getValues()) - try { - stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term.getName() + "' AND term_value = '" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "'"); - }catch (Exception e) { - LOG.log(Level.WARNING, "Failed to delete term: '" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + value + "'"); - } + for (TermBucket termBucket : termBuckets) { + for (Term term : termBucket.getTerms()) { + for (String value : term.getValues()) { + try { + stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term + .getName() + "' AND term_value = '" + (this.useUTF8 ? URLEncoder + .encode(value, "UTF8") : value) + "'"); + } catch (Exception e) { + LOG.log(Level.WARNING, + "Failed to delete term: '" + transactionId + "','" + termBucket.getName() + "','" + term + .getName() + "','" + value + "'"); + } + } + } + } conn.commit(); return true; }catch (Exception e) { @@ -285,15 +294,24 @@ public class DataSourceIndex implements Index, IngestService, QueryService { try { conn = this.dataSource.getConnection(); stmt = conn.createStatement(); - for (TermBucket termBucket : termBuckets) - for (Term term : termBucket.getTerms()) - for (String value : term.getValues()) - try { - stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term.getName() + "'"); - stmt.execute("INSERT INTO transaction_terms VALUES ('" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "')"); - }catch (Exception e) { - LOG.log(Level.WARNING, "Failed to ingest term: '" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + value + "'"); - } + for (TermBucket termBucket : termBuckets) { + for (Term term : termBucket.getTerms()) { + for (String value : term.getValues()) { + try { + stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term + .getName() + "'"); + stmt.execute( + "INSERT INTO transaction_terms VALUES ('" + transactionId + "','" + termBucket.getName() + "','" + + term.getName() + "','" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "')"); + } catch (Exception e) { + LOG.log(Level.WARNING, + "Failed to ingest term: '" + transactionId + "','" + termBucket.getName() + "','" + term + .getName() + "','" + value + "'"); + } + } + } + } Calendar calendar = DateUtils.getCurrentLocalTime(); stmt.execute("UPDATE transactions SET transaction_date = '" + DateUtils.toString(calendar) + "' WHERE transaction_id = '" + transactionId + "'"); return new IngestReceipt(transactionId, calendar.getTime()); @@ -327,8 +345,9 @@ public class DataSourceIndex implements Index, IngestService, QueryService { String termName = rs.getString("term_name"); String termValue = rs.getString("term_value"); TermBucket bucket = termBuckets.get(bucketName); - if (bucket == null) - bucket = new TermBucket(bucketName); + if (bucket == null) { + bucket = new TermBucket(bucketName); + } Term term = new Term(termName, Collections.singletonList((this.useUTF8 ? URLDecoder.decode(termValue, "UTF8") : termValue))); bucket.addTerm(term); termBuckets.put(bucketName, bucket); @@ -355,8 +374,9 @@ public class DataSourceIndex implements Index, IngestService, QueryService { public Map<TransactionId<?>, List<TermBucket>> getBuckets( List<TransactionId<?>> transactionIds) throws QueryServiceException { HashMap<TransactionId<?>, List<TermBucket>> map = new HashMap<TransactionId<?>, List<TermBucket>>(); - for (TransactionId<?> transactionId : transactionIds) - map.put(transactionId, this.getBuckets(transactionId)); + for (TransactionId<?> transactionId : transactionIds) { + map.put(transactionId, this.getBuckets(transactionId)); + } return map; } @@ -378,8 +398,12 @@ public class DataSourceIndex implements Index, IngestService, QueryService { rs = stmt.executeQuery(sqlQuery); List<IngestReceipt> receipts = new Vector<IngestReceipt>(); - while (rs.next()) - receipts.add(new IngestReceipt(this.getTransactionIdFactory().createTransactionId(rs.getString("transaction_id")), DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT).getTime())); + while (rs.next()) { + receipts.add( + new IngestReceipt(this.getTransactionIdFactory().createTransactionId(rs.getString("transaction_id")), + DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT) + .getTime())); + } return receipts; }catch (Exception e) { throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e); @@ -410,9 +434,15 @@ public class DataSourceIndex implements Index, IngestService, QueryService { List<IngestReceipt> receipts = new Vector<IngestReceipt>(); int index = 0; - while (startIndex > index && rs.next()) index++; - while (rs.next() && index++ <= endIndex) - receipts.add(new IngestReceipt(this.getTransactionIdFactory().createTransactionId(rs.getString("transaction_id")), DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT).getTime())); + while (startIndex > index && rs.next()) { + index++; + } + while (rs.next() && index++ <= endIndex) { + receipts.add( + new IngestReceipt(this.getTransactionIdFactory().createTransactionId(rs.getString("transaction_id")), + DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT) + .getTime())); + } return receipts; }catch (Exception e) { throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e); @@ -444,8 +474,9 @@ public class DataSourceIndex implements Index, IngestService, QueryService { rs = stmt.executeQuery(sqlQuery); int numTransactions = 0; - while (rs.next()) - numTransactions = rs.getInt("numTransactions"); + while (rs.next()) { + numTransactions = rs.getInt("numTransactions"); + } return numTransactions; }catch (Exception e) { @@ -468,20 +499,22 @@ public class DataSourceIndex implements Index, IngestService, QueryService { StringBuilder sqlQuery = new StringBuilder(); StringBuilder bucketNameFilter = new StringBuilder(""); if (queryExpression.getBucketNames() != null) { - if (queryExpression.getBucketNames().size() == 1) - bucketNameFilter.append("bucket_name = '").append(queryExpression.getBucketNames().iterator().next()) - .append("' ").append("AND "); - else if (queryExpression.getBucketNames().size() > 1) - bucketNameFilter.append("(bucket_name = '") - .append(StringUtils.join(queryExpression.getBucketNames().iterator(), - "' OR bucket_name = '")).append("') AND "); + if (queryExpression.getBucketNames().size() == 1) { + bucketNameFilter.append("bucket_name = '").append(queryExpression.getBucketNames().iterator().next()) + .append("' ").append("AND "); + } else if (queryExpression.getBucketNames().size() > 1) { + bucketNameFilter.append("(bucket_name = '") + .append(StringUtils.join(queryExpression.getBucketNames().iterator(), + "' OR bucket_name = '")).append("') AND "); + } } if (queryExpression instanceof QueryLogicalGroup) { QueryLogicalGroup qlg = (QueryLogicalGroup) queryExpression; sqlQuery.append("(").append(this.getSqlQuery(qlg.getExpressions().get(0))); String op = qlg.getOperator() == QueryLogicalGroup.Operator.AND ? "INTERSECT" : "UNION"; - for (int i = 1; i < qlg.getExpressions().size(); i++) - sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(qlg.getExpressions().get(i))); + for (int i = 1; i < qlg.getExpressions().size(); i++) { + sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(qlg.getExpressions().get(i))); + } sqlQuery.append(")"); }else if (queryExpression instanceof ComparisonQueryExpression){ ComparisonQueryExpression cqe = (ComparisonQueryExpression) queryExpression; @@ -507,8 +540,9 @@ public class DataSourceIndex implements Index, IngestService, QueryService { String value = cqe.getTerm().getValues().get(i); sqlQuery.append("term_value ").append(operator).append(" '") .append(this.useUTF8 ? URLEncoder.encode(value, "UTF-8") : value).append("'"); - if ((i + 1) < cqe.getTerm().getValues().size()) - sqlQuery.append(" OR "); + if ((i + 1) < cqe.getTerm().getValues().size()) { + sqlQuery.append(" OR "); + } } sqlQuery.append(")"); }else if (queryExpression instanceof NotQueryExpression) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java index c331c1a..23f329f 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java @@ -143,8 +143,9 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { public Map<TransactionId<?>, List<TermBucket>> getBuckets( List<TransactionId<?>> transactionIds) throws QueryServiceException { Map<TransactionId<?>, List<TermBucket>> returnMap = new HashMap<TransactionId<?>, List<TermBucket>>(); - for (TransactionId<?> transactionId : transactionIds) - returnMap.put(transactionId, this.getBuckets(transactionId)); + for (TransactionId<?> transactionId : transactionIds) { + returnMap.put(transactionId, this.getBuckets(transactionId)); + } return returnMap; } @@ -161,8 +162,11 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { rs = stmt.executeQuery(sqlQuery); List<IngestReceipt> receipts = new Vector<IngestReceipt>(); - while (rs.next()) - receipts.add(new IngestReceipt(new LongTransactionIdFactory().createTransactionId(rs.getString("workflow_instance_id")), DateConvert.isoParse(rs.getString("start_date_time")))); + while (rs.next()) { + receipts.add(new IngestReceipt( + new LongTransactionIdFactory().createTransactionId(rs.getString("workflow_instance_id")), + DateConvert.isoParse(rs.getString("start_date_time")))); + } return receipts; }catch (Exception e) { throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e); @@ -192,9 +196,14 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { List<IngestReceipt> receipts = new Vector<IngestReceipt>(); int index = 0; - while (startIndex > index && rs.next()) index++; - while (rs.next() && index++ <= endIndex) - receipts.add(new IngestReceipt(new LongTransactionIdFactory().createTransactionId(rs.getString("workflow_instance_id")), DateConvert.isoParse(rs.getString("start_date_time")))); + while (startIndex > index && rs.next()) { + index++; + } + while (rs.next() && index++ <= endIndex) { + receipts.add(new IngestReceipt( + new LongTransactionIdFactory().createTransactionId(rs.getString("workflow_instance_id")), + DateConvert.isoParse(rs.getString("start_date_time")))); + } return receipts; }catch (Exception e) { throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e); @@ -224,8 +233,9 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { rs = stmt.executeQuery(sqlQuery); int numInstances = 0; - while (rs.next()) - numInstances = rs.getInt("numInstances"); + while (rs.next()) { + numInstances = rs.getInt("numInstances"); + } return numInstances; } catch (Exception e) { @@ -254,8 +264,9 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { QueryLogicalGroup qlg = (QueryLogicalGroup) queryExpression; sqlQuery.append("(").append(this.getSqlQuery(qlg.getExpressions().get(0))); String op = qlg.getOperator() == QueryLogicalGroup.Operator.AND ? "INTERSECT" : "UNION"; - for (int i = 1; i < qlg.getExpressions().size(); i++) - sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(qlg.getExpressions().get(i))); + for (int i = 1; i < qlg.getExpressions().size(); i++) { + sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(qlg.getExpressions().get(i))); + } sqlQuery.append(")"); }else if (queryExpression instanceof ComparisonQueryExpression){ ComparisonQueryExpression cqe = (ComparisonQueryExpression) queryExpression; @@ -281,8 +292,9 @@ public class WorkflowManagerDataSourceIndex implements Index, QueryService { String value = cqe.getTerm().getValues().get(i); sqlQuery.append("workflow_met_val ").append(operator).append(" '") .append(URLEncoder.encode(value, "UTF-8")).append("'"); - if ((i + 1) < cqe.getTerm().getValues().size()) - sqlQuery.append("OR"); + if ((i + 1) < cqe.getTerm().getValues().size()) { + sqlQuery.append("OR"); + } } sqlQuery.append(")"); }else if (queryExpression instanceof NotQueryExpression) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java index 457605c..46253c5 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java @@ -58,8 +58,9 @@ public class Catalog { public Catalog(String id, Index index, List<Dictionary> dictionaries, boolean restrictQueryPermissions, boolean restrictIngestPermissions) { this.id = id; this.index = index; - if (dictionaries != null) - this.dictionaries = new Vector<Dictionary>(dictionaries); + if (dictionaries != null) { + this.dictionaries = new Vector<Dictionary>(dictionaries); + } this.restrictQueryPermissions = restrictQueryPermissions; this.restrictIngestPermissions = restrictIngestPermissions; } @@ -85,8 +86,9 @@ public class Catalog { } public void addDictionary(Dictionary dictionary) { - if (this.dictionaries == null) - this.dictionaries = new Vector<Dictionary>(); + if (this.dictionaries == null) { + this.dictionaries = new Vector<Dictionary>(); + } this.dictionaries.add(dictionary); } @@ -170,10 +172,11 @@ public class Catalog { if (termBuckets.size() > 0) { LOG.log(Level.INFO, "Catalog '" + this + "' attemping update metadata for catalog TransactionId [id = '" + transactionId + "']"); IngestReceipt ingestReceipt = ((IngestService) this.index).update(transactionId, termBuckets); - if (ingestReceipt != null) - return new CatalogReceipt(ingestReceipt, this.getId()); - else - return null; + if (ingestReceipt != null) { + return new CatalogReceipt(ingestReceipt, this.getId()); + } else { + return null; + } }else { LOG.log(Level.WARNING, "Catalog '" + this + "' did not generate any TermBuckets from Metadata for catalog TransactionId [id = '" + transactionId + "']"); return null; @@ -226,8 +229,9 @@ public class Catalog { if (this.isQueriable()) { QueryService queryService = (QueryService) this.index; List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>(); - for (IngestReceipt ingestReceipt : queryService.query(queryExpression)) - catalogReceipts.add(new CatalogReceipt(ingestReceipt, this.getId())); + for (IngestReceipt ingestReceipt : queryService.query(queryExpression)) { + catalogReceipts.add(new CatalogReceipt(ingestReceipt, this.getId())); + } return Collections.unmodifiableList(catalogReceipts); }else { LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable"); @@ -244,8 +248,9 @@ public class Catalog { if (this.isQueriable()) { QueryService queryService = (QueryService) this.index; List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>(); - for (IngestReceipt ingestReceipt : queryService.query(queryExpression, startIndex, endIndex)) - catalogReceipts.add(new CatalogReceipt(ingestReceipt, this.getId())); + for (IngestReceipt ingestReceipt : queryService.query(queryExpression, startIndex, endIndex)) { + catalogReceipts.add(new CatalogReceipt(ingestReceipt, this.getId())); + } return Collections.unmodifiableList(catalogReceipts); }else { LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable"); @@ -290,8 +295,9 @@ public class Catalog { if (this.isQueriable()) { QueryService queryService = (QueryService) this.index; Map<TransactionId<?>, List<TermBucket>> termBucketMap = queryService.getBuckets(transactionIds); - for (TransactionId<?> transactionId : termBucketMap.keySet()) - metadataMap.put(transactionId, this.getMetadataFromBuckets(termBucketMap.get(transactionId))); + for (TransactionId<?> transactionId : termBucketMap.keySet()) { + metadataMap.put(transactionId, this.getMetadataFromBuckets(termBucketMap.get(transactionId))); + } }else { LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable"); } @@ -304,9 +310,11 @@ public class Catalog { public boolean isInterested(QueryExpression queryExpression) throws CatalogException { try { if (this.dictionaries != null) { - for (Dictionary dictionary : this.dictionaries) - if (dictionary.understands(queryExpression)) - return true; + for (Dictionary dictionary : this.dictionaries) { + if (dictionary.understands(queryExpression)) { + return true; + } + } return false; }else { return true; @@ -320,8 +328,9 @@ public class Catalog { Metadata metadata = new Metadata(); for (TermBucket termBucket : termBuckets) { if (this.dictionaries != null) { - for (Dictionary dictionary : this.dictionaries) - metadata.addMetadata(dictionary.reverseLookup(termBucket)); + for (Dictionary dictionary : this.dictionaries) { + metadata.addMetadata(dictionary.reverseLookup(termBucket)); + } }else { metadata.addMetadata(this.asMetadata(termBuckets)); } @@ -331,9 +340,11 @@ public class Catalog { protected Metadata asMetadata(List<TermBucket> termBuckets) { Metadata m = new Metadata(); - for (TermBucket bucket : termBuckets) - for (Term term : bucket.getTerms()) - m.addMetadata(term.getName(), term.getValues()); + for (TermBucket bucket : termBuckets) { + for (Term term : bucket.getTerms()) { + m.addMetadata(term.getName(), term.getValues()); + } + } return m; } @@ -342,14 +353,16 @@ public class Catalog { if (this.dictionaries != null) { for (Dictionary dictionary : this.dictionaries) { TermBucket termBucket = dictionary.lookup(metadata); - if (termBucket != null) - termBuckets.add(termBucket); + if (termBucket != null) { + termBuckets.add(termBucket); + } } }else { LOG.log(Level.WARNING, "Catalog '" + this + "' has no dictionaries defined, attempting to send all Metadata in a default TermBucket"); TermBucket bucket = new TermBucket(); - for (String key : metadata.getAllKeys()) - bucket.addTerm(new Term(key, metadata.getAllMetadata(key))); + for (String key : metadata.getAllKeys()) { + bucket.addTerm(new Term(key, metadata.getAllMetadata(key))); + } termBuckets.add(bucket); } return termBuckets; @@ -360,12 +373,13 @@ public class Catalog { } public boolean equals(Object obj) { - if (obj instanceof Catalog) - return ((Catalog) obj).getId().equals(this.getId()); - else if (obj instanceof String) - return this.getId().equals((String) obj); - else - return false; + if (obj instanceof Catalog) { + return ((Catalog) obj).getId().equals(this.getId()); + } else if (obj instanceof String) { + return this.getId().equals((String) obj); + } else { + return false; + } } public String toString() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java index d01b945..f540239 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java @@ -45,8 +45,9 @@ public class CatalogFactory { Vector<Dictionary> dictionaries = null; if (this.dictionaryFactories != null) { dictionaries = new Vector<Dictionary>(); - for (DictionaryFactory dictionaryFactory : this.dictionaryFactories) - dictionaries.add(dictionaryFactory.createDictionary()); + for (DictionaryFactory dictionaryFactory : this.dictionaryFactories) { + dictionaries.add(dictionaryFactory.createDictionary()); + } } return new Catalog(this.catalogId, this.indexFactory.createIndex(), dictionaries, this.restrictQueryPermissions, this.restrictIngestPermissions); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java index 26a5fe6..426626f 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java @@ -53,8 +53,9 @@ public class CatalogServiceClientFactory implements CatalogServiceFactory { @Required public void setAutoPagerSize(int autoPagerSize) { - if (autoPagerSize > 0) - this.autoPagerSize = autoPagerSize; + if (autoPagerSize > 0) { + this.autoPagerSize = autoPagerSize; + } } public String getServerUrl() { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocal.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocal.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocal.java index 9832110..53b619b 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocal.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocal.java @@ -271,14 +271,18 @@ public class CatalogServiceLocal implements CatalogService { backupCatalogs = new HashSet<Catalog>(this.catalogs); for (Catalog catalog : this.catalogs) { if (catalog.getId().equals(catalogId)) { - if (dictionaries != null) - catalog.setDictionaries(dictionaries); - if (index != null) - catalog.setIndex(index); - if (restrictQueryPermission != null) - catalog.setRestrictQueryPermissions(restrictQueryPermissions); - if (restrictIngestPermission != null) - catalog.setRestrictIngestPermissions(restrictIngestPermissions); + if (dictionaries != null) { + catalog.setDictionaries(dictionaries); + } + if (index != null) { + catalog.setIndex(index); + } + if (restrictQueryPermission != null) { + catalog.setRestrictQueryPermissions(restrictQueryPermissions); + } + if (restrictIngestPermission != null) { + catalog.setRestrictIngestPermissions(restrictIngestPermissions); + } this.catalogRepository.serializeCatalog(catalog); break; } @@ -311,10 +315,12 @@ public class CatalogServiceLocal implements CatalogService { * URNs equals that of an existing Catalog. */ public void addCatalog(Catalog catalog) throws CatalogServiceException { - if (!this.containsCatalog(catalog.getId())) - this.replaceCatalog(catalog); - else - LOG.log(Level.WARNING, "Attempt to override an existing catalog '" + catalog + "' already used in CatalogService, remedy and retry add -- no changes took place!"); + if (!this.containsCatalog(catalog.getId())) { + this.replaceCatalog(catalog); + } else { + LOG.log(Level.WARNING, "Attempt to override an existing catalog '" + catalog + + "' already used in CatalogService, remedy and retry add -- no changes took place!"); + } } /** @@ -438,9 +444,11 @@ public class CatalogServiceLocal implements CatalogService { protected Catalog getCatalog(String catalogUrn) throws CatalogServiceException { this.catalogsLock.readLock().lock(); try { - for (Catalog catalog : this.catalogs) - if (catalog.getId().equals(catalogUrn)) - return catalog; + for (Catalog catalog : this.catalogs) { + if (catalog.getId().equals(catalogUrn)) { + return catalog; + } + } return null; }catch (Exception e) { throw new CatalogServiceException("Failed to get catalog catalog '" + catalogUrn + "' : " + e.getMessage(), e); @@ -458,8 +466,9 @@ public class CatalogServiceLocal implements CatalogService { this.catalogsLock.readLock().lock(); try { Set<String> catalogIds = new HashSet<String>(); - for (Catalog catalog : this.catalogs) - catalogIds.add(catalog.getId()); + for (Catalog catalog : this.catalogs) { + catalogIds.add(catalog.getId()); + } return catalogIds; }catch (Exception e) { throw new CatalogServiceException("Failed to get current catalog ids list : " + e.getMessage(), e); @@ -469,13 +478,17 @@ public class CatalogServiceLocal implements CatalogService { } public TransactionReceipt ingest(Metadata metadata) throws CatalogServiceException { - if (this.restrictIngestPermissions) - throw new CatalogServiceException("Ingest permissions are restricted for this CatalogService -- request denied"); + if (this.restrictIngestPermissions) { + throw new CatalogServiceException( + "Ingest permissions are restricted for this CatalogService -- request denied"); + } try { boolean performUpdate; TransactionId<?> catalogServiceTransactionId = this.getCatalogServiceTransactionId(metadata); - if (performUpdate = this.ingestMapper.hasCatalogServiceTransactionId(catalogServiceTransactionId)) - LOG.log(Level.INFO, "TransactionId '" + catalogServiceTransactionId + "' is an existing TransactionId, switching to update mode"); + if (performUpdate = this.ingestMapper.hasCatalogServiceTransactionId(catalogServiceTransactionId)) { + LOG.log(Level.INFO, "TransactionId '" + catalogServiceTransactionId + + "' is an existing TransactionId, switching to update mode"); + } List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>(); for (Catalog catalog : this.getFilteredCatalogList(metadata)) { if (catalog.isIngestable()) { @@ -483,8 +496,11 @@ public class CatalogServiceLocal implements CatalogService { try { // perform update if (performUpdate) { - if (!Boolean.parseBoolean(metadata.getMetadata(ENABLE_UPDATE_MET_KEY))) - throw new CatalogServiceException("TransactionId '" + catalogServiceTransactionId + "' already exists -- enable update by setting metadata key '" + ENABLE_UPDATE_MET_KEY + "'=true"); + if (!Boolean.parseBoolean(metadata.getMetadata(ENABLE_UPDATE_MET_KEY))) { + throw new CatalogServiceException("TransactionId '" + catalogServiceTransactionId + + "' already exists -- enable update by setting metadata key '" + + ENABLE_UPDATE_MET_KEY + "'=true"); + } TransactionId<?> catalogTransactionId = this.ingestMapper.getCatalogTransactionId(catalogServiceTransactionId, catalog.getId()); if (catalogTransactionId != null) { CatalogReceipt catalogReceipt = catalog.update(catalogTransactionId, metadata); @@ -515,8 +531,10 @@ public class CatalogServiceLocal implements CatalogService { } }catch (Exception e) { LOG.log(Level.WARNING, "Failed to add metadata to catalog '" + catalog.getId() + "' : " + e.getMessage(), e); - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to add metadata to catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to add metadata to catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + } }finally { this.ingestMapperLock.writeLock().unlock(); } @@ -536,8 +554,10 @@ public class CatalogServiceLocal implements CatalogService { * @throws CatalogServiceException */ public void delete(Metadata metadata) throws CatalogServiceException { - if (this.restrictIngestPermissions) - throw new CatalogServiceException("Delete permissions are restricted for this CatalogService -- request denied"); + if (this.restrictIngestPermissions) { + throw new CatalogServiceException( + "Delete permissions are restricted for this CatalogService -- request denied"); + } TransactionId<?> catalogServiceTransactionId = this.getCatalogServiceTransactionId(metadata, false); if (catalogServiceTransactionId != null) { for (Catalog catalog : this.getFilteredCatalogList(metadata)) { @@ -567,8 +587,11 @@ public class CatalogServiceLocal implements CatalogService { } }catch (Exception e) { LOG.log(Level.WARNING, "Error occured while deleting metadata for TransactionId [id = " + catalogServiceTransactionId + "] : " + e.getMessage(), e); - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Error occured while deleting metadata for TransactionId [id = " + catalogServiceTransactionId + "] : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Error occured while deleting metadata for TransactionId [id = " + + catalogServiceTransactionId + "] : " + e.getMessage(), e); + } }finally { this.ingestMapperLock.writeLock().unlock(); } @@ -582,9 +605,12 @@ public class CatalogServiceLocal implements CatalogService { } protected boolean doReduce(Metadata metadata) { - for (String key : metadata.getAllKeys()) - if (!(key.equals(CATALOG_SERVICE_TRANSACTION_ID_MET_KEY) || key.equals(CATALOG_IDS_MET_KEY) || key.equals(CATALOG_TRANSACTION_ID_MET_KEY) || key.equals(CATALOG_ID_MET_KEY))) - return true; + for (String key : metadata.getAllKeys()) { + if (!(key.equals(CATALOG_SERVICE_TRANSACTION_ID_MET_KEY) || key.equals(CATALOG_IDS_MET_KEY) || key + .equals(CATALOG_TRANSACTION_ID_MET_KEY) || key.equals(CATALOG_ID_MET_KEY))) { + return true; + } + } return false; } @@ -593,13 +619,19 @@ public class CatalogServiceLocal implements CatalogService { for (Catalog catalog : this.getCurrentCatalogList()) { try { String val = catalog.getProperty(key); - if (val != null) - vals.add(val); + if (val != null) { + vals.add(val); + } }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e + .getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e + .getMessage(), e); + } } } return vals; @@ -612,17 +644,21 @@ public class CatalogServiceLocal implements CatalogService { Properties catalogProperties = catalog.getProperties(); for (Object key : catalogProperties.keySet()) { String value = properties.getProperty((String) key); - if (value != null) - value += "," + catalogProperties.getProperty((String) key); - else - value = catalogProperties.getProperty((String) key); + if (value != null) { + value += "," + catalogProperties.getProperty((String) key); + } else { + value = catalogProperties.getProperty((String) key); + } properties.setProperty((String) key, value); } }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + } } } return properties; @@ -631,10 +667,11 @@ public class CatalogServiceLocal implements CatalogService { public Properties getCalalogProperties(String catalogUrn) throws CatalogServiceException { try { Catalog catalog = this.getCatalog(catalogUrn); - if (catalog != null) - return catalog.getProperties(); - else - return null; + if (catalog != null) { + return catalog.getProperties(); + } else { + return null; + } }catch (Exception e) { throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalogUrn + "' : " + e.getMessage(), e); } @@ -671,8 +708,9 @@ public class CatalogServiceLocal implements CatalogService { for (String catalogId : catalogToSizeOfMap.keySet()) { Catalog catalog = this.getCatalog(catalogId); QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, queryExpression); - if (qe != null) - catalogReceipts.addAll(catalog.query(qe)); + if (qe != null) { + catalogReceipts.addAll(catalog.query(qe)); + } } List<TransactionReceipt> transactionReceipts = this.getPossiblyUnindexedTransactionReceipts(catalogReceipts); LOG.log(Level.INFO, "Sorting Query Results . . . "); @@ -696,8 +734,9 @@ public class CatalogServiceLocal implements CatalogService { if (qe != null) { List<CatalogReceipt> receipts = catalog.query(qe, desiredStartingIndex - currentIndex, Math.min((desiredStartingIndex - currentIndex) + pageInfo.getPageSize(), entry.getValue())); pageOfReceipts.addAll(receipts); - if (pageOfReceipts.size() >= pageInfo.getPageSize()) - break; + if (pageOfReceipts.size() >= pageInfo.getPageSize()) { + break; + } } }else { currentIndex += entry.getValue(); @@ -738,8 +777,10 @@ public class CatalogServiceLocal implements CatalogService { * @throws CatalogServiceException */ public List<TransactionReceipt> _query(QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException { - if (this.restrictQueryPermissions) - throw new CatalogServiceException("Query permissions are restricted for this CatalogService -- request denied"); + if (this.restrictQueryPermissions) { + throw new CatalogServiceException( + "Query permissions are restricted for this CatalogService -- request denied"); + } try { LOG.log(Level.INFO, "Recieved query '" + queryExpression + "'"); if (this.simplifyQueries) { @@ -758,10 +799,15 @@ public class CatalogServiceLocal implements CatalogService { catalogReceipts.addAll(catalog.query(reducedExpression)); } }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + + e.getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + + e.getMessage(), e); + } } } } @@ -790,16 +836,18 @@ public class CatalogServiceLocal implements CatalogService { TransactionId<?> catalogServiceTransactionId = this.getCatalogServiceTransactionId(catalogReceipt.getTransactionId(), catalogReceipt.getCatalogId()); if (catalogServiceTransactionId != null) { List<CatalogReceipt> found = existing.get(catalogServiceTransactionId); - if (found == null) - found = new Vector<CatalogReceipt>(); + if (found == null) { + found = new Vector<CatalogReceipt>(); + } found.add(catalogReceipt); existing.put(catalogServiceTransactionId, found); }else { returnList.add(new TransactionReceipt(null, Collections.singletonList(catalogReceipt))); } } - for (TransactionId<?> transactionId : existing.keySet()) - returnList.add(new TransactionReceipt(transactionId, existing.get(transactionId))); + for (TransactionId<?> transactionId : existing.keySet()) { + returnList.add(new TransactionReceipt(transactionId, existing.get(transactionId))); + } return returnList; }catch (Exception e) { throw new CatalogServiceException(e.getMessage(), e); @@ -811,8 +859,11 @@ public class CatalogServiceLocal implements CatalogService { for (TransactionReceipt transactionReceipt : transactionReceipts) { try { // for (CatalogReceipt catalogReceipt : transactionReceipt.getCatalogReceipts()) { - if (transactionReceipt.getTransactionId() == null) - transactionReceipt = new TransactionReceipt(this.getCatalogServiceTransactionId(transactionReceipt.getCatalogReceipts().get(0), true), transactionReceipt.getCatalogReceipts()); + if (transactionReceipt.getTransactionId() == null) { + transactionReceipt = new TransactionReceipt( + this.getCatalogServiceTransactionId(transactionReceipt.getCatalogReceipts().get(0), true), + transactionReceipt.getCatalogReceipts()); + } // } indexedReceipts.add(transactionReceipt); }catch(Exception e) { @@ -840,8 +891,9 @@ public class CatalogServiceLocal implements CatalogService { public List<TransactionalMetadata> getMetadataFromTransactionIdStrings(List<String> catalogServiceTransactionIdStrings) throws CatalogServiceException { List<TransactionId<?>> catalogServiceTransactionIds = new Vector<TransactionId<?>>(); - for (String catalogServiceTransactionIdString : catalogServiceTransactionIdStrings) - catalogServiceTransactionIds.add(this.generateTransactionId(catalogServiceTransactionIdString)); + for (String catalogServiceTransactionIdString : catalogServiceTransactionIdStrings) { + catalogServiceTransactionIds.add(this.generateTransactionId(catalogServiceTransactionIdString)); + } return this.getMetadataFromTransactionIds(catalogServiceTransactionIds); } @@ -856,14 +908,21 @@ public class CatalogServiceLocal implements CatalogService { metadata.addMetadata(catalog.getMetadata(catalogReceipt.getTransactionId())); successfulCatalogReceipts.add(catalogReceipt); }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to get metadata for transaction ids for catalog '" + catalogReceipt.getCatalogId() + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to get metadata for transaction ids for catalog '" + catalogReceipt.getCatalogId() + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to get metadata for transaction ids for catalog '" + catalogReceipt.getCatalogId() + + "' : " + e.getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to get metadata for transaction ids for catalog '" + catalogReceipt.getCatalogId() + + "' : " + e.getMessage(), e); + } } } - if (metadata.getHashtable().keySet().size() > 0) - metadataSet.add(new TransactionalMetadata(new TransactionReceipt(transactionReceipt.getTransactionId(), successfulCatalogReceipts), metadata)); + if (metadata.getHashtable().keySet().size() > 0) { + metadataSet.add(new TransactionalMetadata( + new TransactionReceipt(transactionReceipt.getTransactionId(), successfulCatalogReceipts), metadata)); + } } return new Vector<TransactionalMetadata>(metadataSet); } @@ -881,14 +940,22 @@ public class CatalogServiceLocal implements CatalogService { catalogReceipts.add(catalogReceipt); } }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogServiceException("Failed to get metadata for transaction ids for catalog '" + catalog.getId() + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to get metadata for transaction ids for catalog '" + catalog.getId() + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogServiceException( + "Failed to get metadata for transaction ids for catalog '" + catalog.getId() + "' : " + e + .getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to get metadata for transaction ids for catalog '" + catalog.getId() + "' : " + e + .getMessage(), e); + } } } - if (metadata.getHashtable().keySet().size() > 0) - metadataSet.add(new TransactionalMetadata(new TransactionReceipt(catalogServiceTransactionId, catalogReceipts), metadata)); + if (metadata.getHashtable().keySet().size() > 0) { + metadataSet.add( + new TransactionalMetadata(new TransactionReceipt(catalogServiceTransactionId, catalogReceipts), + metadata)); + } } return new Vector<TransactionalMetadata>(metadataSet); } @@ -967,8 +1034,11 @@ public class CatalogServiceLocal implements CatalogService { if (catalog != null) { TransactionId<?> catalogTransactionId = catalog.getTransactionIdFromString(metadata.getMetadata(CatalogServiceLocal.CATALOG_TRANSACTION_ID_MET_KEY)); TransactionId<?> catalogServiceTransactionId = this.ingestMapper.getCatalogServiceTransactionId(catalogTransactionId, catalogId); - if (catalogServiceTransactionId == null) - throw new CatalogServiceException("CatalogService's Catalog '" + catalog.getId() + "' is not aware of TransactionId '" + catalogTransactionId + "'s"); + if (catalogServiceTransactionId == null) { + throw new CatalogServiceException( + "CatalogService's Catalog '" + catalog.getId() + "' is not aware of TransactionId '" + + catalogTransactionId + "'s"); + } return catalogServiceTransactionId; }else { throw new CatalogServiceException("This CatalogService has no Catalog with ID = '" + catalogId + "'"); @@ -987,18 +1057,22 @@ public class CatalogServiceLocal implements CatalogService { try { if (metadata.containsKey(CATALOG_ID_MET_KEY)) { Catalog catalog = this.getCatalog(metadata.getMetadata(CATALOG_ID_MET_KEY)); - if (catalog == null) - throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + "' is not managed by this CatalogService"); - else - return Collections.singleton(catalog); + if (catalog == null) { + throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + + "' is not managed by this CatalogService"); + } else { + return Collections.singleton(catalog); + } }else if (metadata.containsKey(CATALOG_IDS_MET_KEY)) { HashSet<Catalog> filteredCatalogList = new HashSet<Catalog>(); for (Object catalogUrn : metadata.getAllMetadata(CATALOG_IDS_MET_KEY)) { Catalog catalog = this.getCatalog((String) catalogUrn); - if (catalog == null) - throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + "' is not managed by this CatalogService"); - else - filteredCatalogList.add(catalog); + if (catalog == null) { + throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + + "' is not managed by this CatalogService"); + } else { + filteredCatalogList.add(catalog); + } } return filteredCatalogList; }else { @@ -1015,8 +1089,9 @@ public class CatalogServiceLocal implements CatalogService { // get children query results List<QueryResult> childrenQueryResults = new Vector<QueryResult>(); - for (QueryExpression subQueryExpression : ((QueryLogicalGroup) queryExpression).getExpressions()) - childrenQueryResults.add(queryRecur(subQueryExpression, restrictToCatalogIds)); + for (QueryExpression subQueryExpression : ((QueryLogicalGroup) queryExpression).getExpressions()) { + childrenQueryResults.add(queryRecur(subQueryExpression, restrictToCatalogIds)); + } // if (QueryLogicalGroup's operator is AND and is unbalanced or a child contains query results) if ((((QueryLogicalGroup) queryExpression).getOperator().equals(QueryLogicalGroup.Operator.AND) && containsUnbalancedCatalogInterest(childrenQueryResults)) || containsTranactionReceipts(childrenQueryResults)) { @@ -1056,8 +1131,9 @@ public class CatalogServiceLocal implements CatalogService { // get merge of results QueryResult queryResult = new QueryResult(queryExpression); HashSet<String> interestedCatalogs = new HashSet<String>(); - for (QueryResult childQueryResult : childrenQueryResults) - interestedCatalogs.addAll(childQueryResult.getInterestedCatalogs()); + for (QueryResult childQueryResult : childrenQueryResults) { + interestedCatalogs.addAll(childQueryResult.getInterestedCatalogs()); + } queryResult.setInterestedCatalogs(interestedCatalogs); return queryResult; } @@ -1095,8 +1171,9 @@ public class CatalogServiceLocal implements CatalogService { QueryResult qr = queryResults.get(i); TR: for (CatalogReceipt catalogReceipt : qr.getCatalogReceipts()) { for (CatalogReceipt compCatalogReceipt : catalogReceipts) { - if (catalogReceipt.getTransactionId().equals(compCatalogReceipt.getTransactionId())) - continue TR; + if (catalogReceipt.getTransactionId().equals(compCatalogReceipt.getTransactionId())) { + continue TR; + } } catalogReceipts.remove(catalogReceipt); } @@ -1116,8 +1193,9 @@ TR: for (CatalogReceipt catalogReceipt : qr.getCatalogReceipts()) { restrictedExpressions.clear(); break; } - if (restrictedQE != null) - restrictedExpressions.add(restrictedQE); + if (restrictedQE != null) { + restrictedExpressions.add(restrictedQE); + } } if (restrictedExpressions.size() > 0) { if (restrictedExpressions.size() == 1) { @@ -1157,9 +1235,11 @@ TR: for (CatalogReceipt catalogReceipt : qr.getCatalogReceipts()) { } protected boolean containsTranactionReceipts(List<QueryResult> queryResults) { - for (QueryResult queryResult : queryResults) - if (queryResult.getCatalogReceipts() != null) - return true; + for (QueryResult queryResult : queryResults) { + if (queryResult.getCatalogReceipts() != null) { + return true; + } + } return false; } @@ -1168,8 +1248,9 @@ TR: for (CatalogReceipt catalogReceipt : qr.getCatalogReceipts()) { QueryResult firstQueryResult = queryResults.get(0); for (int i = 1; i < queryResults.size(); i++) { QueryResult queryResult = queryResults.get(i); - if (!(queryResult.interestedCatalogs.containsAll(firstQueryResult.interestedCatalogs) && firstQueryResult.interestedCatalogs.containsAll(queryResult.interestedCatalogs))) - return true; + if (!(queryResult.interestedCatalogs.containsAll(firstQueryResult.interestedCatalogs) && firstQueryResult.interestedCatalogs.containsAll(queryResult.interestedCatalogs))) { + return true; + } } return false; }else { @@ -1182,14 +1263,20 @@ TR: for (CatalogReceipt catalogReceipt : qr.getCatalogReceipts()) { for (Catalog catalog : this.getCurrentCatalogList()) { try { if (restrictToCatalogIds.contains(catalog.getId())) { - if (catalog.isInterested(queryExpression)) - interestedCatalogs.add(catalog.getId()); + if (catalog.isInterested(queryExpression)) { + interestedCatalogs.add(catalog.getId()); + } } }catch (Exception e) { - if (this.oneCatalogFailsAllFail) - throw new CatalogException("Failed to determine if Catalog '" + catalog.getId() + "' is interested in query expression '" + queryExpression + "' : " + e.getMessage(), e); - else - LOG.log(Level.WARNING, "Failed to determine if Catalog '" + catalog.getId() + "' is interested in query expression '" + queryExpression + "' : " + e.getMessage(), e); + if (this.oneCatalogFailsAllFail) { + throw new CatalogException( + "Failed to determine if Catalog '" + catalog.getId() + "' is interested in query expression '" + + queryExpression + "' : " + e.getMessage(), e); + } else { + LOG.log(Level.WARNING, + "Failed to determine if Catalog '" + catalog.getId() + "' is interested in query expression '" + + queryExpression + "' : " + e.getMessage(), e); + } } } return interestedCatalogs; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/term/Term.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/term/Term.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/term/Term.java index eb89e49..8670f58 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/term/Term.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/term/Term.java @@ -100,8 +100,9 @@ public class Term implements Cloneable { public Term(String name, List<String> values, Type type) { this(name, values); - if (type != null) - this.type = type; + if (type != null) { + this.type = type; + } } public String getName() { @@ -122,8 +123,9 @@ public class Term implements Cloneable { public String getFirstValue() { String firstValue = null; - if (this.values.size() > 0) - firstValue = this.values.get(0); + if (this.values.size() > 0) { + firstValue = this.values.get(0); + } return firstValue; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/term/TermBucket.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/term/TermBucket.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/term/TermBucket.java index 4d3ed78..5947ba7 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/term/TermBucket.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/term/TermBucket.java @@ -54,8 +54,9 @@ public class TermBucket extends Bucket { public void setTerms(Set<Term> terms) { if (terms != null) { this.terms = new HashMap<String, Term>(); - for (Term term : terms) - this.terms.put(term.name, term); + for (Term term : terms) { + this.terms.put(term.name, term); + } } } @@ -65,8 +66,9 @@ public class TermBucket extends Bucket { public void addTerms(Set<Term> terms, boolean replace) { if (replace) { - for (Term term : terms) - this.terms.put(term.name, term); + for (Term term : terms) { + this.terms.put(term.name, term); + } }else { for (Term term : terms) { Term found = this.terms.get(term.name); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/util/CasPropertyPlaceholderConfigurer.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/CasPropertyPlaceholderConfigurer.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/CasPropertyPlaceholderConfigurer.java index 541cdc5..4686318 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/CasPropertyPlaceholderConfigurer.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/CasPropertyPlaceholderConfigurer.java @@ -42,10 +42,11 @@ public class CasPropertyPlaceholderConfigurer extends defaultValue = splitValue[1]; } String result = PathUtils.doDynamicReplacement(value); - if (result.equals("null")) - return defaultValue; - else - return result; + if (result.equals("null")) { + return defaultValue; + } else { + return result; + } } catch (Exception e) { e.printStackTrace(); return value; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/util/PluginClassLoader.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/PluginClassLoader.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/PluginClassLoader.java index c72f6fb..a2ffefd 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/PluginClassLoader.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/PluginClassLoader.java @@ -53,8 +53,9 @@ public class PluginClassLoader extends URLClassLoader { } protected void addURLs(List<URL> urls) { - for (URL url : urls) - this.addURL(url); + for (URL url : urls) { + this.addURL(url); + } } public static URL[] getPluginURLs() { @@ -85,8 +86,9 @@ public class PluginClassLoader extends URLClassLoader { public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { try { Class<?> clazz = this.findLoadedClass(name); - if (clazz == null) - clazz = this.findClass(name); + if (clazz == null) { + clazz = this.findClass(name); + } return clazz; }catch (Exception ignored) {} return super.loadClass(name, resolve); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/util/Serializer.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/Serializer.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/Serializer.java index c807b08..5b29db2 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/Serializer.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/Serializer.java @@ -43,10 +43,11 @@ public class Serializer { } public void refreshClassLoader() { - if (usePluginUrls) - this.classLoader = new PluginClassLoader(); - else - this.classLoader = Serializer.class.getClassLoader(); + if (usePluginUrls) { + this.classLoader = new PluginClassLoader(); + } else { + this.classLoader = Serializer.class.getClassLoader(); + } } public void setUsePluginUrls(boolean usePluginUrls) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/catalog/src/main/java/org/apache/oodt/cas/catalog/util/SpringUtils.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/SpringUtils.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/SpringUtils.java index f2d629d..3b1a149 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/util/SpringUtils.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/util/SpringUtils.java @@ -42,9 +42,10 @@ public class SpringUtils { for (String key : catalogsMap.keySet()) { Catalog curCatalog = catalogsMap.get(key); LOG.log(Level.INFO, "Loading catalog configuration for Catalog: '" + curCatalog + "'"); - if (catalogs.contains(curCatalog)) - throw new CatalogException("Catalog URN : '" + curCatalog + "' conflicts with another Catalog's URN. " - + "**NOTE: URNs are created based on the following rule: urn:<namespace>:<id or name (if set)>"); + if (catalogs.contains(curCatalog)) { + throw new CatalogException("Catalog URN : '" + curCatalog + "' conflicts with another Catalog's URN. " + + "**NOTE: URNs are created based on the following rule: urn:<namespace>:<id or name (if set)>"); + } catalogs.add(curCatalog); } return catalogs; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/cli/src/main/java/org/apache/oodt/cas/cli/option/SimpleCmdLineOption.java ---------------------------------------------------------------------- diff --git a/cli/src/main/java/org/apache/oodt/cas/cli/option/SimpleCmdLineOption.java b/cli/src/main/java/org/apache/oodt/cas/cli/option/SimpleCmdLineOption.java index 23bf8b0..2494c0d 100755 --- a/cli/src/main/java/org/apache/oodt/cas/cli/option/SimpleCmdLineOption.java +++ b/cli/src/main/java/org/apache/oodt/cas/cli/option/SimpleCmdLineOption.java @@ -171,8 +171,9 @@ public class SimpleCmdLineOption implements CmdLineOption { SimpleCmdLineOption compareObj = (SimpleCmdLineOption) obj; return compareObj.shortOption.equals(this.shortOption) || compareObj.longOption.equals(this.longOption); - } else + } else { return false; + } } @Override http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java ---------------------------------------------------------------------- diff --git a/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java b/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java index d9e0b02..87b8d8e 100755 --- a/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java +++ b/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java @@ -432,10 +432,12 @@ public class CmdLineUtils { Validate.notNull(optionName); Validate.notNull(optionInsts); - for (CmdLineOptionInstance optionInst : optionInsts) + for (CmdLineOptionInstance optionInst : optionInsts) { if (optionInst.getOption().getLongOption().equals(optionName) - || optionInst.getOption().getShortOption().equals(optionName)) + || optionInst.getOption().getShortOption().equals(optionName)) { return optionInst; + } + } return null; } @@ -1056,8 +1058,9 @@ public class CmdLineUtils { curLine.append(splitStrings[i]).append(" "); for (; i + 1 < splitStrings.length - && curLine.length() + splitStrings[i + 1].length() <= (endIndex - startIndex); i++) + && curLine.length() + splitStrings[i + 1].length() <= (endIndex - startIndex); i++) { curLine.append(splitStrings[i + 1]).append(" "); + } outputString.append(StringUtils.repeat(" ", startIndex)).append(curLine.toString()).append("\n"); } @@ -1069,23 +1072,27 @@ public class CmdLineUtils { InstantiationException, IllegalAccessException { if (type.equals(File.class)) { List<Object> files = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { files.add(new File(value)); + } return files; } else if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) { List<Object> booleans = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { booleans.add(value.toLowerCase().trim().equals("true")); + } return booleans; } else if (type.equals(URL.class)) { List<Object> urls = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { urls.add(new URL(value)); + } return urls; } else if (type.equals(Class.class)) { List<Object> classes = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { classes.add(Class.forName(value)); + } return classes; } else if (type.equals(List.class)) { List<Object> lists = new LinkedList<Object>(); @@ -1093,23 +1100,27 @@ public class CmdLineUtils { return lists; } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) { List<Object> ints = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { ints.add(Integer.valueOf(value)); + } return ints; } else if (type.equals(Long.class) || type.equals(Long.TYPE)) { List<Object> longs = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { longs.add(Long.valueOf(value)); + } return longs; } else if (type.equals(Double.class) || type.equals(Double.TYPE)) { List<Object> doubles = new LinkedList<Object>(); - for (String value : values) + for (String value : values) { doubles.add(new Double(value)); + } return doubles; } else if (type.equals(String.class)) { StringBuilder combinedString = new StringBuilder(""); - for (String value : values) + for (String value : values) { combinedString.append(value).append(" "); + } return Lists.newArrayList(combinedString.toString().trim()); } else { List<Object> objects = new LinkedList<Object>();
