http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/filemgr/src/test/java/org/apache/oodt/cas/filemgr/validation/TestXMLValidationLayer.java ---------------------------------------------------------------------- diff --git a/filemgr/src/test/java/org/apache/oodt/cas/filemgr/validation/TestXMLValidationLayer.java b/filemgr/src/test/java/org/apache/oodt/cas/filemgr/validation/TestXMLValidationLayer.java index 096dc35..921bc72 100644 --- a/filemgr/src/test/java/org/apache/oodt/cas/filemgr/validation/TestXMLValidationLayer.java +++ b/filemgr/src/test/java/org/apache/oodt/cas/filemgr/validation/TestXMLValidationLayer.java @@ -191,12 +191,12 @@ public class TestXMLValidationLayer extends TestCase { // try and find one of them // find produuct received time boolean hasReceivedTime = false; - for (Iterator i = elementList.iterator(); i.hasNext();) { - Element element = (Element) i.next(); - if (element.getElementName().equals("CAS.ProductReceivedTime")) { - hasReceivedTime = true; - } + for (Object anElementList : elementList) { + Element element = (Element) anElementList; + if (element.getElementName().equals("CAS.ProductReceivedTime")) { + hasReceivedTime = true; } + } if (!hasReceivedTime) { fail("Didn't load the CAS.ProductReceivedTime element!"); @@ -272,8 +272,8 @@ public class TestXMLValidationLayer extends TestCase { File[] delFiles = startDirFile.listFiles(); if (delFiles != null && delFiles.length > 0) { - for (int i = 0; i < delFiles.length; i++) { - delFiles[i].delete(); + for (File delFile : delFiles) { + delFile.delete(); } }
http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java b/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java index 65d30f0..9494fda 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java @@ -158,9 +158,9 @@ public class ConfigServlet extends GridServlet { List codeBases = config.getCodeBases(); // Get the current code bases List toRemove = new ArrayList(); // Hold indexes of code bases to remove - for (Iterator i = params.entrySet().iterator(); i.hasNext();) { // For each - // parameter - Map.Entry entry = (Map.Entry) i.next(); // Get its entry + for (Object o : params.entrySet()) { // For each + // parameter + Map.Entry entry = (Map.Entry) o; // Get its entry String key = (String) entry.getKey(); // And its name String value = ((String[]) entry.getValue())[0]; // And its zeroth value if (key.startsWith("delcb-") && "on".equals(value)) { // If it's checked http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/Configuration.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/Configuration.java b/grid/src/main/java/org/apache/oodt/grid/Configuration.java index 8ea5375..c894052 100755 --- a/grid/src/main/java/org/apache/oodt/grid/Configuration.java +++ b/grid/src/main/java/org/apache/oodt/grid/Configuration.java @@ -83,21 +83,21 @@ public class Configuration implements Serializable { if (password != null && password.length > 0) // If we have a password elem.setAttribute("password", encode(password)); // Add passowrd attribute - for (Iterator i = productServers.iterator(); i.hasNext();) { // For each product server - ProductServer ps = (ProductServer) i.next(); // Get the product server + for (Object productServer : productServers) { // For each product server + ProductServer ps = (ProductServer) productServer; // Get the product server elem.appendChild(ps.toXML(owner)); // And add it under <configuration> } - for (Iterator i = profileServers.iterator(); i.hasNext();) { // For each profile server - ProfileServer ps = (ProfileServer) i.next(); // Get the profile server + for (Object profileServer : profileServers) { // For each profile server + ProfileServer ps = (ProfileServer) profileServer; // Get the profile server elem.appendChild(ps.toXML(owner)); // And add it under the <configuration> } if (!codeBases.isEmpty()) { // Got any code bases? Element cbs = owner.createElement("codeBases"); // Boo yah. Make a parent for 'em elem.appendChild(cbs); // Add parent - for (Iterator i = codeBases.iterator(); i.hasNext();) { // Then, for each code base - URL url = (URL) i.next(); // Get the URL to it + for (Object codeBase : codeBases) { // Then, for each code base + URL url = (URL) codeBase; // Get the URL to it Element cb = owner.createElement("codeBase"); // And make a <codeBase> for it cb.setAttribute("url", url.toString()); // And an "url" attribute cbs.appendChild(cb); // Add it @@ -108,8 +108,9 @@ public class Configuration implements Serializable { Element props = owner.createElement("properties"); // Add <properties> under <configuration> props.setAttribute("xml:space", "preserve"); // And make sure space is properly preserved elem.appendChild(props); // Add the space attribute - for (Iterator i = properties.entrySet().iterator(); i.hasNext();) { // For each property - Map.Entry entry = (Map.Entry) i.next(); // Get the property key/value pair + for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) { // For each property + Map.Entry entry = + (Map.Entry) objectObjectEntry; // Get the property key/value pair String key = (String) entry.getKey(); // Key is always a String String value = (String) entry.getValue(); // So is the value Element prop = owner.createElement("property"); // Create a <property> element http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java index 8229e75..4f1df63 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java @@ -56,15 +56,15 @@ public class ProductQueryServlet extends QueryServlet { } try { // OK, let's try - for (Iterator i = handlers.iterator(); i.hasNext();) { // Try each query handler - QueryHandler handler = (QueryHandler) i.next(); // Get the query handler - query = handler.query(query); // Give it the query - if (!query.getResults().isEmpty()) { // Did it give any result? - Result result = (Result) query.getResults().get(0); // Yes, get the result - deliverResult(handler, result, res); // And deliver it - return; // Done! - } + for (Object handler1 : handlers) { // Try each query handler + QueryHandler handler = (QueryHandler) handler1; // Get the query handler + query = handler.query(query); // Give it the query + if (!query.getResults().isEmpty()) { // Did it give any result? + Result result = (Result) query.getResults().get(0); // Yes, get the result + deliverResult(handler, result, res); // And deliver it + return; // Done! } + } } catch (ProductException ex) { if (ex instanceof HttpRedirectException) { HttpRedirectException hre = (HttpRedirectException) ex; @@ -133,8 +133,11 @@ public class ProductQueryServlet extends QueryServlet { * @return a <code>boolean</code> value. */ protected static boolean displayable(String contentType) { - for (int i = 0; i < DISPLAYABLE_TYPES.length; ++i) // For each displayable type - if (DISPLAYABLE_TYPES[i].equals(contentType)) return true; // Does it match? + for (String DISPLAYABLE_TYPE : DISPLAYABLE_TYPES) { + if (DISPLAYABLE_TYPE.equals(contentType)) { + return true; // Does it match? + } + } return false; // None of 'em do, it's not displayable } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java index 80b1592..4fa9a17 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java @@ -56,11 +56,12 @@ public class ProfileQueryServlet extends QueryServlet { // Find if the query should be targeted to specific handlers. Set ids = new HashSet(); if (query.getFromElementSet() != null) { - for (Iterator i = query.getFromElementSet().iterator(); i.hasNext();) { - QueryElement qe = (QueryElement) i.next(); - if ("handler".equals(qe.getRole()) && qe.getValue() != null) - ids.add(qe.getValue()); + for (Object o : query.getFromElementSet()) { + QueryElement qe = (QueryElement) o; + if ("handler".equals(qe.getRole()) && qe.getValue() != null) { + ids.add(qe.getValue()); } + } } res.setContentType("text/xml"); // XML, comin' at ya @@ -73,27 +74,33 @@ public class ProfileQueryServlet extends QueryServlet { Document doc = null; // Don't make 'em if we don't need 'em boolean sentAtLeastOne = false; // Track if we send any profiles at all Exception exception = null; // And save any exception - for (Iterator i = handlers.iterator(); i.hasNext();) try { // To iterate over each handler - ProfileHandler handler = (ProfileHandler) i.next(); // Get the handler - String id = handler.getID(); // Get the ID, and if targeting to IDs - if (!ids.isEmpty() && !ids.contains(id)) continue; // ... and it's not one we want, skip it. - List results = handler.findProfiles(query); // Have it find profiles - if (results == null) results = Collections.EMPTY_LIST; // Assume nothing - for (Iterator j = results.iterator(); j.hasNext();) { // For each matching profile - Profile profile = (Profile) j.next(); // Get the profile - if (transformer == null) { // No transformer/doc yet? - transformer = createTransformer(); // Then make the transformer - doc = Profile.createProfileDocument(); // And the doc - } // And use the doc ... - Node profileNode = profile.toXML(doc); // To render the profile into XML - DOMSource source = new DOMSource(profileNode); // And the XML becomes is source - StreamResult result = new StreamResult(res.getWriter()); // And the response is a result - transformer.transform(source, result); // And serialize into glorious text - sentAtLeastOne = true; // OK, we got at least one out the doo - } - } catch (Exception ex) { // Uh oh - exception = ex; // OK, just hold onto it for now + for (Object handler1 : handlers) { + try { // To iterate over each handler + ProfileHandler handler = (ProfileHandler) handler1; // Get the handler + String id = handler.getID(); // Get the ID, and if targeting to IDs + if (!ids.isEmpty() && !ids.contains(id)) { + continue; // ... and it's not one we want, skip it. + } + List results = handler.findProfiles(query); // Have it find profiles + if (results == null) { + results = Collections.EMPTY_LIST; // Assume nothing + } + for (Iterator j = results.iterator(); j.hasNext(); ) { // For each matching profile + Profile profile = (Profile) j.next(); // Get the profile + if (transformer == null) { // No transformer/doc yet? + transformer = createTransformer(); // Then make the transformer + doc = Profile.createProfileDocument(); // And the doc + } // And use the doc ... + Node profileNode = profile.toXML(doc); // To render the profile into XML + DOMSource source = new DOMSource(profileNode); // And the XML becomes is source + StreamResult result = new StreamResult(res.getWriter()); // And the response is a result + transformer.transform(source, result); // And serialize into glorious text + sentAtLeastOne = true; // OK, we got at least one out the doo + } + } catch (Exception ex) { // Uh oh + exception = ex; // OK, just hold onto it for now } + } if (!sentAtLeastOne && exception != null) { // Got none out the door and had an error? res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, // Then we can report it. exception.getMessage()); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java index f22c6a9..22c58d0 100755 --- a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java @@ -93,10 +93,10 @@ public abstract class QueryServlet extends GridServlet { updateHandlers(getServers(config)); // And any servers. List handlerObjects = new ArrayList(handlers.size()); // Start with no handlers. - for (Iterator i = handlers.iterator(); i.hasNext();) { // For each server - InstantiedHandler ih = (InstantiedHandler) i.next(); // Get its handler - handlerObjects.add(ih.getHandler()); // Add its handler - } + for (Object handler : handlers) { // For each server + InstantiedHandler ih = (InstantiedHandler) handler; // Get its handler + handlerObjects.add(ih.getHandler()); // Add its handler + } handleQuery(query, handlerObjects, req, res); // Handlers: handle query, please } catch (RuntimeException ex) { throw ex; @@ -165,17 +165,19 @@ public abstract class QueryServlet extends GridServlet { private synchronized void updateHandlers(List servers) throws ClassNotFoundException, InstantiationException, IllegalAccessException { eachServer: - for (Iterator i = servers.iterator(); i.hasNext();) { // For each server - Server server = (Server) i.next(); // Grab the server - for (Iterator j = handlers.iterator(); j.hasNext();) { // For each handler - InstantiedHandler handler = (InstantiedHandler) j.next(); // Grab the handler - if (handler.getServer().equals(server)) // Have we already instantiated? - continue eachServer; // Yes, try the next server - } - InstantiedHandler handler // No. Create ... - = new InstantiedHandler(server, server.createHandler()); // ... a fresh handler - handlers.add(handler); // Save it + for (Object server1 : servers) { // For each server + Server server = (Server) server1; // Grab the server + for (Object handler1 : handlers) { // For each handler + InstantiedHandler handler = (InstantiedHandler) handler1; // Grab the handler + if (handler.getServer().equals(server)) // Have we already instantiated? + { + continue eachServer; // Yes, try the next server + } } + InstantiedHandler handler // No. Create ... + = new InstantiedHandler(server, server.createHandler()); // ... a fresh handler + handlers.add(handler); // Save it + } for (Iterator i = handlers.iterator(); i.hasNext();) { // Now, for each handler InstantiedHandler handler = (InstantiedHandler) i.next(); // Grab the handler @@ -192,8 +194,9 @@ public abstract class QueryServlet extends GridServlet { private synchronized void updateProperties(Configuration config) { if (properties != null) { // Any old properties? if (properties.equals(config.getProperties())) return; // Yes, any changes? No? Then done. - for (Iterator i = properties.keySet().iterator(); i.hasNext();) // Yes, then grab each old setting - System.getProperties().remove(i.next()); // and remove it. + for (Object o : properties.keySet()) { + System.getProperties().remove(o); // and remove it. + } } properties = (Properties) config.getProperties().clone(); // Now copy the new settings System.getProperties().putAll(properties); // And set them! http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java index 6f9cf66..4b7068b 100644 --- a/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java @@ -65,10 +65,12 @@ public class RestfulProductQueryServlet extends ProductQueryServlet { while (parameterNames.hasMoreElements()) { String paramName = parameterNames.nextElement(); String[] paramValues = req.getParameterValues(paramName); - for (int i = 0; i < paramValues.length; i++) { - if (q.length()>0) q.append(" AND "); - q.append(paramName).append(" EQ ").append(paramValues[i]); + for (String paramValue : paramValues) { + if (q.length() > 0) { + q.append(" AND "); } + q.append(paramName).append(" EQ ").append(paramValue); + } } // build XMLQuery object from HTTP parameters http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/mvn/plugins/cas-install/src/main/java/org/apache/oodt/cas/install/CASInstallDistMojo.java ---------------------------------------------------------------------- diff --git a/mvn/plugins/cas-install/src/main/java/org/apache/oodt/cas/install/CASInstallDistMojo.java b/mvn/plugins/cas-install/src/main/java/org/apache/oodt/cas/install/CASInstallDistMojo.java index 6f3fdf3..1b5921a 100644 --- a/mvn/plugins/cas-install/src/main/java/org/apache/oodt/cas/install/CASInstallDistMojo.java +++ b/mvn/plugins/cas-install/src/main/java/org/apache/oodt/cas/install/CASInstallDistMojo.java @@ -238,19 +238,19 @@ public class CASInstallDistMojo extends AbstractMojo { + e.getMessage()); } - for (int i = 0; i < customLibs.length; i++) { - getLog().info( - "installing [" + customLibs[i] + "] to " - + libDir.getAbsolutePath() + "]"); - try { - FileUtils.copyFileToDirectory(customLibs[i], libDir); - } catch (IOException e) { - getLog().warn( - "IOException installing [" + customLibs[i] - + "] to " + libDir.getAbsolutePath() - + "]: Message: " + e.getMessage()); - } + for (File customLib : customLibs) { + getLog().info( + "installing [" + customLib + "] to " + + libDir.getAbsolutePath() + "]"); + try { + FileUtils.copyFileToDirectory(customLib, libDir); + } catch (IOException e) { + getLog().warn( + "IOException installing [" + customLib + + "] to " + libDir.getAbsolutePath() + + "]: Message: " + e.getMessage()); } + } } if (envVarReplaceFiles != null && envVarReplaceFiles.length > 0) { http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java index 5b1b4a9..0758690 100644 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java +++ b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java @@ -77,13 +77,11 @@ public class DatasetCrawler implements CatalogCrawler.Listener { // look for an OpenDAP access URL, only extract metadata if it is found List<InvAccess> datasets = dd.getAccess(); if (dd.getAccess() != null && dd.getAccess().size() > 0) { - Iterator<InvAccess> sets = datasets.iterator(); - while (sets.hasNext()) { - InvAccess single = sets.next(); + for (InvAccess single : datasets) { InvService service = single.getService(); // note: select the OpenDAP access URL based on THREDDS service type - if (service.getServiceType()==ServiceType.OPENDAP) { - LOG.log(Level.FINE, "Found OpenDAP access URL: "+ single.getUrlPath()); + if (service.getServiceType() == ServiceType.OPENDAP) { + LOG.log(Level.FINE, "Found OpenDAP access URL: " + single.getUrlPath()); String opendapurl = this.datasetURL + single.getUrlPath(); // extract metadata from THREDDS catalog MetadataExtractor extractor = new ThreddsMetadataExtractor(dd); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/pcs/core/src/main/java/org/apache/oodt/pcs/health/CrawlPropertiesFile.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/health/CrawlPropertiesFile.java b/pcs/core/src/main/java/org/apache/oodt/pcs/health/CrawlPropertiesFile.java index 3b6bfa4..d887dc7 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/health/CrawlPropertiesFile.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/health/CrawlPropertiesFile.java @@ -68,8 +68,8 @@ public class CrawlPropertiesFile implements CrawlerPropertiesMetKeys { Map scalars = crawlInfo.getScalars(); List crawlers = new Vector(scalars.keySet().size()); - for (Iterator i = scalars.keySet().iterator(); i.hasNext();) { - String crawlerName = (String) i.next(); + for (Object o : scalars.keySet()) { + String crawlerName = (String) o; String crawlerPort = crawlInfo.getScalar(crawlerName).getValue(); CrawlInfo info = new CrawlInfo(crawlerName, crawlerPort); crawlers.add(info); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 8783669..307667b 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 @@ -245,8 +245,8 @@ public final class PCSHealthMonitor implements CoreMetKeys, List 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; PCSDaemonStatus batchStatus = new PCSDaemonStatus(); batchStatus.setDaemonName(BATCH_STUB_DAEMON_NAME); batchStatus.setUrlStr(node.getIpAddr().toString()); @@ -275,10 +275,10 @@ public final class PCSHealthMonitor implements CoreMetKeys, }); - 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(); CrawlerStatus status = new CrawlerStatus(); status.setInfo(info); status.setStatus(printUp(getCrawlerUp(crawlerUrlStr))); @@ -307,8 +307,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; @@ -382,10 +382,10 @@ public final class PCSHealthMonitor implements CoreMetKeys, private void printJobStatusHealth(PCSHealthMonitorReport report) { if (report.getJobHealthStatus() != null && report.getJobHealthStatus().size() > 0) { - for (Iterator i = report.getJobHealthStatus().iterator(); i.hasNext();) { - JobHealthStatus status = (JobHealthStatus) i.next(); + for (Object o : report.getJobHealthStatus()) { + JobHealthStatus status = (JobHealthStatus) o; System.out.println(status.getNumPipelines() + " pipelines " - + status.getStatus()); + + status.getStatus()); } } } @@ -410,10 +410,10 @@ public final class PCSHealthMonitor implements CoreMetKeys, private void printBatchStubs(PCSHealthMonitorReport report) { if (report.getBatchStubStatus() != null && report.getBatchStubStatus().size() > 0) { - for (Iterator i = report.getBatchStubStatus().iterator(); i.hasNext();) { - PCSDaemonStatus batchStatus = (PCSDaemonStatus) i.next(); + for (Object o : report.getBatchStubStatus()) { + PCSDaemonStatus batchStatus = (PCSDaemonStatus) o; System.out.println("> " + batchStatus.getDaemonName() + ": [" - + batchStatus.getUrlStr() + "]: " + batchStatus.getStatus()); + + batchStatus.getUrlStr() + "]: " + batchStatus.getStatus()); } } @@ -533,17 +533,17 @@ public final class PCSHealthMonitor implements CoreMetKeys, return; } - 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); System.out.println(info.getCrawlerName() + ":"); System.out.println("Number of Crawls: " + controller.getNumCrawls()); System.out.println("Average Crawl Time (seconds): " - + (double) (controller.getAverageCrawlTime() / 1000.0)); + + (double) (controller.getAverageCrawlTime() / 1000.0)); System.out.println(""); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 4d7e53b..72ecaaa 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 @@ -64,8 +64,8 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys { public void doList(List prodNames) { if (prodNames != null && prodNames.size() > 0) { System.out.println(getToolHeader()); - for (Iterator i = prodNames.iterator(); i.hasNext();) { - String prodName = (String) i.next(); + for (Object prodName1 : prodNames) { + String prodName = (String) prodName1; // check to see if the product name has a "/" in it // (this is true in the case of someone using */* from // a shell): if it does, we'll consider the prodName a @@ -181,14 +181,15 @@ public class PCSLongLister implements PCSMetadata, CoreMetKeys { // if you find one tag, then set foundTag = true, and we // break if (products != null && products.size() > 0) { - for (Iterator i = products.iterator(); i.hasNext();) { - Product prod = (Product) i.next(); + for (Object product : products) { + Product prod = (Product) product; Metadata prodMet = fm.safeGetMetadata(prod); if (prodMet.containsKey(tagType)) { // got one, done - if (!foundTag) + if (!foundTag) { foundTag = true; + } if (!tags.contains(prodMet.getMetadata(tagType))) { tags.add(prodMet.getMetadata(tagType)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java index 76425c1..28b24f7 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSTrace.java @@ -136,8 +136,7 @@ public final class PCSTrace implements PCSMetadata, PCSConfigMetadata { Metadata met = fm.safeGetMetadata(prod); if (met != null && met.getHashtable() != null && met.getHashtable().keySet().size() > 0) { - for (Iterator i = met.getHashtable().keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (String key : met.getHashtable().keySet()) { List vals = met.getAllMetadata(key); System.out.println(key + "=>" + vals); } @@ -159,8 +158,8 @@ public final class PCSTrace implements PCSMetadata, PCSConfigMetadata { if (wInstProds != null && wInstProds.size() > 0) { System.out.println("Associated products:"); System.out.println(""); - for (Iterator i = wInstProds.iterator(); i.hasNext();) { - Product wInstProd = (Product) i.next(); + for (Object wInstProd1 : wInstProds) { + Product wInstProd = (Product) wInstProd1; System.out.println(wInstProd.getProductName()); } } @@ -238,8 +237,8 @@ public final class PCSTrace implements PCSMetadata, PCSConfigMetadata { return null; } - for (Iterator i = insts.iterator(); i.hasNext();) { - WorkflowInstance inst = (WorkflowInstance) i.next(); + for (Object inst1 : insts) { + WorkflowInstance inst = (WorkflowInstance) inst1; if (inst.getId().equals(id)) { return inst; } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 d084e7f..cb672a3 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 @@ -110,8 +110,8 @@ public class FileManagerUtils implements PCSConfigMetadata { List typeList = new Vector(); if (typeNames != null && typeNames.size() > 0) { - for (Iterator i = typeNames.iterator(); i.hasNext();) { - String typeName = (String) i.next(); + for (Object typeName1 : typeNames) { + String typeName = (String) typeName1; ProductType type = safeGetProductTypeByName(typeName); if (type != null) { typeList.add(type); @@ -126,8 +126,8 @@ public class FileManagerUtils implements PCSConfigMetadata { List products = new Vector(); if (typeList != null && typeList.size() > 0) { - for (Iterator i = typeList.iterator(); i.hasNext();) { - ProductType type = (ProductType) i.next(); + for (Object aTypeList : typeList) { + ProductType type = (ProductType) aTypeList; List prods = safeIssueQuery(query, type); if (prods != null && prods.size() > 0) { products.addAll(prods); @@ -161,8 +161,8 @@ public class FileManagerUtils implements PCSConfigMetadata { List products = new Vector(); if (productTypes != null && productTypes.size() > 0) { - for (Iterator i = productTypes.iterator(); i.hasNext();) { - ProductType type = (ProductType) i.next(); + for (Object productType : productTypes) { + ProductType type = (ProductType) productType; if (excludeTypeList != null && excludeTypeList.contains(type.getName())) { // System.out.println("Skipping: [" + type.getName() + "]"); continue; @@ -428,8 +428,8 @@ public class FileManagerUtils implements PCSConfigMetadata { public static Reference getRootReference(String productName, List refs) { Reference r = null; - for (Iterator i = refs.iterator(); i.hasNext();) { - Reference ref = (Reference) i.next(); + for (Object ref1 : refs) { + Reference ref = (Reference) ref1; if (isRootDir(ref, productName)) { r = ref; } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 d87d983..9a04a6d 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 @@ -162,18 +162,18 @@ public class PGEConfigFileReader { PGEGroup pgeGroup = new PGEGroup(group.getAttribute("name")); - for (Iterator i = scalars.iterator(); i.hasNext();) { - PGEScalar s = (PGEScalar) i.next(); + for (Object scalar : scalars) { + PGEScalar s = (PGEScalar) scalar; pgeGroup.addScalar(s); } - for (Iterator i = vectors.iterator(); i.hasNext();) { - PGEVector v = (PGEVector) i.next(); + for (Object vector : vectors) { + PGEVector v = (PGEVector) vector; pgeGroup.addVector(v); } - for (Iterator i = matrixs.iterator(); i.hasNext();) { - PGEMatrix m = (PGEMatrix) i.next(); + for (Object matrix : matrixs) { + PGEMatrix m = (PGEMatrix) matrix; pgeGroup.addMatrix(m); } @@ -187,8 +187,8 @@ public class PGEConfigFileReader { List scalars = PGEXMLFileUtils.getScalars(group); if (scalars != null && scalars.size() > 0) { - for (Iterator i = scalars.iterator(); i.hasNext();) { - PGEScalar scalar = (PGEScalar) i.next(); + for (Object scalar1 : scalars) { + PGEScalar scalar = (PGEScalar) scalar1; configFile.getMonitorLevelGroup().addScalar(scalar); } } @@ -208,8 +208,8 @@ public class PGEConfigFileReader { PGEScalar monPath = null, monFilenameFormat = null; - for (Iterator i = scalars.iterator(); i.hasNext();) { - PGEScalar scalar = (PGEScalar) i.next(); + for (Object scalar1 : scalars) { + PGEScalar scalar = (PGEScalar) scalar1; if (scalar.getName().equals("MonitorPath")) { monPath = scalar; @@ -297,8 +297,8 @@ public class PGEConfigFileReader { List scalars = PGEXMLFileUtils.getScalars(group); if (scalars != null && scalars.size() > 0) { - for (Iterator i = scalars.iterator(); i.hasNext();) { - PGEScalar scalar = (PGEScalar) i.next(); + for (Object scalar1 : scalars) { + PGEScalar scalar = (PGEScalar) scalar1; pgeGroup.addScalar(scalar); } } @@ -310,8 +310,8 @@ public class PGEConfigFileReader { List vectors = PGEXMLFileUtils.getVectors(group); if (vectors != null && vectors.size() > 0) { - for (Iterator i = vectors.iterator(); i.hasNext();) { - PGEVector vector = (PGEVector) i.next(); + for (Object vector1 : vectors) { + PGEVector vector = (PGEVector) vector1; pgeGroup.addVector(vector); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 0ae1162..165da6d 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 @@ -159,9 +159,7 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } // write the pge specific groups - for (Iterator i = configFile.getPgeSpecificGroups().keySet().iterator(); i - .hasNext();) { - String pgeSpecificGroupName = (String) i.next(); + for (String pgeSpecificGroupName : configFile.getPgeSpecificGroups().keySet()) { PGEGroup pgeSpecificGroup = (PGEGroup) configFile .getPgeSpecificGroups().get(pgeSpecificGroupName); @@ -191,8 +189,7 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, groupElem.setAttribute(NAME_ATTR, group.getName()); if (group.getNumScalars() > 0) { - for (Iterator i = group.getScalars().keySet().iterator(); i.hasNext();) { - String scalarName = (String) i.next(); + for (String scalarName : group.getScalars().keySet()) { PGEScalar scalar = group.getScalar(scalarName); Element scalarElem = document.createElement(SCALAR_TAG_NAME); @@ -200,7 +197,7 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, if (scalar.getValue() == null) { throw new Exception("Attempt to write null value for scalar: [" - + scalarName + "] to PGE config file!"); + + scalarName + "] to PGE config file!"); } if (urlEncoding) { @@ -210,8 +207,8 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } catch (UnsupportedEncodingException e) { LOG.log(Level.WARNING, "Error creating text node for scalar element: " - + scalar.getName() + " in pge group: " + group.getName() - + " Message: " + e.getMessage()); + + scalar.getName() + " in pge group: " + group.getName() + + " Message: " + e.getMessage()); } } else { @@ -224,19 +221,18 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } if (group.getNumVectors() > 0) { - for (Iterator i = group.getVectors().keySet().iterator(); i.hasNext();) { - String vectorName = (String) i.next(); + for (String vectorName : group.getVectors().keySet()) { PGEVector vector = group.getVector(vectorName); Element vectorElem = document.createElement(VECTOR_TAG_NAME); vectorElem.setAttribute(NAME_ATTR, vector.getName()); - for (Iterator j = vector.getElements().iterator(); j.hasNext();) { - String element = (String) j.next(); + for (Object o : vector.getElements()) { + String element = (String) o; if (element == null) { throw new Exception("Attempt to write null value for vector: [" - + vectorName + "] to PGE config file!"); + + vectorName + "] to PGE config file!"); } Element elementElem = document.createElement(VECTOR_ELEMENT_TAG); @@ -247,8 +243,8 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } catch (UnsupportedEncodingException e) { LOG.log(Level.WARNING, "Error creating text node for vector element: " - + vector.getName() + " in pge group: " + group.getName() - + " Message: " + e.getMessage()); + + vector.getName() + " in pge group: " + group.getName() + + " Message: " + e.getMessage()); } } else { elementElem.appendChild(document.createTextNode(element)); @@ -262,27 +258,26 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } if (group.getNumMatrixs() > 0) { - for (Iterator i = group.getMatrixs().keySet().iterator(); i.hasNext();) { - String matrixName = (String) i.next(); + for (String matrixName : group.getMatrixs().keySet()) { PGEMatrix matrix = group.getMatrix(matrixName); Element matrixElem = document.createElement(MATRIX_TAG_NAME); matrixElem.setAttribute(NAME_ATTR, matrix.getName()); int rowNum = 0; - for (Iterator j = matrix.getRows().iterator(); j.hasNext();) { - List rowValues = (List) j.next(); + for (List<Object> objects : matrix.getRows()) { + List rowValues = (List) objects; Element rowElem = document.createElement(MATRIX_ROW_TAG); int colNum = 0; - for (Iterator k = rowValues.iterator(); k.hasNext();) { - String colValue = (String) k.next(); + for (Object rowValue : rowValues) { + String colValue = (String) rowValue; Element colElem = document.createElement(MATRIX_COL_TAG); if (colValue == null) { throw new Exception("Attempt to write null value for matrix: [" - + matrixName + "]: " + "(" + rowNum + "," + colNum + ")"); + + matrixName + "]: " + "(" + rowNum + "," + colNum + ")"); } if (urlEncoding) { @@ -292,9 +287,9 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } catch (UnsupportedEncodingException e) { LOG.log(Level.WARNING, "Error creating node for matrix element: " - + matrix.getName() + " (" + rowNum + "," + colNum - + ") in pge group: " + group.getName() + " Message: " - + e.getMessage()); + + matrix.getName() + " (" + rowNum + "," + colNum + + ") in pge group: " + group.getName() + " Message: " + + e.getMessage()); } } else { @@ -312,8 +307,7 @@ public final class PGEConfigFileWriter implements PGEConfigFileKeys, } if (group.getNumGroups() > 0) { - for (Iterator i = group.getGroups().keySet().iterator(); i.hasNext();) { - String groupName = (String) i.next(); + for (String groupName : group.getGroups().keySet()) { PGEGroup subgroup = group.getGroup(groupName); Element subgroupElem = getGroupElement(subgroup, document); groupElem.appendChild(subgroupElem); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 e4c8581..f5c28e0 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 @@ -99,15 +99,16 @@ public abstract class AbstractCrawlLister implements OFSNListHandler { productFiles = dir.listFiles(FILE_FILTER); } - for (int j = 0; j < productFiles.length; j++) { - fileList.add(productFiles[j]); + for (File productFile : productFiles) { + fileList.add(productFile); } if (recur) { File[] subdirs = dir.listFiles(DIR_FILTER); if (subdirs != null) - for (int j = 0; j < subdirs.length; j++) - stack.push(subdirs[j]); + for (File subdir : subdirs) { + stack.push(subdir); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java index ca29c9c..bd119d6 100644 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java +++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/URLGetHandler.java @@ -171,11 +171,11 @@ public class URLGetHandler extends AbstractCrawlLister implements OFSNGetHandler // convert each crawled file's path into an OFSN download link StringBuilder stringBuilder = new StringBuilder(); - for (int i=0; i < fileListing.length; i++) { - File file = (File) fileListing[i]; - stringBuilder.append(buildOFSNURL(file).toString()); - stringBuilder.append("\n"); - } + for (File aFileListing : fileListing) { + File file = (File) aFileListing; + stringBuilder.append(buildOFSNURL(file).toString()); + stringBuilder.append("\n"); + } return stringBuilder.toString(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java index c644f79..a0aa99c 100644 --- a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java @@ -76,11 +76,11 @@ public class EnumeratedProfileElement extends ProfileElement { protected void addValues(Node node) throws DOMException { if (values == null) return; - for (Iterator<?> i = values.iterator(); i.hasNext();) { - Element e = node.getOwnerDocument().createElement("elemValue"); - e.appendChild(node.getOwnerDocument().createCDATASection((String) i.next())); - node.appendChild(e); - } + for (Object value : values) { + Element e = node.getOwnerDocument().createElement("elemValue"); + e.appendChild(node.getOwnerDocument().createCDATASection((String) value)); + node.appendChild(e); + } } public String getMinValue() { http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/Profile.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Profile.java b/profile/src/main/java/org/apache/oodt/profile/Profile.java index 7fab8ec..2cb6184 100644 --- a/profile/src/main/java/org/apache/oodt/profile/Profile.java +++ b/profile/src/main/java/org/apache/oodt/profile/Profile.java @@ -269,10 +269,9 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc public void addToModel(Model model) { Resource resource = model.createResource(getURI().toString()); resAttr.addToModel(model, resource, profAttr); - for (Iterator<ProfileElement> i = elements.values().iterator(); i.hasNext();) { - ProfileElement e = (ProfileElement) i.next(); - e.addToModel(model, resource, profAttr); - } + for (ProfileElement e : elements.values()) { + e.addToModel(model, resource, profAttr); + } } /** @@ -309,8 +308,10 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc Element profile = doc.createElement("profile"); profile.appendChild(profAttr.toXML(doc)); profile.appendChild(resAttr.toXML(doc)); - if (withElements) for (Iterator<ProfileElement> i = elements.values().iterator(); i.hasNext();) - profile.appendChild(((ProfileElement) i.next()).toXML(doc)); + if (withElements) + for (ProfileElement profileElement : elements.values()) { + profile.appendChild((profileElement).toXML(doc)); + } return profile; } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java index d2c3f23..6224177 100644 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java +++ b/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java @@ -526,10 +526,10 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara */ public static Set<Profile> profiles(Set<?> elements) { Set<Profile> rc = new HashSet<Profile>(); - for (Iterator<?> i = elements.iterator(); i.hasNext();) { - ProfileElement element = (ProfileElement) i.next(); - rc.add(element.getProfile()); - } + for (Object element1 : elements) { + ProfileElement element = (ProfileElement) element1; + rc.add(element.getProfile()); + } return rc; } @@ -543,11 +543,12 @@ public abstract class ProfileElement implements Serializable, Cloneable, Compara */ public static Set<ProfileElement> elements(Set<?> profiles, Set<?> elements) { Set<ProfileElement> rc = new HashSet<ProfileElement>(); - for (Iterator<?> i = elements.iterator(); i.hasNext();) { - ProfileElement element = (ProfileElement) i.next(); - if (profiles.contains(element.getProfile())) - rc.add(element); + for (Object element1 : elements) { + ProfileElement element = (ProfileElement) element1; + if (profiles.contains(element.getProfile())) { + rc.add(element); } + } return rc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/Utility.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Utility.java b/profile/src/main/java/org/apache/oodt/profile/Utility.java index 2e6517f..a5b74da 100644 --- a/profile/src/main/java/org/apache/oodt/profile/Utility.java +++ b/profile/src/main/java/org/apache/oodt/profile/Utility.java @@ -60,8 +60,9 @@ class Utility { Collection<?> collection = (Collection<?>) value; if (collection.isEmpty()) return; Bag bag = model.createBag(uri + "_" + property.getLocalName() + "_bag"); - for (Iterator<?> i = collection.iterator(); i.hasNext();) - bag.add(i.next()); + for (Object aCollection : collection) { + bag.add(aCollection); + } resource.addProperty(property, bag); obj = bag; } else { @@ -87,16 +88,18 @@ class Utility { List<?> children = profAttr.getChildren(); if (!children.isEmpty()) { Bag bag = model.createBag(uri + "_" + property.getLocalName() + "_childrenBag"); - for (Iterator<?> i = children.iterator(); i.hasNext();) - bag.add(i.next()); + for (Object aChildren : children) { + bag.add(aChildren); + } reification.addProperty(edmChild, bag); } List<?> revNotes = profAttr.getRevisionNotes(); if (!revNotes.isEmpty()) { Seq seq = model.createSeq(uri + "_" + property.getLocalName() + "_revNotesSeq"); - for (Iterator<?> i = revNotes.iterator(); i.hasNext();) - seq.add(i.next()); + for (Object revNote : revNotes) { + seq.add(revNote); + } reification.addProperty(edmRevNote, seq); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileAttributesPrinter.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileAttributesPrinter.java b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileAttributesPrinter.java index 01d57af..614d122 100755 --- a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileAttributesPrinter.java +++ b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileAttributesPrinter.java @@ -55,18 +55,18 @@ public class ProfileAttributesPrinter { rStr+="\t<profStatusId>"+myProfAttributes.getStatusID()+"</profStatusId>\n"; rStr+="\t<profSecurityType>"+myProfAttributes.getSecurityType()+"</profSecurityType>\n"; rStr+="\t<profParentId>"+myProfAttributes.getParent()+"</profParentId>\n"; - - for(Iterator i = myProfAttributes.getChildren().iterator(); i.hasNext(); ){ - String theChild = (String)i.next(); - rStr+="\t<profChildId>"+theChild+"</profChildId>\n"; - } + + for (Object o1 : myProfAttributes.getChildren()) { + String theChild = (String) o1; + rStr += "\t<profChildId>" + theChild + "</profChildId>\n"; + } rStr+="\t<profRegAuthority>"+myProfAttributes.getRegAuthority()+"</profRegAuthority>\n"; - - for(Iterator i = myProfAttributes.getRevisionNotes().iterator(); i.hasNext(); ){ - String theNote = (String)i.next(); - rStr+="\t<profRevisionNote>"+theNote+"</profRevisionNote>\n"; - } + + for (Object o : myProfAttributes.getRevisionNotes()) { + String theNote = (String) o; + rStr += "\t<profRevisionNote>" + theNote + "</profRevisionNote>\n"; + } rStr+="</profAttributes>\n\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileElementPrinter.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileElementPrinter.java b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileElementPrinter.java index 55e9896..3f8c260 100755 --- a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileElementPrinter.java +++ b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfileElementPrinter.java @@ -52,11 +52,11 @@ public class ProfileElementPrinter { rStr+="\t<elemMaxOccurrence>"+myProfileElement.getMaxOccurrence()+"</elemMaxOccurrence>\n"; rStr+="\t<elemMaxValue>"+myProfileElement.getMaxValue()+"</elemMaxValue>\n"; rStr+="\t<elemMinValue>"+myProfileElement.getMinValue()+"</elemMinValue>\n"; - - for(Iterator i = myProfileElement.getValues().iterator(); i.hasNext(); ){ - String theValue = (String)i.next(); - rStr+="<elemValue>"+theValue+"</elemValue>\n"; - } + + for (Object o : myProfileElement.getValues()) { + String theValue = (String) o; + rStr += "<elemValue>" + theValue + "</elemValue>\n"; + } rStr+="\t<elemComment>"+myProfileElement.getComments()+"</elemComment>\n"; rStr+="</profElement>\n"; return rStr; http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfilePrinter.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfilePrinter.java b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfilePrinter.java index 22f52a9..2909ea8 100755 --- a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfilePrinter.java +++ b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ProfilePrinter.java @@ -64,14 +64,12 @@ public class ProfilePrinter { ResourceAttributesPrinter rap = new ResourceAttributesPrinter(myProfile.getResourceAttributes()); rStr+=rap.toXMLString(); - - for(Iterator i = myProfile.getProfileElements().keySet().iterator(); i.hasNext(); ){ - String profElemName = (String)i.next(); - - ProfileElement pe = (ProfileElement)myProfile.getProfileElements().get(profElemName); - ProfileElementPrinter pPrinter = new ProfileElementPrinter(pe); - rStr+=pPrinter.toXMLString(); - } + + for (String profElemName : myProfile.getProfileElements().keySet()) { + ProfileElement pe = (ProfileElement) myProfile.getProfileElements().get(profElemName); + ProfileElementPrinter pPrinter = new ProfileElementPrinter(pe); + rStr += pPrinter.toXMLString(); + } rStr+="</profile>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ResourceAttributesPrinter.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ResourceAttributesPrinter.java b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ResourceAttributesPrinter.java index 0bc1a90..81a7932 100755 --- a/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ResourceAttributesPrinter.java +++ b/profile/src/main/java/org/apache/oodt/profile/gui/pstructs/ResourceAttributesPrinter.java @@ -60,70 +60,57 @@ public class ResourceAttributesPrinter { rStr+="\t<resClass>"+resAttr.getResClass()+"</resClass>\n"; rStr+="\t<resAggregation>"+resAttr.getResAggregation()+"</resAggregation>\n"; - for(Iterator i = resAttr.getRights().iterator(); i.hasNext(); ){ - String theRight = (String)i.next(); - rStr+="\t<Right>"+theRight+"</Right>\n"; - } - - for(Iterator i = resAttr.getSources().iterator(); i.hasNext(); ){ - String theSource = (String)i.next(); - rStr+="\t<Source>"+theSource+"</Source>\n"; - } - - for(Iterator i = resAttr.getSubjects().iterator(); i.hasNext(); ){ - String theSubject = (String)i.next(); - rStr+="\t<Subject>"+theSubject+"</Subject>\n"; - } - - for(Iterator i = resAttr.getFormats().iterator(); i.hasNext(); ){ - String theFormat = (String)i.next(); - rStr+="\t<Format>"+theFormat+"</Format>\n"; - } - - for(Iterator i = resAttr.getCreators().iterator(); i.hasNext(); ){ - String theCreator = (String)i.next(); - rStr+="\t<Creator>"+theCreator+"</Creator>\n"; - } - - for(Iterator i = resAttr.getPublishers().iterator(); i.hasNext(); ){ - String thePublisher = (String)i.next(); - rStr+="\t<Publisher>"+thePublisher+"</Publisher>\n"; - } - - for(Iterator i = resAttr.getTypes().iterator(); i.hasNext(); ){ - String theType = (String)i.next(); - rStr+="\t<Type>"+theType+"</Type>\n"; - } - - for(Iterator i = resAttr.getResContexts().iterator(); i.hasNext(); ){ - String theContext = (String)i.next(); - rStr+="\t<resContext>"+theContext+"</resContext>\n"; - } - - for(Iterator i = resAttr.getResLocations().iterator(); i.hasNext(); ){ - String theLocation = (String)i.next(); - rStr+="\t<resLocation>"+theLocation+"</resLocation>\n"; - } - - for(Iterator i = resAttr.getContributors().iterator(); i.hasNext(); ){ - String theContributor = (String)i.next(); - rStr+="\t<Contributor>"+theContributor+"</Contributor>\n"; - } - - for(Iterator i = resAttr.getCoverages().iterator(); i.hasNext(); ){ - String theCoverage = (String)i.next(); - rStr+="\t<Coverage>"+theCoverage+"</Coverage>\n"; - } - - for(Iterator i = resAttr.getLanguages().iterator(); i.hasNext(); ){ - String theLang = (String)i.next(); - rStr+="\t<Language>"+theLang+"</Language>\n"; - } - - for(Iterator i = resAttr.getRelations().iterator(); i.hasNext(); ){ - String theRelation = (String)i.next(); - rStr+="\t<Relation>"+theRelation+"</Relation>\n"; - } + for (String theRight : resAttr.getRights()) { + rStr += "\t<Right>" + theRight + "</Right>\n"; + } + + for (String theSource : resAttr.getSources()) { + rStr += "\t<Source>" + theSource + "</Source>\n"; + } + + for (String theSubject : resAttr.getSubjects()) { + rStr += "\t<Subject>" + theSubject + "</Subject>\n"; + } + + for (String theFormat : resAttr.getFormats()) { + rStr += "\t<Format>" + theFormat + "</Format>\n"; + } + + for (String theCreator : resAttr.getCreators()) { + rStr += "\t<Creator>" + theCreator + "</Creator>\n"; + } + + for (String thePublisher : resAttr.getPublishers()) { + rStr += "\t<Publisher>" + thePublisher + "</Publisher>\n"; + } + + for (String theType : resAttr.getTypes()) { + rStr += "\t<Type>" + theType + "</Type>\n"; + } + + for (String theContext : resAttr.getResContexts()) { + rStr += "\t<resContext>" + theContext + "</resContext>\n"; + } + + for (String theLocation : resAttr.getResLocations()) { + rStr += "\t<resLocation>" + theLocation + "</resLocation>\n"; + } + + for (String theContributor : resAttr.getContributors()) { + rStr += "\t<Contributor>" + theContributor + "</Contributor>\n"; + } + + for (String theCoverage : resAttr.getCoverages()) { + rStr += "\t<Coverage>" + theCoverage + "</Coverage>\n"; + } + + for (String theLang : resAttr.getLanguages()) { + rStr += "\t<Language>" + theLang + "</Language>\n"; + } + + for (String theRelation : resAttr.getRelations()) { + rStr += "\t<Relation>" + theRelation + "</Relation>\n"; + } rStr+="</resAttributes>\n"; http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/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 ceb9baa..1ef17a1 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 @@ -99,8 +99,8 @@ public class CASProfileHandler implements ProfileHandler { List profs = new Vector(); if (productTypeFilter != null && productTypeFilter.size() > 0) { - for (Iterator i = productTypeFilter.iterator(); i.hasNext();) { - ProductType type = (ProductType) i.next(); + for (Object aProductTypeFilter : productTypeFilter) { + ProductType type = (ProductType) aProductTypeFilter; Query cQuery = convertQuery(query); profs.addAll(queryAndBuildProfiles(type, cQuery)); @@ -264,13 +264,13 @@ public class CASProfileHandler implements ProfileHandler { products = fmClient.query(query, type); if (products != null && products.size() > 0) { - for (Iterator i = products.iterator(); i.hasNext();) { - Product p = (Product) i.next(); + for (Object product : products) { + Product p = (Product) product; p.setProductReferences(safeGetProductReferences(p)); Metadata met = safeGetMetadata(p); try { profiles.add(ProfileUtils.buildProfile(p, met, - dataDelivBaseUrlStr)); + dataDelivBaseUrlStr)); } catch (Exception e) { e.printStackTrace(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/handlers/cas/util/ProfileUtils.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/cas/util/ProfileUtils.java b/profile/src/main/java/org/apache/oodt/profile/handlers/cas/util/ProfileUtils.java index 9338c73..7a2b379 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/cas/util/ProfileUtils.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/cas/util/ProfileUtils.java @@ -90,12 +90,11 @@ public final class ProfileUtils { prof.setResourceAttributes(resAttrs); // build up profile elements - for(Iterator i = met.getHashtable().keySet().iterator(); i.hasNext(); ){ - String key = (String)i.next(); + for (String key : met.getHashtable().keySet()) { List vals = met.getAllMetadata(key); - + EnumeratedProfileElement elem = new EnumeratedProfileElement(prof); - System.out.println("Adding ["+key+"]=>"+vals); + System.out.println("Adding [" + key + "]=>" + vals); elem.setName(key); elem.getValues().addAll(vals); prof.getProfileElements().put(key, elem); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java index c31db1c..8994028 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServer.java @@ -134,16 +134,17 @@ final public class LightweightProfileServer implements ProfileHandler { WhereExpression whereExpression = createWhereExpression(query); // Search each profile, and add the results of the search to the set of results. - for (Iterator i = profiles.iterator(); i.hasNext();) { - SearchableProfile profile = (SearchableProfile) i.next(); + for (Object profile1 : profiles) { + SearchableProfile profile = (SearchableProfile) profile1; - // Search the profile with the where-expression. - Result result = profile.search(whereExpression); + // Search the profile with the where-expression. + Result result = profile.search(whereExpression); - // If there are any matching elements, add the profile to the set. - if (!result.matchingElements().isEmpty()) - matchingProfiles.add(profile); + // If there are any matching elements, add the profile to the set. + if (!result.matchingElements().isEmpty()) { + matchingProfiles.add(profile); } + } // Convert from set to list. return new ArrayList(matchingProfiles); @@ -158,13 +159,13 @@ final public class LightweightProfileServer implements ProfileHandler { public Profile get(String profID) { if (profID == null) return null; Profile rc = null; - for (Iterator i = profiles.iterator(); i.hasNext();) { - Profile p = (Profile) i.next(); - if (p.getProfileAttributes().getID().equals(profID)) { - rc = p; - break; - } + for (Object profile : profiles) { + Profile p = (Profile) profile; + if (p.getProfileAttributes().getID().equals(profID)) { + rc = p; + break; } + } return rc; } @@ -186,36 +187,38 @@ final public class LightweightProfileServer implements ProfileHandler { } // For each item in the where-set - for (Iterator i = allElements.iterator(); i.hasNext();) { - QueryElement queryElement = (QueryElement) i.next(); - - // Get the keyword and its type. - String keyword = queryElement.getValue(); - String type = queryElement.getRole(); - - if (type.equals("elemName")) { - // It's an element name, so push the element name. - stack.push(keyword); - } else if (type.equals("LITERAL")) { - // It's a literal value, so push the value. - stack.push(keyword); - } else if (type.equals("LOGOP")) { - // It's a logical operator. Pop the operands off the - // stack and push the appropriate operator back on. - if (keyword.equals("AND")) { - stack.push(new AndExpression((WhereExpression) stack.pop(), (WhereExpression)stack.pop())); - } else if (keyword.equals("OR")) { - stack.push(new OrExpression((WhereExpression) stack.pop(), (WhereExpression)stack.pop())); - } else if (keyword.equals("NOT")) { - stack.push(new NotExpression((WhereExpression) stack.pop())); - } else throw new IllegalArgumentException("Illegal operator \"" + keyword + "\" in query"); - } else if (type.equals("RELOP")) { - // It's a relational operator. Pop the element name and - // literal value off the stack, and push the operator - // expression on with the given operator. - stack.push(new OperatorExpression((String) stack.pop(), (String) stack.pop(), keyword)); - } + for (Object allElement : allElements) { + QueryElement queryElement = (QueryElement) allElement; + + // Get the keyword and its type. + String keyword = queryElement.getValue(); + String type = queryElement.getRole(); + + if (type.equals("elemName")) { + // It's an element name, so push the element name. + stack.push(keyword); + } else if (type.equals("LITERAL")) { + // It's a literal value, so push the value. + stack.push(keyword); + } else if (type.equals("LOGOP")) { + // It's a logical operator. Pop the operands off the + // stack and push the appropriate operator back on. + if (keyword.equals("AND")) { + stack.push(new AndExpression((WhereExpression) stack.pop(), (WhereExpression) stack.pop())); + } else if (keyword.equals("OR")) { + stack.push(new OrExpression((WhereExpression) stack.pop(), (WhereExpression) stack.pop())); + } else if (keyword.equals("NOT")) { + stack.push(new NotExpression((WhereExpression) stack.pop())); + } else { + throw new IllegalArgumentException("Illegal operator \"" + keyword + "\" in query"); + } + } else if (type.equals("RELOP")) { + // It's a relational operator. Pop the element name and + // literal value off the stack, and push the operator + // expression on with the given operator. + stack.push(new OperatorExpression((String) stack.pop(), (String) stack.pop(), keyword)); } + } // If there's nothing on the stack, we're given nothing, so give back everything. if (stack.size() == 0) @@ -272,8 +275,9 @@ final public class LightweightProfileServer implements ProfileHandler { // Gather together the command-line arguments into a single long string. StringBuilder b = new StringBuilder(); - for (int i = 0; i < argv.length; ++i) - b.append(argv[i]).append(' '); + for (String anArgv : argv) { + b.append(anArgv).append(' '); + } // Create the query object from the expression. XMLQuery query = new XMLQuery(b.toString().trim(), /*id*/"cli1", /*title*/"CmdLine-1", http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java index 9ba2f98..854a63f 100644 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/lightweight/SearchableResourceAttributes.java @@ -117,11 +117,13 @@ public class SearchableResourceAttributes extends ResourceAttributes { else if ("NE".equals(op) || "NOTLIKE".equals(op)) if (!a.contains(b)) rc = t; else if ("LT".equals(op) || "GT".equals(op) || "LE".equals(op) || "GE".equals(op)) { - for (Iterator i = a.iterator(); i.hasNext();) { - String value = (String) i.next(); + for (Object anA : a) { + String value = (String) anA; rc = computeResult(value, b, op); - if (rc != f) break; - } + if (rc != f) { + break; + } + } } else throw new IllegalArgumentException("Unknown relational operator \"" + op + "\""); return rc; } http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java ---------------------------------------------------------------------- diff --git a/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java b/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java index 8c7c134..6c0f263 100644 --- a/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java +++ b/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java @@ -106,16 +106,18 @@ public class LightweightProfileServerTest extends TestCase { // And again, but spanning profiles profiles = doSearch("TEST2 = 48 OR TEST4 = 192"); assertEquals(2, profiles.size()); - for (Iterator i = profiles.iterator(); i.hasNext();) { - profile = (SearchableProfile) i.next(); - elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - if (profile.getProfileAttributes().getID().equals("PROFILE1")) { - assertTrue(elements.containsKey("TEST2")); - } else if (profile.getProfileAttributes().getID().equals("PROFILE2")) { - assertTrue(elements.containsKey("TEST4")); - } else fail("Profile \"" + profile.getProfileAttributes().getID() + "\" matched, but shouldn't"); + for (Object profile1 : profiles) { + profile = (SearchableProfile) profile1; + elements = profile.getProfileElements(); + assertEquals(3, elements.size()); + if (profile.getProfileAttributes().getID().equals("PROFILE1")) { + assertTrue(elements.containsKey("TEST2")); + } else if (profile.getProfileAttributes().getID().equals("PROFILE2")) { + assertTrue(elements.containsKey("TEST4")); + } else { + fail("Profile \"" + profile.getProfileAttributes().getID() + "\" matched, but shouldn't"); } + } // And again, but with a query on the "from" part. profiles = doSearch("( TEST2 = 48 OR TEST4 = 192 ) AND Creator = Alice"); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java index fdc0f3c..d55b08b 100644 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java +++ b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java @@ -105,13 +105,13 @@ public class CommonsNetFtpProtocol implements Protocol { String path = this.pwd().getPath(); FTPFile[] files = ftp.listFiles(); List<ProtocolFile> returnFiles = new LinkedList<ProtocolFile>(); - for (int i = 0; i < files.length; i++) { - FTPFile file = files[i]; - if (file == null) - continue; - returnFiles.add(new ProtocolFile(path + "/" + file.getName(), file - .isDirectory())); + for (FTPFile file : files) { + if (file == null) { + continue; } + returnFiles.add(new ProtocolFile(path + "/" + file.getName(), file + .isDirectory())); + } return returnFiles; } catch (Exception e) { throw new ProtocolException("Failed to get file list : " + e.getMessage()); @@ -126,17 +126,17 @@ public class CommonsNetFtpProtocol implements Protocol { try { FTPFile[] files = ftp.listFiles(); List<ProtocolFile> returnFiles = new LinkedList<ProtocolFile>(); - for (int i = 0; i < files.length; i++) { - FTPFile file = files[i]; - if (file == null) - continue; - String path = this.pwd().getPath(); - ProtocolFile pFile = new ProtocolFile(path + "/" + file.getName(), file - .isDirectory()); - if (filter.accept(pFile)) { - returnFiles.add(pFile); - } + for (FTPFile file : files) { + if (file == null) { + continue; + } + String path = this.pwd().getPath(); + ProtocolFile pFile = new ProtocolFile(path + "/" + file.getName(), file + .isDirectory()); + if (filter.accept(pFile)) { + returnFiles.add(pFile); } + } return returnFiles; } catch (Exception e) { throw new ProtocolException("Failed to get file list : " + e.getMessage()); http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgr.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgr.java b/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgr.java index 806305a..4d28cb8 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgr.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgr.java @@ -148,12 +148,12 @@ public class XmlRpcBatchMgr implements Batchmgr { Vector<String> jobIds = new Vector(); if(this.nodeToJobMap.size() > 0){ - for(Iterator i = this.nodeToJobMap.keySet().iterator(); i.hasNext(); ){ - String jobId = (String)i.next(); - if(nodeId.equals(this.nodeToJobMap.get(jobId))){ - jobIds.add(jobId); - } - } + for (Object o : this.nodeToJobMap.keySet()) { + String jobId = (String) o; + if (nodeId.equals(this.nodeToJobMap.get(jobId))) { + jobIds.add(jobId); + } + } } Collections.sort(jobIds); // sort the list to return as a courtesy to the user http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/resource/src/main/java/org/apache/oodt/cas/resource/noderepo/XmlNodeRepository.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/noderepo/XmlNodeRepository.java b/resource/src/main/java/org/apache/oodt/cas/resource/noderepo/XmlNodeRepository.java index c40cbe5..6adf58f 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/noderepo/XmlNodeRepository.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/noderepo/XmlNodeRepository.java @@ -83,26 +83,28 @@ public class XmlNodeRepository implements NodeRepository { // get all the workflow xml files File[] nodesFiles = nodesDir.listFiles(nodesXmlFilter); - for (int j = 0; j < nodesFiles.length; j++) { - - String nodesXmlFile = nodesFiles[j].getAbsolutePath(); - Document nodesRoot = null; - try { - nodesRoot = XMLUtils - .getDocumentRoot(new FileInputStream( - nodesFiles[j])); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - - NodeList nodeList = nodesRoot - .getElementsByTagName("node"); - if (nodeList != null) - for (int k = 0; k < nodeList.getLength(); k++) - nodes.add(XmlStructFactory - .getNodes((Element) nodeList.item(k))); + for (File nodesFile : nodesFiles) { + + String nodesXmlFile = nodesFile.getAbsolutePath(); + Document nodesRoot = null; + try { + nodesRoot = XMLUtils + .getDocumentRoot(new FileInputStream( + nodesFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; } + + NodeList nodeList = nodesRoot + .getElementsByTagName("node"); + if (nodeList != null) { + for (int k = 0; k < nodeList.getLength(); k++) { + nodes.add(XmlStructFactory + .getNodes((Element) nodeList.item(k))); + } + } + } } } catch (URISyntaxException e) { LOG.log(Level.WARNING, "DirUri: " + dirUri http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/resource/src/main/java/org/apache/oodt/cas/resource/queuerepo/XmlQueueRepository.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/queuerepo/XmlQueueRepository.java b/resource/src/main/java/org/apache/oodt/cas/resource/queuerepo/XmlQueueRepository.java index a6ac289..aad472c 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/queuerepo/XmlQueueRepository.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/queuerepo/XmlQueueRepository.java @@ -74,87 +74,82 @@ public class XmlQueueRepository implements QueueRepository { QueueManager queueManager = new QueueManager(); if (dirUris != null && dirUris.size() > 0) { - for (Iterator i = dirUris.iterator(); i.hasNext();) { - String dirUri = (String) i.next(); + for (String dirUri : dirUris) { + try { + File nodesDir = new File(new URI(dirUri)); + if (nodesDir.isDirectory()) { - try { - File nodesDir = new File(new URI(dirUri)); - if (nodesDir.isDirectory()) { + String nodesDirStr = nodesDir.getAbsolutePath(); - String nodesDirStr = nodesDir.getAbsolutePath(); + if (!nodesDirStr.endsWith("/")) { + nodesDirStr += "/"; + } - if (!nodesDirStr.endsWith("/")) { - nodesDirStr += "/"; - } + // get all the workflow xml files + File[] nodesFiles = nodesDir.listFiles(queuesXmlFilter); + + for (File nodesFile : nodesFiles) { - // get all the workflow xml files - File[] nodesFiles = nodesDir.listFiles(queuesXmlFilter); - - for (int j = 0; j < nodesFiles.length; j++) { - - String nodesXmlFile = nodesFiles[j] - .getAbsolutePath(); - Document nodesRoot = null; - try { - nodesRoot = XMLUtils - .getDocumentRoot(new FileInputStream( - nodesFiles[j])); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - - NodeList nodeList = nodesRoot - .getElementsByTagName("node"); - - if (nodeList != null && nodeList.getLength() > 0) { - for (int k = 0; k < nodeList.getLength(); k++) { - - String nodeId = ((Element) nodeList.item(k)) - .getAttribute("id"); - Vector assignments = (Vector) XmlStructFactory - .getQueueAssignment((Element) nodeList - .item(k)); - for (int l = 0; l < assignments.size(); l++) { - try { - // make sure queue exists - queueManager - .addQueue((String) assignments - .get(l)); - // add node to queue - queueManager - .addNodeToQueue(nodeId, - (String) assignments - .get(l)); - } catch (Exception e) { - LOG - .log( - Level.WARNING, - "Failed to add node '" - + nodeId - + "' to queue '" - + (String) assignments - .get(l) - + "' : " - + e - .getMessage(), - e); - } - } - } - } + String nodesXmlFile = nodesFile + .getAbsolutePath(); + Document nodesRoot = null; + try { + nodesRoot = XMLUtils + .getDocumentRoot(new FileInputStream( + nodesFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } + + NodeList nodeList = nodesRoot + .getElementsByTagName("node"); + + if (nodeList != null && nodeList.getLength() > 0) { + for (int k = 0; k < nodeList.getLength(); k++) { + + String nodeId = ((Element) nodeList.item(k)) + .getAttribute("id"); + Vector assignments = (Vector) XmlStructFactory + .getQueueAssignment((Element) nodeList + .item(k)); + for (Object assignment : assignments) { + try { + // make sure queue exists + queueManager + .addQueue((String) assignment); + // add node to queue + queueManager + .addNodeToQueue(nodeId, + (String) assignment); + } catch (Exception e) { + LOG + .log( + Level.WARNING, + "Failed to add node '" + + nodeId + + "' to queue '" + + (String) assignment + + "' : " + + e + .getMessage(), + e); } + } } - } catch (URISyntaxException e) { - e.printStackTrace(); - LOG - .log( - Level.WARNING, - "DirUri: " - + dirUri - + " is not a directory: skipping node loading for it."); + } } + } + } catch (URISyntaxException e) { + e.printStackTrace(); + LOG + .log( + Level.WARNING, + "DirUri: " + + dirUri + + " is not a directory: skipping node loading for it."); } + } } return queueManager; http://git-wip-us.apache.org/repos/asf/oodt/blob/82cc2da5/resource/src/main/java/org/apache/oodt/cas/resource/structs/NameValueJobInput.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/structs/NameValueJobInput.java b/resource/src/main/java/org/apache/oodt/cas/resource/structs/NameValueJobInput.java index a7fcb7a..c178f64 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/structs/NameValueJobInput.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/structs/NameValueJobInput.java @@ -77,8 +77,8 @@ public class NameValueJobInput implements JobInput { } Hashtable readable = (Hashtable) in; - for (Iterator i = readable.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (Object o : readable.keySet()) { + String key = (String) o; String value = (String) readable.get(key); this.props.setProperty(key, value); } @@ -93,8 +93,8 @@ public class NameValueJobInput implements JobInput { public Object write() { Hashtable writeable = new Hashtable(); if (props != null && props.size() > 0) { - for (Iterator i = props.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; String val = props.getProperty(key); writeable.put(key, val); }
