You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2015/10/14 08:57:33 UTC
[3/5] oodt git commit: OODT-892 remove null assignments
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java
index 2d5ca1d..a5b92d1 100644
--- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java
+++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java
@@ -18,36 +18,22 @@
package org.apache.oodt.pcs.tools;
//JDK imports
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-//APACHE imports
-import org.apache.xmlrpc.XmlRpcClient;
-
-//OODT imports
-import org.apache.oodt.commons.date.DateUtils;
-import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.crawl.daemon.CrawlDaemonController;
import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys;
import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.resource.structs.ResourceNode;
-import org.apache.oodt.cas.crawl.daemon.CrawlDaemonController;
+import org.apache.oodt.commons.date.DateUtils;
+import org.apache.oodt.pcs.health.*;
import org.apache.oodt.pcs.util.FileManagerUtils;
import org.apache.oodt.pcs.util.ResourceManagerUtils;
import org.apache.oodt.pcs.util.WorkflowManagerUtils;
-import org.apache.oodt.pcs.health.CrawlInfo;
-import org.apache.oodt.pcs.health.CrawlPropertiesFile;
-import org.apache.oodt.pcs.health.CrawlerHealth;
-import org.apache.oodt.pcs.health.CrawlerStatus;
-import org.apache.oodt.pcs.health.JobHealthStatus;
-import org.apache.oodt.pcs.health.PCSDaemonStatus;
-import org.apache.oodt.pcs.health.PCSHealthMonitorMetKeys;
-import org.apache.oodt.pcs.health.PCSHealthMonitorReport;
-import org.apache.oodt.pcs.health.WorkflowStatesFile;
+import org.apache.xmlrpc.XmlRpcClient;
+
+import java.util.*;
+
+//APACHE imports
+//OODT imports
/**
*
@@ -345,10 +331,10 @@ public final class PCSHealthMonitor implements CoreMetKeys,
List statuses = new Vector();
- for (Iterator i = this.crawlProps.getCrawlers().iterator(); i.hasNext();) {
- CrawlInfo info = (CrawlInfo) i.next();
+ for (Object o : this.crawlProps.getCrawlers()) {
+ CrawlInfo info = (CrawlInfo) o;
String crawlUrlStr = "http://" + this.crawlProps.getCrawlHost() + ":"
- + info.getCrawlerPort();
+ + info.getCrawlerPort();
try {
CrawlDaemonController controller = new CrawlDaemonController(
crawlUrlStr);
@@ -375,8 +361,8 @@ public final class PCSHealthMonitor implements CoreMetKeys,
private void printIngestStatusHealth(PCSHealthMonitorReport report) {
if (report.getCrawlerHealthStatus() != null
&& report.getCrawlerHealthStatus().size() > 0) {
- for (Iterator i = report.getCrawlerHealthStatus().iterator(); i.hasNext();) {
- CrawlerHealth health = (CrawlerHealth) i.next();
+ for (Object o : report.getCrawlerHealthStatus()) {
+ CrawlerHealth health = (CrawlerHealth) o;
System.out.print(health.getCrawlerName() + ":");
if (health.getNumCrawls() == CRAWLER_DOWN_INT) {
System.out.println(" DOWN");
@@ -384,7 +370,7 @@ public final class PCSHealthMonitor implements CoreMetKeys,
System.out.println("");
System.out.println("Number of Crawls: " + health.getNumCrawls());
System.out.println("Average Crawl Time (seconds): "
- + health.getAvgCrawlTime());
+ + health.getAvgCrawlTime());
System.out.println("");
}
@@ -408,15 +394,14 @@ public final class PCSHealthMonitor implements CoreMetKeys,
if (report.getLatestProductsIngested() != null
&& report.getLatestProductsIngested().size() > 0) {
System.out.println("Latest " + TOP_N_PRODUCTS + " products ingested:");
- for (Iterator i = report.getLatestProductsIngested().iterator(); i
- .hasNext();) {
- Product p = (Product) i.next();
+ for (Object o : report.getLatestProductsIngested()) {
+ Product p = (Product) o;
p.setProductType(fm.safeGetProductTypeById(p.getProductType()
- .getProductTypeId()));
+ .getProductTypeId()));
p.setProductReferences(fm.safeGetProductReferences(p));
Metadata prodMet = fm.safeGetMetadata(p);
System.out.println(fm.getFilePath(p) + " at: "
- + prodMet.getMetadata("CAS." + PRODUCT_RECEVIED_TIME));
+ + prodMet.getMetadata("CAS." + PRODUCT_RECEVIED_TIME));
}
}
@@ -440,17 +425,17 @@ public final class PCSHealthMonitor implements CoreMetKeys,
List crawlers = this.crawlProps.getCrawlers();
String biggestString = getBiggestString(crawlers);
- for (Iterator i = report.getCrawlerStatus().iterator(); i.hasNext();) {
- CrawlerStatus status = (CrawlerStatus) i.next();
+ for (Object o : report.getCrawlerStatus()) {
+ CrawlerStatus status = (CrawlerStatus) o;
String crawlerUrlStr = "http://" + status.getCrawlHost() + ":"
- + status.getInfo().getCrawlerPort();
+ + status.getInfo().getCrawlerPort();
System.out.println(getStrPadding(status.getInfo().getCrawlerName(),
biggestString)
- + status.getInfo().getCrawlerName()
- + ": ["
- + crawlerUrlStr
- + "]: "
- + status.getStatus());
+ + status.getInfo().getCrawlerName()
+ + ": ["
+ + crawlerUrlStr
+ + "]: "
+ + status.getStatus());
}
}
@@ -473,13 +458,13 @@ public final class PCSHealthMonitor implements CoreMetKeys,
});
String biggestString = getBiggestString(crawlers);
- for (Iterator i = crawlers.iterator(); i.hasNext();) {
- CrawlInfo info = (CrawlInfo) i.next();
+ for (Object crawler : crawlers) {
+ CrawlInfo info = (CrawlInfo) crawler;
String crawlerUrlStr = "http://" + crawlHost + ":"
- + info.getCrawlerPort();
+ + info.getCrawlerPort();
System.out.println(getStrPadding(info.getCrawlerName(), biggestString)
- + info.getCrawlerName() + ": [" + crawlerUrlStr + "]: "
- + printUp(getCrawlerUp(crawlerUrlStr)));
+ + info.getCrawlerName() + ": [" + crawlerUrlStr + "]: "
+ + printUp(getCrawlerUp(crawlerUrlStr)));
}
}
@@ -493,10 +478,10 @@ public final class PCSHealthMonitor implements CoreMetKeys,
resNodes = rm.safeGetResourceNodes();
if (resNodes != null && resNodes.size() > 0) {
- for (Iterator i = resNodes.iterator(); i.hasNext();) {
- ResourceNode node = (ResourceNode) i.next();
+ for (Object resNode : resNodes) {
+ ResourceNode node = (ResourceNode) resNode;
System.out.println("> " + BATCH_STUB_DAEMON_NAME + ": ["
- + node.getIpAddr() + "]: " + printUp(getBatchStubUp(node)));
+ + node.getIpAddr() + "]: " + printUp(getBatchStubUp(node)));
}
}
}
@@ -510,8 +495,8 @@ public final class PCSHealthMonitor implements CoreMetKeys,
List states = this.statesFile.getStates();
if (states != null && states.size() > 0) {
- for (Iterator i = states.iterator(); i.hasNext();) {
- String state = (String) i.next();
+ for (Object state1 : states) {
+ String state = (String) state1;
int numPipelines = this.wm.safeGetNumWorkflowInstancesByStatus(state);
if (numPipelines == -1) {
numPipelines = 0;
@@ -529,14 +514,14 @@ public final class PCSHealthMonitor implements CoreMetKeys,
List prods = this.fm.safeGetTopNProducts(TOP_N_PRODUCTS);
if (prods != null && prods.size() > 0) {
- for (Iterator i = prods.iterator(); i.hasNext();) {
- Product p = (Product) i.next();
+ for (Object prod : prods) {
+ Product p = (Product) prod;
p.setProductType(fm.safeGetProductTypeById(p.getProductType()
- .getProductTypeId()));
+ .getProductTypeId()));
p.setProductReferences(fm.safeGetProductReferences(p));
Metadata prodMet = fm.safeGetMetadata(p);
System.out.println(fm.getFilePath(p) + " at: "
- + prodMet.getMetadata("CAS." + PRODUCT_RECEVIED_TIME));
+ + prodMet.getMetadata("CAS." + PRODUCT_RECEVIED_TIME));
}
}
@@ -572,8 +557,8 @@ public final class PCSHealthMonitor implements CoreMetKeys,
int biggestStrSz = Integer.MIN_VALUE;
String biggestStr = null;
- for (Iterator i = crawlInfos.iterator(); i.hasNext();) {
- CrawlInfo info = (CrawlInfo) i.next();
+ for (Object crawlInfo : crawlInfos) {
+ CrawlInfo info = (CrawlInfo) crawlInfo;
String crawlInfoName = info.getCrawlerName();
if (crawlInfoName.length() > biggestStrSz) {
biggestStr = crawlInfoName;
@@ -589,7 +574,7 @@ public final class PCSHealthMonitor implements CoreMetKeys,
int sizeCompareStr = compareString.length();
int diff = Math.abs(sizeInitStr - sizeCompareStr);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < diff; i++) {
buf.append(" ");
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java
----------------------------------------------------------------------
diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java
index 74eabd2..4d7e53b 100644
--- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java
+++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSLongLister.java
@@ -70,7 +70,7 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys {
// (this is true in the case of someone using */* from
// a shell): if it does, we'll consider the prodName a
// path, and we'll clean it using new File(prodName).getName()
- if (prodName.indexOf("/") != -1) {
+ if (prodName.contains("/")) {
// clean the prodName
prodName = new File(prodName).getName();
}
@@ -116,7 +116,7 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys {
}
private String getToolHeader() {
- StringBuffer header = new StringBuffer();
+ StringBuilder header = new StringBuilder();
for (String colName : this.conf.getHeaderColKeys()) {
header.append(this.conf.getHeaderColDisplayName(colName));
header.append("\t");
@@ -125,7 +125,7 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys {
}
private void outputListingLine(Metadata met, String prodName) {
- StringBuffer output = new StringBuffer();
+ StringBuilder output = new StringBuilder();
for (String colNameKey : this.conf.getHeaderColKeys()) {
if (!this.conf.isCollectionField(colNameKey)) {
output.append(met.getMetadata(colNameKey));
@@ -140,13 +140,13 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys {
}
private static String outputOrBlank(List items) {
- if (items == null || (items != null && items.size() == 0)) {
+ if (items == null || (items.size() == 0)) {
return "N/A";
}
- StringBuffer buf = new StringBuffer();
- for (Iterator i = items.iterator(); i.hasNext();) {
- String item = (String) i.next();
+ StringBuilder buf = new StringBuilder();
+ for (Object item1 : items) {
+ String item = (String) item1;
buf.append(item);
buf.append(",");
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/core/src/main/java/org/apache/oodt/pcs/util/FileManagerUtils.java
----------------------------------------------------------------------
diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/util/FileManagerUtils.java b/pcs/core/src/main/java/org/apache/oodt/pcs/util/FileManagerUtils.java
index c19f819..d084e7f 100644
--- a/pcs/core/src/main/java/org/apache/oodt/pcs/util/FileManagerUtils.java
+++ b/pcs/core/src/main/java/org/apache/oodt/pcs/util/FileManagerUtils.java
@@ -182,14 +182,14 @@ public class FileManagerUtils implements PCSConfigMetadata {
public List queryAndReturnMetadata(Query query, ProductType type) {
List prods = safeIssueQuery(query, type);
- if (prods == null || (prods != null && prods.size() == 0)) {
+ if (prods == null || (prods.size() == 0)) {
return new Vector();
}
List prodsMet = new Vector(prods.size());
- for (Iterator i = prods.iterator(); i.hasNext();) {
- Product p = (Product) i.next();
+ for (Object prod : prods) {
+ Product p = (Product) prod;
prodsMet.add(safeGetMetadata(p));
}
@@ -342,13 +342,13 @@ public class FileManagerUtils implements PCSConfigMetadata {
}
public static List toProductNameList(List productList) {
- if (productList == null || (productList != null && productList.size() == 0)) {
+ if (productList == null || (productList.size() == 0)) {
return new Vector();
}
List prodNames = new Vector(productList.size());
- for (Iterator i = productList.iterator(); i.hasNext();) {
- Product p = (Product) i.next();
+ for (Object aProductList : productList) {
+ Product p = (Product) aProductList;
prodNames.add(p.getProductName());
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileReader.java
----------------------------------------------------------------------
diff --git a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileReader.java b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileReader.java
index 4759c9e..d87d983 100644
--- a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileReader.java
+++ b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileReader.java
@@ -16,17 +16,19 @@
package org.apache.oodt.pcs.input;
//JDK imports
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
/**
*
@@ -226,7 +228,7 @@ public class PGEConfigFileReader {
List scalars = PGEXMLFileUtils.getScalars(group);
// the list should be size 1
- if (scalars == null || (scalars != null && scalars.size() != 1)) {
+ if (scalars == null || (scalars.size() != 1)) {
throw new PGEConfigFileException(
"There is no product path defined in the configuration file, or there is more than one scalar listed in the ProductPathGroup!");
}
@@ -250,7 +252,7 @@ public class PGEConfigFileReader {
List scalars = PGEXMLFileUtils.getScalars(group);
// the list should be size 1
- if (scalars == null || (scalars != null && scalars.size() != 1)) {
+ if (scalars == null || (scalars.size() != 1)) {
throw new PGEConfigFileException(
"There is no PGEName defined in the configuration file, or there is more than one scalar listed in the PGENameGroup");
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileWriter.java
----------------------------------------------------------------------
diff --git a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileWriter.java b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileWriter.java
index f989f46..0ae1162 100644
--- a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileWriter.java
+++ b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEConfigFileWriter.java
@@ -16,19 +16,21 @@
package org.apache.oodt.pcs.input;
import org.apache.oodt.commons.xml.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
-//JDK imports
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+
+//JDK imports
/**
* <p>
@@ -108,8 +110,7 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys,
root
.setAttribute(
"xsi:noNamespaceSchemaLocation",
- (schemaLocation == null
- || (schemaLocation != null && schemaLocation.equals("")) ? "input.xsd"
+ (schemaLocation == null || (schemaLocation.equals("")) ? "input.xsd"
: schemaLocation));
document.appendChild(root);
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEXMLFileUtils.java
----------------------------------------------------------------------
diff --git a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEXMLFileUtils.java b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEXMLFileUtils.java
index ab2cdb1..815f63f 100644
--- a/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEXMLFileUtils.java
+++ b/pcs/input/src/main/java/org/apache/oodt/pcs/input/PGEXMLFileUtils.java
@@ -17,8 +17,11 @@ package org.apache.oodt.pcs.input;
//OODT imports
import org.apache.oodt.commons.xml.DOMUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
-//JDK imports
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -28,12 +31,11 @@ import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
+
+//JDK imports
/**
* <p>
@@ -91,8 +93,7 @@ public final class PGEXMLFileUtils {
NodeList colNodeList = rowElem.getElementsByTagName("td");
// there must be at least one colum in each row
- if (colNodeList == null
- || (colNodeList != null && colNodeList.getLength() <= 0)) {
+ if (colNodeList == null || (colNodeList.getLength() <= 0)) {
throw new PGEConfigFileException(
"there must be at least one column a matrix row!");
}
@@ -141,8 +142,7 @@ public final class PGEXMLFileUtils {
NodeList rowNodeList = matrix.getElementsByTagName("tr");
// there has to be at least one 1
- if (rowNodeList == null
- || (rowNodeList != null && rowNodeList.getLength() <= 0)) {
+ if (rowNodeList == null || (rowNodeList.getLength() <= 0)) {
throw new PGEConfigFileException(
"there must be at least one row in a matrix!");
}
@@ -157,8 +157,7 @@ public final class PGEXMLFileUtils {
NodeList colNodeList = rowElem.getElementsByTagName("td");
// there must be at least one colum in each row
- if (colNodeList == null
- || (colNodeList != null && colNodeList.getLength() <= 0)) {
+ if (colNodeList == null || (colNodeList.getLength() <= 0)) {
throw new PGEConfigFileException(
"there must be at least one column a matrix row!");
}
@@ -267,7 +266,7 @@ public final class PGEXMLFileUtils {
// get the nodelist of elements
NodeList vecElems = vector.getElementsByTagName("element");
- if (vecElems == null || (vecElems != null && vecElems.getLength() <= 0)) {
+ if (vecElems == null || (vecElems.getLength() <= 0)) {
throw new PGEConfigFileException(
"There must be at least one element in a PGEVector!");
}
@@ -311,7 +310,7 @@ public final class PGEXMLFileUtils {
// get the nodelist of elements
NodeList vecElems = vector.getElementsByTagName("element");
- if (vecElems == null || (vecElems != null && vecElems.getLength() <= 0)) {
+ if (vecElems == null || (vecElems.getLength() <= 0)) {
throw new PGEConfigFileException(
"There must be at least one element in a PGEVector!");
}
@@ -332,12 +331,12 @@ public final class PGEXMLFileUtils {
public static Document getDocumentRoot(String xmlFile) {
// open up the XML file
- DocumentBuilderFactory factory = null;
- DocumentBuilder parser = null;
- Document document = null;
- InputSource inputSource = null;
+ DocumentBuilderFactory factory;
+ DocumentBuilder parser;
+ Document document;
+ InputSource inputSource;
- InputStream xmlInputStream = null;
+ InputStream xmlInputStream;
try {
xmlInputStream = new File(xmlFile).toURL().openStream();
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java
----------------------------------------------------------------------
diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java
index 649dcbd..c2dd506 100644
--- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java
+++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java
@@ -19,6 +19,8 @@
package org.apache.oodt.product.handlers.ofsn;
//JDK imports
+import org.apache.oodt.product.ProductException;
+
import java.io.File;
import java.io.FileFilter;
import java.util.List;
@@ -29,7 +31,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
//OODT imports
-import org.apache.oodt.product.ProductException;
/**
*
@@ -84,7 +85,7 @@ public abstract class AbstractCrawlLister implements OFSNListHandler {
protected File[] crawlFiles(File dirRoot, boolean recur,
boolean crawlForDirs) {
- if (dirRoot == null || ((dirRoot != null && !dirRoot.exists())))
+ if (dirRoot == null || ((!dirRoot.exists())))
throw new IllegalArgumentException("dir root: [" + dirRoot
+ "] is null or non existant!");
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java
----------------------------------------------------------------------
diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java
index 1ffd1f7..484d5f3 100644
--- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java
+++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java
@@ -19,6 +19,21 @@
package org.apache.oodt.product.handlers.ofsn;
//JDK imports
+import org.apache.oodt.commons.xml.XMLUtils;
+import org.apache.oodt.product.LargeProductQueryHandler;
+import org.apache.oodt.product.ProductException;
+import org.apache.oodt.product.handlers.ofsn.metadata.OFSNMetKeys;
+import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLConfigMetKeys;
+import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLMetKeys;
+import org.apache.oodt.product.handlers.ofsn.metadata.XMLQueryMetKeys;
+import org.apache.oodt.product.handlers.ofsn.util.OFSNObjectFactory;
+import org.apache.oodt.product.handlers.ofsn.util.OFSNUtils;
+import org.apache.oodt.xmlquery.LargeResult;
+import org.apache.oodt.xmlquery.Result;
+import org.apache.oodt.xmlquery.XMLQuery;
+import org.apache.tika.mime.MediaType;
+import org.apache.tika.mime.MimeTypesFactory;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,22 +46,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
//APACHE imports
-import org.apache.tika.mime.MediaType;
-import org.apache.tika.mime.MimeTypesFactory;
-
//OODT imports
-import org.apache.oodt.commons.xml.XMLUtils;
-import org.apache.oodt.product.handlers.ofsn.metadata.OFSNMetKeys;
-import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLConfigMetKeys;
-import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLMetKeys;
-import org.apache.oodt.product.handlers.ofsn.metadata.XMLQueryMetKeys;
-import org.apache.oodt.product.handlers.ofsn.util.OFSNObjectFactory;
-import org.apache.oodt.product.handlers.ofsn.util.OFSNUtils;
-import org.apache.oodt.product.LargeProductQueryHandler;
-import org.apache.oodt.product.ProductException;
-import org.apache.oodt.xmlquery.LargeResult;
-import org.apache.oodt.xmlquery.Result;
-import org.apache.oodt.xmlquery.XMLQuery;
/**
*
@@ -203,8 +203,7 @@ public class OFSNFileHandler implements LargeProductQueryHandler,
}
private void validate(String ofsn, String cmd) throws ProductException {
- if (ofsn == null || cmd == null || (ofsn != null && ofsn.equals(""))
- || (cmd != null && cmd.equals(""))) {
+ if (ofsn == null || cmd == null || (ofsn.equals("")) || (cmd.equals(""))) {
throw new ProductException("must specify OFSN and RT parameters!");
} else if (!OFSNUtils.validateOFSN(ofsn)) {
throw new ProductException("OFSN is invalid");
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/profile/src/main/java/org/apache/oodt/profile/handlers/cas/CASProfileHandler.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/cas/CASProfileHandler.java b/profile/src/main/java/org/apache/oodt/profile/handlers/cas/CASProfileHandler.java
index 1a3c4d5..ceb9baa 100644
--- a/profile/src/main/java/org/apache/oodt/profile/handlers/cas/CASProfileHandler.java
+++ b/profile/src/main/java/org/apache/oodt/profile/handlers/cas/CASProfileHandler.java
@@ -19,16 +19,16 @@
package org.apache.oodt.profile.handlers.cas;
//CAS imports
-import org.apache.oodt.cas.filemgr.structs.Element;
-import org.apache.oodt.cas.filemgr.structs.Product;
-import org.apache.oodt.cas.filemgr.structs.ProductType;
-import org.apache.oodt.cas.filemgr.structs.Query;
-import org.apache.oodt.cas.filemgr.structs.TermQueryCriteria;
+import org.apache.oodt.cas.filemgr.structs.*;
import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.profile.Profile;
+import org.apache.oodt.profile.ProfileException;
+import org.apache.oodt.profile.handlers.ProfileHandler;
import org.apache.oodt.profile.handlers.cas.util.ProfileUtils;
+import org.apache.oodt.xmlquery.QueryElement;
+import org.apache.oodt.xmlquery.XMLQuery;
-//JDK imports
import java.net.URL;
import java.util.Iterator;
import java.util.List;
@@ -36,12 +36,8 @@ import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
+//JDK imports
//OODT imports
-import org.apache.oodt.profile.Profile;
-import org.apache.oodt.profile.ProfileException;
-import org.apache.oodt.profile.handlers.ProfileHandler;
-import org.apache.oodt.xmlquery.QueryElement;
-import org.apache.oodt.xmlquery.XMLQuery;
/**
* @author mattmann
@@ -212,16 +208,9 @@ public class CASProfileHandler implements ProfileHandler {
// split the string on ","
String[] typeNames = productTypeNames.split(",");
- if (typeNames != null) {
- for (int i = 0; i < typeNames.length; i++) {
- ProductType type = safeGetProductTypeByName(typeNames[i]);
- typeFilter.add(type);
- }
- } else {
- LOG.log(Level.WARNING,
- "Unable to parse comma delimited type string: ["
- + productTypeNames + "]: using all types");
- typeFilter = safeGetProductTypes();
+ for (String typeName : typeNames) {
+ ProductType type = safeGetProductTypeByName(typeName);
+ typeFilter.add(type);
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java
----------------------------------------------------------------------
diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java
index d96ad09..797a1da 100644
--- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java
+++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/SiteInfo.java
@@ -87,7 +87,7 @@ public class SiteInfo {
}
}
if (remoteSites.size() == 0) {
- if (url != null && username != null && password != null)
+ if (username != null && password != null)
remoteSites.add(new RemoteSite(url.toString(), url,
username, password));
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
----------------------------------------------------------------------
diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
index 63e5a6a..d2c02ca 100644
--- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
+++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
@@ -21,17 +21,20 @@ package org.apache.oodt.cas.pushpull.filerestrictions.parsers;
//OODT imports
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.metadata.util.PathUtils;
-import org.apache.oodt.cas.pushpull.filerestrictions.Parser;
-import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFile;
-import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFileStructure;
import org.apache.oodt.cas.pushpull.exceptions.ParserException;
import org.apache.oodt.cas.pushpull.expressions.GlobalVariables;
import org.apache.oodt.cas.pushpull.expressions.Method;
import org.apache.oodt.cas.pushpull.expressions.Variable;
+import org.apache.oodt.cas.pushpull.filerestrictions.Parser;
+import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFile;
+import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFileStructure;
import org.apache.oodt.commons.xml.XMLUtils;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
-
-//JDK imports
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.StringTokenizer;
@@ -40,11 +43,7 @@ import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
+//JDK imports
/**
*
@@ -72,7 +71,7 @@ public class DirStructXmlParser implements Parser {
NodeList list = (DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(new InputSource(xmlFile)))
.getDocumentElement().getChildNodes();
- VirtualFile currentFile = null;
+ VirtualFile currentFile;
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeName().equals("dirstruct")) {
@@ -144,7 +143,7 @@ public class DirStructXmlParser implements Parser {
case '$':
try {
if (input.charAt(i + 1) == '{') {
- StringBuffer variable = new StringBuffer("");
+ StringBuilder variable = new StringBuilder("");
for (int j = i + 2; j < input.length(); j++) {
char ch = input.charAt(j);
if ((ch <= 'Z' && ch >= 'A')
@@ -168,7 +167,7 @@ public class DirStructXmlParser implements Parser {
break;
case '%':
try {
- StringBuffer method = new StringBuffer("");
+ StringBuilder method = new StringBuilder("");
int j = i + 1;
for (; j < input.length(); j++) {
char ch = input.substring(j, j + 1).charAt(0);
@@ -201,7 +200,7 @@ public class DirStructXmlParser implements Parser {
+ input + " near " + method);
break;
}
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
break;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/filemgr/browser/metadata/MetadataBrowser.java
----------------------------------------------------------------------
diff --git a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/filemgr/browser/metadata/MetadataBrowser.java b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/filemgr/browser/metadata/MetadataBrowser.java
index 58f993f..668fbfc 100644
--- a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/filemgr/browser/metadata/MetadataBrowser.java
+++ b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/filemgr/browser/metadata/MetadataBrowser.java
@@ -54,56 +54,52 @@ public class MetadataBrowser extends Panel {
.getMetadata(this.fm.safeGetProductById(productId)));
setDefaultModel(new Model(met));
- if (met != null) {
- add(new Label("no_prod_met_display") {
- /*
- * (non-Javadoc)
- *
- * @see org.apache.wicket.Component#isVisible()
- */
- @Override
- public boolean isVisible() {
- return false;
- }
- });
+ add(new Label("no_prod_met_display") {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.wicket.Component#isVisible()
+ */
+ @Override
+ public boolean isVisible() {
+ return false;
+ }
+ });
- List<String> metKeys = met.getAllKeys();
- Collections.sort(metKeys);
+ List<String> metKeys = met.getAllKeys();
+ Collections.sort(metKeys);
- add(new ListView<String>("met_elem", new ListModel<String>(metKeys)) {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache
- * .wicket.markup.html.list.ListItem)
- */
- @Override
- protected void populateItem(ListItem<String> item) {
- item.add(new Label("met_elem_name", item.getModelObject()));
+ add(new ListView<String>("met_elem", new ListModel<String>(metKeys)) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache
+ * .wicket.markup.html.list.ListItem)
+ */
+ @Override
+ protected void populateItem(ListItem<String> item) {
+ item.add(new Label("met_elem_name", item.getModelObject()));
- item
- .add(new ListView<String>("met_values_list",
- new ListModel<String>(met.getAllMetadata(item
- .getModelObject()))) {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.wicket.markup.html.list.ListView#populateItem(
- * org.apache.wicket.markup.html.list.ListItem)
- */
- @Override
- protected void populateItem(ListItem<String> item) {
- item.add(new Label("met_value", item.getModelObject()));
- }
- });
+ item
+ .add(new ListView<String>("met_values_list",
+ new ListModel<String>(met.getAllMetadata(item
+ .getModelObject()))) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.wicket.markup.html.list.ListView#populateItem(
+ * org.apache.wicket.markup.html.list.ListItem)
+ */
+ @Override
+ protected void populateItem(ListItem<String> item) {
+ item.add(new Label("met_value", item.getModelObject()));
+ }
+ });
- }
- });
- } else {
- add(new Label("no_prod_met_display", "No Product Metadata!"));
- }
+ }
+ });
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/CASProductHandler.java
----------------------------------------------------------------------
diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/CASProductHandler.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/CASProductHandler.java
index 12d3ad9..edcdd19 100644
--- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/CASProductHandler.java
+++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/CASProductHandler.java
@@ -19,18 +19,6 @@
package org.apache.oodt.cas.product;
//JDK imports
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Collections;
-import java.util.Iterator;
-
-//OODT imports
import org.apache.oodt.cas.filemgr.structs.Product;
import org.apache.oodt.cas.filemgr.structs.Reference;
import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException;
@@ -42,8 +30,18 @@ import org.apache.oodt.product.ProductException;
import org.apache.oodt.xmlquery.Header;
import org.apache.oodt.xmlquery.LargeResult;
import org.apache.oodt.xmlquery.XMLQuery;
-import static org.apache.oodt.cas.filemgr.metadata.CoreMetKeys.*;
-import static org.apache.oodt.cas.product.CASProductHandlerMetKeys.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.*;
+import java.util.Collections;
+
+import static org.apache.oodt.cas.filemgr.metadata.CoreMetKeys.PRODUCT_ID;
+import static org.apache.oodt.cas.product.CASProductHandlerMetKeys.CAS_PROFILE_ID;
+import static org.apache.oodt.cas.product.CASProductHandlerMetKeys.FILE_HEADER;
+
+//OODT imports
/**
* @author mattmann
@@ -72,8 +70,7 @@ public class CASProductHandler implements LargeProductQueryHandler {
// we'll only accept queries for ProductId=some_id
String kwdQuery = query.getKwdQueryString();
String[] kwdQueryToks = kwdQuery.split("=");
- if (kwdQueryToks == null
- || (kwdQueryToks != null && kwdQueryToks.length != 2)) {
+ if ((kwdQueryToks.length != 2)) {
throw new ProductException(
"Malformed query: CASProductHandler only accepts queries of the "
+ "form " + PRODUCT_ID
@@ -82,7 +79,7 @@ public class CASProductHandler implements LargeProductQueryHandler {
}
String prodId = kwdQueryToks[1];
- Product product = null;
+ Product product;
try {
product = this.fm.getProductById(prodId);
product.setProductReferences(this.fm.getProductReferences(product));
@@ -173,11 +170,9 @@ public class CASProductHandler implements LargeProductQueryHandler {
if (product != null && product.getProductReferences() != null
&& product.getProductReferences().size() > 0) {
- for (Iterator<Reference> i = product.getProductReferences()
- .iterator(); i.hasNext();) {
- Reference r = i.next();
- query.getResults().add(toResult(r));
- }
+ for (Reference r : product.getProductReferences()) {
+ query.getResults().add(toResult(r));
+ }
}
}
@@ -185,12 +180,11 @@ public class CASProductHandler implements LargeProductQueryHandler {
private LargeResult toResult(Reference r) throws URISyntaxException {
String mimeType = r.getMimeType() != null ? r.getMimeType().getName()
: DataUtils.guessTypeFromName(r.getDataStoreReference());
- LargeResult result = new LargeResult(r.getDataStoreReference(),
- mimeType, CAS_PROFILE_ID, new File(new URI(r
- .getDataStoreReference())).getName(),
- Collections.singletonList(new Header(FILE_HEADER, mimeType,
- null /* unit */)), r.getFileSize());
- return result;
+ return new LargeResult(r.getDataStoreReference(),
+ mimeType, CAS_PROFILE_ID, new File(new URI(r
+ .getDataStoreReference())).getName(),
+ Collections.singletonList(new Header(FILE_HEADER, mimeType,
+ null /* unit */)), r.getFileSize());
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java
----------------------------------------------------------------------
diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java
index c0c08fc..20148dc 100644
--- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java
+++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java
@@ -27,25 +27,22 @@ import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.metadata.util.PathUtils;
-//JDK imports
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+//JDK imports
+
/**
* Delivers back entire {@link ProductType}s (or <code>Dataset</code>s) as
* zipped up packages.
@@ -105,7 +102,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements
throws ServletException, IOException {
String typeID = req.getParameter("typeID");
- ProductType type = null;
+ ProductType type;
if (typeID == null) {
throw new IllegalArgumentException("No typeID parameter specified!");
@@ -134,10 +131,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements
try {
page = client.getFirstPage(type);
- if (page == null
- || (page != null && page.getPageProducts() == null)
- || (page != null && page.getPageProducts() != null && page
- .getPageProducts().size() == 0)) {
+ if (page == null || (page.getPageProducts() == null) || (page.getPageProducts().size() == 0)) {
throw new ServletException("No products for dataset: ["
+ type.getName() + "]");
}
@@ -145,8 +139,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements
Map productHash = new HashMap();
do {
- for (Iterator i = page.getPageProducts().iterator(); i.hasNext();) {
- Product product = (Product) i.next();
+ for (Product product : page.getPageProducts()) {
if (alreadyZipped(product, productHash)) {
continue;
}
@@ -169,7 +162,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements
// now that all product zips have been created, create the dataset
// zip
- String datasetZipFilePath = null;
+ String datasetZipFilePath;
File datasetZipFile = null;
InputStream in = null;
OutputStream o2 = null;
@@ -215,7 +208,6 @@ public class DatasetDeliveryServlet extends HttpServlet implements
} catch (Exception ignore) {
}
- in = null;
}
if (o2 != null) {
@@ -224,7 +216,6 @@ public class DatasetDeliveryServlet extends HttpServlet implements
} catch (Exception ignore) {
}
- o2 = null;
}
// now try and remove the tmp working directory for the
@@ -232,7 +223,6 @@ public class DatasetDeliveryServlet extends HttpServlet implements
if (datasetZipFile != null) {
datasetZipFile.getParentFile().delete();
}
- datasetZipFile = null;
}
}
@@ -246,15 +236,13 @@ public class DatasetDeliveryServlet extends HttpServlet implements
super.init(config);
try {
- String fileMgrURL = null;
+ String fileMgrURL;
try {
fileMgrURL = PathUtils.replaceEnvVariables(config.getServletContext().getInitParameter(
"filemgr.url") );
} catch (Exception e) {
throw new ServletException("Failed to get filemgr url : " + e.getMessage(), e);
- }
- if (fileMgrURL == null)
- fileMgrURL = "http://localhost:9000";
+ }
client = new XmlRpcFileManagerClient(new URL(fileMgrURL));
} catch (MalformedURLException ex) {
throw new ServletException(ex);
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskRunner.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskRunner.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskRunner.java
index d35cebd..5ba6565 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskRunner.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskRunner.java
@@ -78,7 +78,7 @@ public class TaskRunner implements Runnable {
*/
@Override
public void run() {
- TaskProcessor nextTaskProcessor = null;
+ TaskProcessor nextTaskProcessor;
while (running) {
nextTaskProcessor = taskQuerier.getNext();
@@ -93,9 +93,7 @@ public class TaskRunner implements Runnable {
Level.SEVERE,
"Engine failed while submitting jobs to its runner : "
+ e.getMessage(), e);
- if (nextTaskProcessor != null) {
- this.flagProcessorAsFailed(nextTaskProcessor, e.getMessage());
- }
+ this.flagProcessorAsFailed(nextTaskProcessor, e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
index e220628..0cbffd0 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepository.java
@@ -719,7 +719,7 @@ public class DataSourceWorkflowInstanceRepository extends
List wInstIds = null;
int numResults = -1;
- if (status == null || (status != null && status.equals(""))) {
+ if (status == null || (status.equals(""))) {
numResults = getNumWorkflowInstances();
} else {
numResults = getNumWorkflowInstancesByStatus(status);
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepository.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepository.java
index 7a60559..f16755d 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepository.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/DataSourceWorkflowRepository.java
@@ -18,25 +18,23 @@
package org.apache.oodt.cas.workflow.repository;
//OODT imports
-import org.apache.oodt.cas.workflow.util.DbStructFactory;
import org.apache.oodt.cas.workflow.examples.NoOpTask;
-import org.apache.oodt.cas.workflow.structs.Workflow;
-import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration;
-import org.apache.oodt.cas.workflow.structs.WorkflowTask;
-import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
-import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.*;
import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException;
+import org.apache.oodt.cas.workflow.util.DbStructFactory;
-//JDK imports
-import java.util.List;
-import java.util.Vector;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.List;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.sql.DataSource;
+
+//JDK imports
/**
*
@@ -1731,7 +1729,7 @@ public class DataSourceWorkflowRepository implements WorkflowRepository {
}
private boolean hasTaskId(List<WorkflowTask> tasks, String id) {
- if (tasks == null || (tasks != null && tasks.size() == 0))
+ if (tasks == null || (tasks.size() == 0))
return false;
for (WorkflowTask task : tasks) {
@@ -1744,7 +1742,7 @@ public class DataSourceWorkflowRepository implements WorkflowRepository {
}
private boolean hasConditionId(List<WorkflowCondition> conds, String id) {
- if (conds == null || (conds != null && conds.size() == 0))
+ if (conds == null || (conds.size() == 0))
return false;
for (WorkflowCondition cond : conds) {
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
index 35acebe..dd90b60 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
@@ -20,38 +20,21 @@ package org.apache.oodt.cas.workflow.repository;
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.workflow.examples.BranchRedirector;
import org.apache.oodt.cas.workflow.examples.NoOpTask;
-import org.apache.oodt.cas.workflow.structs.Graph;
-import org.apache.oodt.cas.workflow.structs.ParentChildWorkflow;
-import org.apache.oodt.cas.workflow.structs.Workflow;
-import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
-import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration;
-import org.apache.oodt.cas.workflow.structs.WorkflowTask;
-import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
+import org.apache.oodt.cas.workflow.structs.*;
import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException;
import org.apache.oodt.cas.workflow.util.XmlStructFactory;
import org.apache.oodt.commons.xml.XMLUtils;
+import org.w3c.dom.*;
-
-//JDK imports
import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.Vector;
+import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+//JDK imports
/**
*
@@ -300,8 +283,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
@Override
public String addWorkflow(Workflow workflow) throws RepositoryException {
// first check to see that its tasks are all present
- if (workflow.getTasks() == null
- || (workflow.getTasks() != null && workflow.getTasks().size() == 0)) {
+ if (workflow.getTasks() == null || (workflow.getTasks().size() == 0)) {
throw new RepositoryException("Attempt to define a new worklfow: ["
+ workflow.getName() + "] with no tasks.");
}
@@ -328,8 +310,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
// recast it as a parent/child workflow
String workflowId = workflow.getId();
- if (workflowId == null
- || (workflowId != null && workflowId.equals(""))) {
+ if (workflowId == null || (workflowId.equals(""))) {
// generate its ID
workflowId = UUID.randomUUID().toString();
workflow.setId(workflowId);
@@ -410,8 +391,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
}
private void computeWorkflowConditions() throws Exception {
- if (this.workflows != null && this.workflows.values() != null
- && this.workflows.values().size() > 0) {
+ if (this.workflows != null && this.workflows.values().size() > 0) {
for (ParentChildWorkflow w : this.workflows.values()) {
if (w.getConditions() != null && w.getConditions().size() > 0) {
w.getTasks().add(0,
@@ -516,8 +496,8 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
if (procTypeBlocks != null && procTypeBlocks.size() > 0) {
LOG.log(Level.FINE, "Found: [" + procTypeBlocks.size() + "] ["
+ processorType + "] processor types");
- for (int i = 0; i < procTypeBlocks.size(); i++) {
- loadGraphs(rootElements, procTypeBlocks.get(i), graph, staticMetadata);
+ for (Element procTypeBlock : procTypeBlocks) {
+ loadGraphs(rootElements, procTypeBlock, graph, staticMetadata);
}
} else {
if (processorType.equals("condition")) {
@@ -529,8 +509,8 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
if (procTypeBlockNodes != null && procTypeBlockNodes.size() > 0) {
LOG.log(Level.FINE, "Found: [" + procTypeBlockNodes.size()
+ "] linked condition definitions");
- for (int i = 0; i < procTypeBlockNodes.size(); i++) {
- loadGraphs(rootElements, procTypeBlockNodes.get(i), graph,
+ for (Element procTypeBlockNode : procTypeBlockNodes) {
+ loadGraphs(rootElements, procTypeBlockNode, graph,
staticMetadata);
}
}
@@ -539,8 +519,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
}
}
- if (graphElem.getNodeName().equals("cas:workflows"))
- return;
+
}
private void loadConfiguration(List<Element> rootElements, Node workflowNode,
@@ -569,7 +548,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
}
}
- if (configName == null || (configName != null && configName.equals(""))) {
+ if (configName == null || (configName.equals(""))) {
NamedNodeMap workflowNodeAttrs = workflowNode.getAttributes();
for (int j = 0; j < workflowNodeAttrs.getLength(); j++) {
Attr attr = (Attr) workflowNodeAttrs.item(j);
@@ -608,14 +587,12 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
workflow.setId(graph.getModelId());
workflow.setName(graph.getModelName());
graph.setWorkflow(workflow);
- if (graph.getParent() == null
- || (graph.getParent() != null && graph.getParent().getWorkflow() == null)) {
+ if (graph.getParent() == null || (graph.getParent().getWorkflow() == null)) {
LOG.log(Level.FINEST, "Workflow: [" + graph.getModelId()
+ "] has no parent: it's a top-level workflow");
}
- if (workflow.getName() == null
- || (workflow.getName() != null && workflow.getName().equals(""))) {
+ if (workflow.getName() == null || (workflow.getName().equals(""))) {
workflow.setName(graph.getExecutionType() + "-" + workflow.getId());
}
this.workflows.put(graph.getModelId(), workflow);
@@ -633,9 +610,8 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
cond.setOptional(graph.isOptional());
cond.setCondConfig(convertToConditionConfiguration(staticMetadata));
- if (cond.getConditionName() == null
- || (cond.getConditionName() != null && cond.getConditionName()
- .equals(""))) {
+ if (cond.getConditionName() == null || (cond.getConditionName()
+ .equals(""))) {
cond.setConditionName(cond.getConditionId());
}
this.conditions.put(graph.getModelId(), cond);
@@ -674,8 +650,7 @@ public class PackagedWorkflowRepository implements WorkflowRepository {
task.setTaskConfig(convertToTaskConfiguration(staticMetadata));
task.setTaskInstanceClassName(graph.getClazz());
- if (task.getTaskName() == null
- || (task.getTaskName() != null && task.getTaskName().equals(""))) {
+ if (task.getTaskName() == null || (task.getTaskName().equals(""))) {
task.setTaskName(task.getTaskId());
}
this.tasks.put(graph.getModelId(), task);
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepositoryFactory.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepositoryFactory.java
index e603170..12ae9c9 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepositoryFactory.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepositoryFactory.java
@@ -42,8 +42,7 @@ public class PackagedWorkflowRepositoryFactory implements
public PackagedWorkflowRepositoryFactory() throws InstantiationException {
this.wDirPath = System
.getProperty("org.apache.oodt.cas.workflow.wengine.packagedRepo.dir.path");
- if (this.wDirPath == null
- || (this.wDirPath != null && !new File(wDirPath).isDirectory())) {
+ if (this.wDirPath == null || (!new File(wDirPath).isDirectory())) {
throw new InstantiationException("Must specify valid directory path "
+ "containing wengine-style workflow xml files! path specified: ["
+ this.wDirPath + "]");
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
index e92570f..8553ef2 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
@@ -310,8 +310,7 @@ public class XMLWorkflowRepository implements WorkflowRepository {
}
String workflowId = workflow.getId();
- if (workflowId == null
- || (workflowId != null && workflowId.equals(""))) {
+ if (workflowId == null || (workflowId.equals(""))) {
// generate its ID
workflowId = UUID.randomUUID().toString();
workflow.setId(workflowId);
@@ -369,58 +368,54 @@ public class XMLWorkflowRepository implements WorkflowRepository {
List workflows = repo.getWorkflows();
if (workflows != null) {
- for (Iterator i = workflows.iterator(); i.hasNext();) {
- Workflow w = (Workflow) i.next();
- System.out.println("Workflow: [id=" + w.getId() + ", name="
- + w.getName() + "]");
-
- System.out.println("Tasks: ");
-
- for (Iterator j = w.getTasks().iterator(); j.hasNext();) {
- WorkflowTask task = (WorkflowTask) j.next();
-
- System.out.println("Task: [class="
- + task.getTaskInstanceClassName() + ", id="
- + task.getTaskId() + ", name=" + task.getTaskName()
- + ", order=" + task.getOrder() + ",reqMetFields="
- + task.getRequiredMetFields() + "]");
- System.out.println("Configuration: ");
-
- for (Iterator k = task.getTaskConfig().getProperties()
- .keySet().iterator(); k.hasNext();) {
- String key = (String) k.next();
- String value = (String) task.getTaskConfig()
- .getProperties().get(key);
-
- System.out.println("[name=" + key + ", value=" + value
- + "]");
- }
-
- System.out.println("Conditions: ");
-
- for (Iterator k = task.getConditions().iterator(); k
- .hasNext();) {
- WorkflowCondition condition = (WorkflowCondition) k
- .next();
- System.out.println("Condition: ["
- + condition.getClass().getName() + ", id="
- + condition.getConditionId() + ", name="
- + condition.getConditionName() + ", timeout="
- + condition.getTimeoutSeconds()+ ", optional="
- + condition.isOptional()+", order="
- + condition.getOrder() + "]");
-
- System.out.println("Configuration: ");
- for (String cKeyName : (Set<String>) (Set<?>) condition
- .getCondConfig().getProperties().keySet()) {
- System.out.println("[name=" + cKeyName + ", value="
- + condition.getCondConfig().getProperty(cKeyName) + "]");
- }
- }
-
+ for (Object workflow : workflows) {
+ Workflow w = (Workflow) workflow;
+ System.out.println("Workflow: [id=" + w.getId() + ", name="
+ + w.getName() + "]");
+
+ System.out.println("Tasks: ");
+
+ for (WorkflowTask task : w.getTasks()) {
+ System.out.println("Task: [class="
+ + task.getTaskInstanceClassName() + ", id="
+ + task.getTaskId() + ", name=" + task.getTaskName()
+ + ", order=" + task.getOrder() + ",reqMetFields="
+ + task.getRequiredMetFields() + "]");
+ System.out.println("Configuration: ");
+
+ for (Object o : task.getTaskConfig().getProperties()
+ .keySet()) {
+ String key = (String) o;
+ String value = (String) task.getTaskConfig()
+ .getProperties().get(key);
+
+ System.out.println("[name=" + key + ", value=" + value
+ + "]");
+ }
+
+ System.out.println("Conditions: ");
+
+ for (Object o : task.getConditions()) {
+ WorkflowCondition condition = (WorkflowCondition) o;
+ System.out.println("Condition: ["
+ + condition.getClass().getName() + ", id="
+ + condition.getConditionId() + ", name="
+ + condition.getConditionName() + ", timeout="
+ + condition.getTimeoutSeconds() + ", optional="
+ + condition.isOptional() + ", order="
+ + condition.getOrder() + "]");
+
+ System.out.println("Configuration: ");
+ for (String cKeyName : (Set<String>) (Set<?>) condition
+ .getCondConfig().getProperties().keySet()) {
+ System.out.println("[name=" + cKeyName + ", value="
+ + condition.getCondConfig().getProperty(cKeyName) + "]");
}
+ }
}
+
+ }
} else {
System.out.println("No workflows defined!");
}
@@ -429,244 +424,244 @@ public class XMLWorkflowRepository implements WorkflowRepository {
private void loadTasks(List dirUris) {
if (dirUris != null && dirUris.size() > 0) {
- for (Iterator i = dirUris.iterator(); i.hasNext();) {
- String dirUri = (String) i.next();
-
- try {
- File workflowDir = new File(new URI(dirUri));
- if (workflowDir.isDirectory()) {
- String workflowDirStr = workflowDir.getAbsolutePath();
+ for (Object dirUri1 : dirUris) {
+ String dirUri = (String) dirUri1;
- if (!workflowDirStr.endsWith("/")) {
- workflowDirStr += "/";
- }
+ try {
+ File workflowDir = new File(new URI(dirUri));
+ if (workflowDir.isDirectory()) {
+ String workflowDirStr = workflowDir.getAbsolutePath();
- Document taskRoot = getDocumentRoot(workflowDirStr
- + "tasks.xml");
+ if (!workflowDirStr.endsWith("/")) {
+ workflowDirStr += "/";
+ }
- Element taskElement = taskRoot.getDocumentElement();
+ Document taskRoot = getDocumentRoot(workflowDirStr
+ + "tasks.xml");
- NodeList taskElemList = taskElement
- .getElementsByTagName("task");
+ Element taskElement = taskRoot.getDocumentElement();
- if (taskElemList != null
- && taskElemList.getLength() > 0) {
- for (int j = 0; j < taskElemList.getLength(); j++) {
- Element taskElem = (Element) taskElemList
- .item(j);
- WorkflowTask task = XmlStructFactory
- .getWorkflowTask(taskElem, conditionMap);
- if (task != null) {
- taskMap.put(task.getTaskId(), task);
- }
- }
+ NodeList taskElemList = taskElement
+ .getElementsByTagName("task");
- }
+ if (taskElemList != null
+ && taskElemList.getLength() > 0) {
+ for (int j = 0; j < taskElemList.getLength(); j++) {
+ Element taskElem = (Element) taskElemList
+ .item(j);
+ WorkflowTask task = XmlStructFactory
+ .getWorkflowTask(taskElem, conditionMap);
+ if (task != null) {
+ taskMap.put(task.getTaskId(), task);
}
- } catch (URISyntaxException e) {
- LOG
- .log(
- Level.WARNING,
- "DirUri: "
- + dirUri
- + " is not a directory: skipping task loading for it.");
- }
+ }
+ }
+ }
+ } catch (URISyntaxException e) {
+ LOG
+ .log(
+ Level.WARNING,
+ "DirUri: "
+ + dirUri
+ + " is not a directory: skipping task loading for it.");
}
+
+ }
}
}
private void loadConditions(List dirUris) {
if (dirUris != null && dirUris.size() > 0) {
- for (Iterator i = dirUris.iterator(); i.hasNext();) {
- String dirUri = (String) i.next();
+ for (Object dirUri1 : dirUris) {
+ String dirUri = (String) dirUri1;
- try {
- File workflowDir = new File(new URI(dirUri));
- if (workflowDir.isDirectory()) {
- String workflowDirStr = workflowDir.getAbsolutePath();
+ try {
+ File workflowDir = new File(new URI(dirUri));
+ if (workflowDir.isDirectory()) {
+ String workflowDirStr = workflowDir.getAbsolutePath();
- if (!workflowDirStr.endsWith("/")) {
- workflowDirStr += "/";
- }
-
- Document conditionRoot = getDocumentRoot(workflowDirStr
- + "conditions.xml");
-
- Element conditionElement = conditionRoot
- .getDocumentElement();
-
- NodeList conditionElemList = conditionElement
- .getElementsByTagName("condition");
-
- if (conditionElemList != null
- && conditionElemList.getLength() > 0) {
- for (int j = 0; j < conditionElemList.getLength(); j++) {
- Element conditionElem = (Element) conditionElemList
- .item(j);
- WorkflowCondition condition = XmlStructFactory
- .getWorkflowCondition(conditionElem);
- if (condition != null) {
- conditionMap.put(
- condition.getConditionId(),
- condition);
- }
- }
+ if (!workflowDirStr.endsWith("/")) {
+ workflowDirStr += "/";
+ }
- }
+ Document conditionRoot = getDocumentRoot(workflowDirStr
+ + "conditions.xml");
+
+ Element conditionElement = conditionRoot
+ .getDocumentElement();
+
+ NodeList conditionElemList = conditionElement
+ .getElementsByTagName("condition");
+
+ if (conditionElemList != null
+ && conditionElemList.getLength() > 0) {
+ for (int j = 0; j < conditionElemList.getLength(); j++) {
+ Element conditionElem = (Element) conditionElemList
+ .item(j);
+ WorkflowCondition condition = XmlStructFactory
+ .getWorkflowCondition(conditionElem);
+ if (condition != null) {
+ conditionMap.put(
+ condition.getConditionId(),
+ condition);
}
- } catch (URISyntaxException e) {
- LOG
- .log(
- Level.WARNING,
- "DirUri: "
- + dirUri
- + " is not a directory: skipping condition loading for it.");
- }
+ }
+ }
+ }
+ } catch (URISyntaxException e) {
+ LOG
+ .log(
+ Level.WARNING,
+ "DirUri: "
+ + dirUri
+ + " is not a directory: skipping condition loading for it.");
}
+
+ }
}
}
private void loadWorkflows(List dirUris) {
if (dirUris != null && dirUris.size() > 0) {
- for (Iterator i = dirUris.iterator(); i.hasNext();) {
- String dirUri = (String) i.next();
-
- try {
- File workflowDir = new File(new URI(dirUri));
- if (workflowDir.isDirectory()) {
- String workflowDirStr = workflowDir.getAbsolutePath();
+ for (Object dirUri1 : dirUris) {
+ String dirUri = (String) dirUri1;
- if (!workflowDirStr.endsWith("/")) {
- workflowDirStr += "/";
- }
+ try {
+ File workflowDir = new File(new URI(dirUri));
+ if (workflowDir.isDirectory()) {
+ String workflowDirStr = workflowDir.getAbsolutePath();
- // get all the workflow xml files
- File[] workflowFiles = workflowDir
- .listFiles(workflowXmlFilter);
-
- for (int j = 0; j < workflowFiles.length; j++) {
- String workflowXmlFile = workflowFiles[j]
- .getAbsolutePath();
- Document workflowRoot = getDocumentRoot(workflowXmlFile);
-
- String workflowId = workflowRoot
- .getDocumentElement().getAttribute("id");
- if (workflowMap.get(workflowId) == null) {
- Workflow w = XmlStructFactory.getWorkflow(
- workflowRoot.getDocumentElement(),
- taskMap, conditionMap);
-
- if(w.getConditions() != null && w.getConditions().size() > 0){
- // add a virtual first task, with the conditions
- w.getTasks().add(0, getGlobalWorkflowConditionsTask(w.getName(), w.getId(), w.getConditions()));
- }
- workflowMap.put(workflowId, w);
- } else {
- LOG
- .log(
- Level.FINE,
- "Ignoring workflow file: "
- + workflowXmlFile
- + " when loading workflows, workflow id: "
- + workflowId
- + " already loaded");
- }
+ if (!workflowDirStr.endsWith("/")) {
+ workflowDirStr += "/";
+ }
- }
+ // get all the workflow xml files
+ File[] workflowFiles = workflowDir
+ .listFiles(workflowXmlFilter);
+
+ for (File workflowFile : workflowFiles) {
+ String workflowXmlFile = workflowFile
+ .getAbsolutePath();
+ Document workflowRoot = getDocumentRoot(workflowXmlFile);
+
+ String workflowId = workflowRoot
+ .getDocumentElement().getAttribute("id");
+ if (workflowMap.get(workflowId) == null) {
+ Workflow w = XmlStructFactory.getWorkflow(
+ workflowRoot.getDocumentElement(),
+ taskMap, conditionMap);
+
+ if (w.getConditions() != null && w.getConditions().size() > 0) {
+ // add a virtual first task, with the conditions
+ w.getTasks().add(0, getGlobalWorkflowConditionsTask(w.getName(), w.getId(), w.getConditions()));
}
- } catch (URISyntaxException e) {
+ workflowMap.put(workflowId, w);
+ } else {
LOG
- .log(
- Level.WARNING,
- "DirUri: "
- + dirUri
- + " is not a directory: skipping workflow loading for it.");
- }
+ .log(
+ Level.FINE,
+ "Ignoring workflow file: "
+ + workflowXmlFile
+ + " when loading workflows, workflow id: "
+ + workflowId
+ + " already loaded");
+ }
+ }
+ }
+ } catch (URISyntaxException e) {
+ LOG
+ .log(
+ Level.WARNING,
+ "DirUri: "
+ + dirUri
+ + " is not a directory: skipping workflow loading for it.");
}
+
+ }
}
}
private void loadEvents(List dirUris) {
if (dirUris != null && dirUris.size() > 0) {
- for (Iterator i = dirUris.iterator(); i.hasNext();) {
- String dirUri = (String) i.next();
+ for (Object dirUri1 : dirUris) {
+ String dirUri = (String) dirUri1;
- try {
- File workflowDir = new File(new URI(dirUri));
- if (workflowDir.isDirectory()) {
- String workflowDirStr = workflowDir.getAbsolutePath();
+ try {
+ File workflowDir = new File(new URI(dirUri));
+ if (workflowDir.isDirectory()) {
+ String workflowDirStr = workflowDir.getAbsolutePath();
- if (!workflowDirStr.endsWith("/")) {
- workflowDirStr += "/";
- }
-
- Document eventRoot = getDocumentRoot(workflowDirStr
- + "events.xml");
+ if (!workflowDirStr.endsWith("/")) {
+ workflowDirStr += "/";
+ }
- Element eventElement = eventRoot.getDocumentElement();
+ Document eventRoot = getDocumentRoot(workflowDirStr
+ + "events.xml");
- NodeList eventElemList = eventElement
- .getElementsByTagName("event");
+ Element eventElement = eventRoot.getDocumentElement();
- if (eventElemList != null
- && eventElemList.getLength() > 0) {
- for (int j = 0; j < eventElemList.getLength(); j++) {
- Element eventElem = (Element) eventElemList
- .item(j);
+ NodeList eventElemList = eventElement
+ .getElementsByTagName("event");
- String eventName = eventElem
- .getAttribute("name");
- Workflow w = null;
+ if (eventElemList != null
+ && eventElemList.getLength() > 0) {
+ for (int j = 0; j < eventElemList.getLength(); j++) {
+ Element eventElem = (Element) eventElemList
+ .item(j);
- NodeList workflowNodeList = eventElem
- .getElementsByTagName("workflow");
+ String eventName = eventElem
+ .getAttribute("name");
+ Workflow w = null;
- if (workflowNodeList != null
- && workflowNodeList.getLength() > 0) {
- List workflowList = new Vector();
+ NodeList workflowNodeList = eventElem
+ .getElementsByTagName("workflow");
- for (int k = 0; k < workflowNodeList
- .getLength(); k++) {
- Element workflowElement = (Element) workflowNodeList
- .item(k);
- w = (Workflow) workflowMap
- .get(workflowElement
- .getAttribute("id"));
+ if (workflowNodeList != null
+ && workflowNodeList.getLength() > 0) {
+ List workflowList = new Vector();
- if (w != null) {
- workflowList.add(w);
- }
- }
+ for (int k = 0; k < workflowNodeList
+ .getLength(); k++) {
+ Element workflowElement = (Element) workflowNodeList
+ .item(k);
+ w = (Workflow) workflowMap
+ .get(workflowElement
+ .getAttribute("id"));
- eventMap.put(eventName, workflowList);
- }
- }
+ if (w != null) {
+ workflowList.add(w);
}
+ }
+
+ eventMap.put(eventName, workflowList);
}
- } catch (URISyntaxException e) {
- LOG
- .log(
- Level.WARNING,
- "DirUri: "
- + dirUri
- + " is not a directory: skipping event loading for it.");
+ }
}
-
+ }
+ } catch (URISyntaxException e) {
+ LOG
+ .log(
+ Level.WARNING,
+ "DirUri: "
+ + dirUri
+ + " is not a directory: skipping event loading for it.");
}
+
+ }
}
}
private Document getDocumentRoot(String xmlFile) {
// open up the XML file
- DocumentBuilderFactory factory = null;
- DocumentBuilder parser = null;
- Document document = null;
- InputSource inputSource = null;
+ DocumentBuilderFactory factory;
+ DocumentBuilder parser;
+ Document document;
+ InputSource inputSource;
- InputStream xmlInputStream = null;
+ InputStream xmlInputStream;
try {
xmlInputStream = new File(xmlFile).toURL().openStream();
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ConditionTaskInstance.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ConditionTaskInstance.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ConditionTaskInstance.java
index d8a5947..9fd7116 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ConditionTaskInstance.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ConditionTaskInstance.java
@@ -18,14 +18,15 @@
package org.apache.oodt.cas.workflow.structs;
//JDK imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.structs.exceptions.WorkflowTaskInstanceException;
+import org.apache.oodt.cas.workflow.util.GenericWorkflowObjectFactory;
+
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
//OODT imports
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.workflow.structs.exceptions.WorkflowTaskInstanceException;
-import org.apache.oodt.cas.workflow.util.GenericWorkflowObjectFactory;
/**
*
@@ -61,8 +62,7 @@ public class ConditionTaskInstance implements WorkflowTaskInstance {
public void run(Metadata metadata, WorkflowTaskConfiguration config)
throws WorkflowTaskInstanceException {
String conditionClassName = config.getProperty("ConditionClassName");
- if (conditionClassName == null
- || (conditionClassName != null && conditionClassName.equals(""))) {
+ if (conditionClassName == null || (conditionClassName.equals(""))) {
throw new WorkflowTaskInstanceException(
"Condition class name is null or " + "unreadable: ["
+ conditionClassName + "]: unable to run ConditionTaskInstance!");
http://git-wip-us.apache.org/repos/asf/oodt/blob/0a3ff32c/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/TaskJob.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/TaskJob.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/TaskJob.java
index 333c436..3ed12bb 100644
--- a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/TaskJob.java
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/TaskJob.java
@@ -177,8 +177,7 @@ public class TaskJob implements JobInstance, WorkflowStatus, CoreMetKeys{
private XmlRpcWorkflowManagerClient getWmClientFromMetadata(Metadata met) {
String workflowMgrUrlStr = met.getMetadata(WORKFLOW_MANAGER_URL);
- if (workflowMgrUrlStr == null
- || (workflowMgrUrlStr != null && workflowMgrUrlStr.equals(""))) {
+ if (workflowMgrUrlStr == null || (workflowMgrUrlStr.equals(""))) {
// try to default to a workflow mgr on localhost
// most likely won't work, but worth trying
workflowMgrUrlStr = "http://localhost:9001";