OODT-896 fix inefficient constructors
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/d5dfd9f1 Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/d5dfd9f1 Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/d5dfd9f1 Branch: refs/heads/master Commit: d5dfd9f1b2b49b118c7cc2096e4c4f8ad98f78a7 Parents: 64b200a Author: Tom Barber <[email protected]> Authored: Sat Oct 24 23:08:05 2015 +0100 Committer: Tom Barber <[email protected]> Committed: Sat Oct 24 23:08:05 2015 +0100 ---------------------------------------------------------------------- CHANGES.txt | 2 + .../browser/controller/TableListener.java | 23 ++- .../filemgr/browser/view/panels/TablePane.java | 4 +- .../XmlRpcCommunicationChannelClient.java | 28 ++- .../apache/oodt/cas/cli/util/CmdLineUtils.java | 6 +- .../apache/oodt/commons/filter/TimeEvent.java | 2 +- .../oodt/commons/object/jndi/ObjectContext.java | 60 ++++--- .../oodt/commons/object/jndi/RMIContext.java | 2 +- .../org/apache/oodt/commons/util/XMLRPC.java | 53 ++++-- .../filemgr/system/XmlRpcFileManagerClient.java | 180 +++++++++---------- .../cas/filemgr/util/XmlRpcStructFactory.java | 107 +++++------ .../org/apache/oodt/grid/ConfigServlet.java | 38 ++-- .../ExternPreconditionComparator.java | 15 +- .../preconditions/FileSizeComparator.java | 2 +- .../apache/oodt/profile/gui/LeafListener.java | 41 +++-- .../oodt/cas/pushpull/daemon/DaemonManager.java | 4 +- .../oodt/cas/pushpull/expressions/Method.java | 37 ++-- .../parsers/DirStructXmlParser.java | 5 +- .../oodt/cas/resource/examples/LongJob.java | 4 +- .../oodt/cas/resource/examples/TestResmgr.java | 2 +- .../cas/resource/monitor/AssignmentMonitor.java | 23 +-- .../monitor/ganglia/GangliaResourceMonitor.java | 4 +- .../resource/system/XmlRpcResourceManager.java | 102 +++++------ .../system/XmlRpcResourceManagerClient.java | 46 +++-- .../resource/system/extern/XmlRpcBatchStub.java | 35 ++-- .../IterativeWorkflowProcessorThread.java | 38 ++-- .../workflow/engine/runner/ResourceRunner.java | 13 +- .../lifecycle/WorkflowLifecycleStage.java | 2 +- .../DataSourceWorkflowRepository.java | 5 +- 29 files changed, 433 insertions(+), 450 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 8b3d86f..4534d27 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -25,6 +25,8 @@ Release 0.11 - Current Development * OODT-755 Fix error message in FM client when ingestion fails +* OODT-894 Remove inefficient constructors + Release 0.10 - 08/30/2015 * OODT-871 Issues with OODT 0.10 RC#1 (lewismc, mattmann) http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/controller/TableListener.java ---------------------------------------------------------------------- diff --git a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/controller/TableListener.java b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/controller/TableListener.java index 9aeb5d7..dec6add 100644 --- a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/controller/TableListener.java +++ b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/controller/TableListener.java @@ -17,6 +17,15 @@ package org.apache.oodt.cas.filemgr.browser.controller; +import org.apache.oodt.cas.filemgr.browser.view.menus.RightClickMenu; +import org.apache.oodt.cas.filemgr.browser.view.panels.HeaderCell; +import org.apache.oodt.cas.filemgr.browser.view.panels.HeaderSpacer; +import org.apache.oodt.cas.filemgr.browser.view.panels.Row; +import org.apache.oodt.cas.filemgr.browser.view.panels.TablePane; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -26,16 +35,6 @@ import java.io.FileOutputStream; import javax.swing.JFileChooser; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; - -import org.apache.oodt.cas.filemgr.browser.view.menus.RightClickMenu; -import org.apache.oodt.cas.filemgr.browser.view.panels.HeaderCell; -import org.apache.oodt.cas.filemgr.browser.view.panels.HeaderSpacer; -import org.apache.oodt.cas.filemgr.browser.view.panels.Row; -import org.apache.oodt.cas.filemgr.browser.view.panels.TablePane; - public class TableListener implements MouseListener, ActionListener { private Component caller; @@ -70,7 +69,7 @@ public class TableListener implements MouseListener, ActionListener { if (caller instanceof HeaderSpacer) { HeaderSpacer hsCaller = (HeaderSpacer) caller; if (e.getModifiers() == 18 - && table.hiddenCols.contains(new Integer(hsCaller.getColNum() + 1))) { + && table.hiddenCols.contains(Integer.valueOf(hsCaller.getColNum() + 1))) { rcMenu.setUnhideMode(); rcMenu.show(caller, e.getX(), e.getY()); @@ -130,7 +129,7 @@ public class TableListener implements MouseListener, ActionListener { int i = 0; for (int j = 0; j < table.getRow(0).getComponentCount(); j++) { - if (!table.hiddenCols.contains(new Integer(j))) { + if (!table.hiddenCols.contains(Integer.valueOf(j))) { headerRow.createCell((short) i).setCellValue( table.header.getText(j)); i++; http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java ---------------------------------------------------------------------- diff --git a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java index 9984999..3c096da 100644 --- a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java +++ b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java @@ -135,7 +135,7 @@ public class TablePane extends JPanel{ for(int i=1;i<this.getComponentCount();i++){ ((Row)this.getComponent(i)).hideCol(colNum); } - hiddenCols.add(new Integer(colNum)); + hiddenCols.add(Integer.valueOf(colNum)); } public void unhideColumn(int colNum){ @@ -143,7 +143,7 @@ public class TablePane extends JPanel{ for(int i=1;i<this.getComponentCount();i++){ ((Row)this.getComponent(i)).unhideCol(colNum); } - hiddenCols.remove(new Integer(colNum)); + hiddenCols.remove(Integer.valueOf(colNum)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java index 466ee60..ca98ff2 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java @@ -16,16 +16,6 @@ */ package org.apache.oodt.cas.catalog.server.channel.xmlrpc; -//JDK imports -import java.io.File; -import java.io.FileInputStream; -import java.net.URL; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; - -//OODT imports import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata; import org.apache.oodt.cas.catalog.page.CatalogReceipt; import org.apache.oodt.cas.catalog.page.Page; @@ -40,11 +30,17 @@ import org.apache.oodt.cas.catalog.struct.TransactionId; import org.apache.oodt.cas.catalog.system.Catalog; import org.apache.oodt.cas.catalog.util.PluginURL; import org.apache.oodt.cas.metadata.Metadata; - -//APACHE imports import org.apache.xmlrpc.CommonsXmlRpcTransportFactory; import org.apache.xmlrpc.XmlRpcClient; +import java.io.File; +import java.io.FileInputStream; +import java.net.URL; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.Vector; + /** * @author bfoster * @version $Revision$ @@ -175,7 +171,7 @@ public class XmlRpcCommunicationChannelClient extends AbstractCommunicationChann }finally { try { is.close(); - }catch(Exception e) {} + }catch(Exception ignored) {} } } @@ -184,8 +180,8 @@ public class XmlRpcCommunicationChannelClient extends AbstractCommunicationChann Vector<Object> argList = new Vector<Object>(); argList.add(filePath); argList.add(fileData); - argList.add(new Integer(offset)); - argList.add(new Integer(numBytes)); + argList.add(offset); + argList.add(numBytes); client.execute(XmlRpcCommunicationChannelServer.class.getSimpleName() + ".xmlrpc_transferFile", argList); } @@ -237,7 +233,7 @@ public class XmlRpcCommunicationChannelClient extends AbstractCommunicationChann boolean generateNew) throws Exception { Vector<Object> args = new Vector<Object>(); args.add(this.serializer.serializeObject(catalogReceipt)); - args.add(this.serializer.serializeObject(new Boolean(generateNew))); + args.add(this.serializer.serializeObject(generateNew)); return this.serializer.deserializeObject(TransactionId.class, (String) this.client.execute(XmlRpcCommunicationChannelServer.class.getSimpleName() + ".xmlrpc_getCatalogServiceTransactionId2", args)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java ---------------------------------------------------------------------- diff --git a/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java b/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java index 06df1d2..06e1454 100755 --- a/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java +++ b/cli/src/main/java/org/apache/oodt/cas/cli/util/CmdLineUtils.java @@ -341,7 +341,7 @@ public class CmdLineUtils { return option2.getLongOption() .compareTo(option1.getLongOption()); } else { - return new Integer(thisScore).compareTo(compareScore); + return Integer.valueOf(thisScore).compareTo(compareScore); } } }); @@ -1095,12 +1095,12 @@ public class CmdLineUtils { } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) { List<Object> ints = new LinkedList<Object>(); for (String value : values) - ints.add(new Integer(value)); + ints.add(Integer.valueOf(value)); return ints; } else if (type.equals(Long.class) || type.equals(Long.TYPE)) { List<Object> longs = new LinkedList<Object>(); for (String value : values) - longs.add(new Long(value)); + longs.add(Long.valueOf(value)); return longs; } else if (type.equals(Double.class) || type.equals(Double.TYPE)) { List<Object> doubles = new LinkedList<Object>(); http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/commons/src/main/java/org/apache/oodt/commons/filter/TimeEvent.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/filter/TimeEvent.java b/commons/src/main/java/org/apache/oodt/commons/filter/TimeEvent.java index 386344e..3d5f372 100644 --- a/commons/src/main/java/org/apache/oodt/commons/filter/TimeEvent.java +++ b/commons/src/main/java/org/apache/oodt/commons/filter/TimeEvent.java @@ -89,7 +89,7 @@ public class TimeEvent implements Comparable<TimeEvent> { } public int compareTo(TimeEvent te) { - return new Long(this.startTime).compareTo(te.startTime); + return Long.valueOf(this.startTime).compareTo(te.startTime); } public static List<? extends TimeEvent> getTimeOrderedEvents(List<? extends TimeEvent> events) { http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/commons/src/main/java/org/apache/oodt/commons/object/jndi/ObjectContext.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/object/jndi/ObjectContext.java b/commons/src/main/java/org/apache/oodt/commons/object/jndi/ObjectContext.java index 1bd38d2..9785694 100644 --- a/commons/src/main/java/org/apache/oodt/commons/object/jndi/ObjectContext.java +++ b/commons/src/main/java/org/apache/oodt/commons/object/jndi/ObjectContext.java @@ -60,14 +60,14 @@ class ObjectContext implements Context { Constructor ctor = clazz.getConstructor(new Class[]{Hashtable.class}); Object corbaContext = ctor.newInstance(new Object[]{this.environment}); contexts.add(corbaContext); - } catch (Throwable ex) {} + } catch (Throwable ignored) {} - String registryList = (String) environment.get("rmiregistries"); + String registryList = (String) (environment != null ? environment.get("rmiregistries") : null); if (registryList != null) for (Iterator i = Utility.parseCommaList(registryList); i.hasNext();) { Hashtable rmiEnv = (Hashtable) this.environment.clone(); URI uri = URI.create((String) i.next()); rmiEnv.put("host", uri.getHost()); - rmiEnv.put("port", new Integer(uri.getPort())); + rmiEnv.put("port", uri.getPort()); contexts.add(new RMIContext(rmiEnv)); } @@ -123,14 +123,15 @@ class ObjectContext implements Context { String alias = aliases.getProperty(name); if (alias != null) name = alias; - for (Iterator i = contexts.iterator(); i.hasNext();) { - Context c = (Context) i.next(); - try { - return c.lookup(name); - } catch (InvalidNameException ignore) { - } catch (NameNotFoundException ignore) { - } catch (NamingException ignore){} + for (Object context : contexts) { + Context c = (Context) context; + try { + return c.lookup(name); + } catch (InvalidNameException ignore) { + } catch (NameNotFoundException ignore) { + } catch (NamingException ignore) { } + } throw new NameNotFoundException(name + " not found in any managed subcontext"); } @@ -180,13 +181,14 @@ class ObjectContext implements Context { */ private void doRebind(String name, Object obj) throws NamingException { boolean bound = false; - for (Iterator i = contexts.iterator(); i.hasNext();) { - Context c = (Context) i.next(); - try { - c.rebind(name, obj); - bound = true; - } catch (NamingException ex) {} + for (Object context : contexts) { + Context c = (Context) context; + try { + c.rebind(name, obj); + bound = true; + } catch (NamingException ignored) { } + } if (!bound) throw new InvalidNameException("Name \"" + name + "\" not compatible with any managed subcontext"); } @@ -205,13 +207,14 @@ class ObjectContext implements Context { } boolean unbound = false; - for (Iterator i = contexts.iterator(); i.hasNext();) { - Context c = (Context) i.next(); - try { - c.unbind(name); - unbound = true; - } catch (NamingException ignore) {} + for (Object context : contexts) { + Context c = (Context) context; + try { + c.unbind(name); + unbound = true; + } catch (NamingException ignore) { } + } if (!unbound) throw new InvalidNameException("Name \"" + name + "\" not compatible with any managed subcontext"); } @@ -233,13 +236,14 @@ class ObjectContext implements Context { } boolean renamed = false; - for (Iterator i = contexts.iterator(); i.hasNext();) { - Context c = (Context) i.next(); - try { - c.rename(oldName, newName); - renamed = true; - } catch (NamingException ignore) {} + for (Object context : contexts) { + Context c = (Context) context; + try { + c.rename(oldName, newName); + renamed = true; + } catch (NamingException ignore) { } + } if (!renamed) throw new InvalidNameException("Names not compatible with any managed subcontext"); } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/commons/src/main/java/org/apache/oodt/commons/object/jndi/RMIContext.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/object/jndi/RMIContext.java b/commons/src/main/java/org/apache/oodt/commons/object/jndi/RMIContext.java index 135a7f5..b3427e4 100644 --- a/commons/src/main/java/org/apache/oodt/commons/object/jndi/RMIContext.java +++ b/commons/src/main/java/org/apache/oodt/commons/object/jndi/RMIContext.java @@ -59,7 +59,7 @@ public class RMIContext implements Context { public RMIContext(String host, int port) { Hashtable environment = new Hashtable(); environment.put("host", host); - environment.put("port", new Integer(port)); + environment.put("port", port); initEnv(environment); } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/commons/src/main/java/org/apache/oodt/commons/util/XMLRPC.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/XMLRPC.java b/commons/src/main/java/org/apache/oodt/commons/util/XMLRPC.java index 11192c7..14d7549 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/XMLRPC.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/XMLRPC.java @@ -15,13 +15,25 @@ package org.apache.oodt.commons.util; -import java.io.*; -import java.util.*; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import org.w3c.dom.*; -import org.xml.sax.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** XML-RPC utilities. * @@ -48,8 +60,9 @@ public class XMLRPC { if (params != null && !params.isEmpty()) { Element paramsElement = doc.createElement("params"); methodCallElement.appendChild(paramsElement); - for (Iterator i = params.iterator(); i.hasNext();) - paramsElement.appendChild(createValueElement(doc, i.next())); + for (Object param : params) { + paramsElement.appendChild(createValueElement(doc, param)); + } } return XML.serialize(doc).getBytes(); } @@ -87,23 +100,25 @@ public class XMLRPC { Element structElement = doc.createElement("struct"); valueElement.appendChild(structElement); Map map = (Map) value; - for (Iterator i = map.entrySet().iterator(); i.hasNext();) { - Element memberElement = doc.createElement("member"); - valueElement.appendChild(memberElement); - Map.Entry entry = (Map.Entry) i.next(); - if (!(entry.getKey() instanceof String)) - throw new IllegalArgumentException("Keys in maps for XML-RPC structs must be Strings"); - XML.add(memberElement, "name", entry.getKey().toString()); - memberElement.appendChild(createValueElement(doc, entry.getValue())); + for (Object o : map.entrySet()) { + Element memberElement = doc.createElement("member"); + valueElement.appendChild(memberElement); + Map.Entry entry = (Map.Entry) o; + if (!(entry.getKey() instanceof String)) { + throw new IllegalArgumentException("Keys in maps for XML-RPC structs must be Strings"); } + XML.add(memberElement, "name", entry.getKey().toString()); + memberElement.appendChild(createValueElement(doc, entry.getValue())); + } } else if (value instanceof Collection) { Element arrayElement = doc.createElement("array"); valueElement.appendChild(arrayElement); Element dataElement = doc.createElement("data"); arrayElement.appendChild(dataElement); Collection collection = (Collection) value; - for (Iterator i = collection.iterator(); i.hasNext();) - dataElement.appendChild(createValueElement(doc, i.next())); + for (Object aCollection : collection) { + dataElement.appendChild(createValueElement(doc, aCollection)); + } } else throw new IllegalArgumentException(value.getClass().getName() + " not supported in XML-RPC"); return valueElement; } @@ -163,10 +178,10 @@ public class XMLRPC { // Figure out what the type is from the nested element. String txt = XML.unwrappedText(t); if ("i4".equals(n) || "int".equals(n)) { - return new Integer(txt); + return Integer.valueOf(txt); } else if ("boolean".equals(n)) { - if ("1".equals(txt)) return new Boolean(true); - else if ("0".equals(txt)) return new Boolean(false); + if ("1".equals(txt)) return true; + else if ("0".equals(txt)) return false; else throw new IllegalArgumentException(n + " does not contain a 0 or 1"); } else if ("string".equals(n)) { return txt; http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java index 832c4af..b8bb51f 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java @@ -130,17 +130,17 @@ public class XmlRpcFileManagerClient { public boolean retryMethod(HttpMethod method, IOException e, int count) { if (count < Integer - .getInteger( - "org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retries", - 3).intValue()) { + .getInteger( + "org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retries", + 3)) { try { Thread .sleep(Integer - .getInteger( - "org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retry.interval.seconds", - 0).intValue() * 1000); + .getInteger( + "org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retry.interval.seconds", + 0) * 1000); return true; - } catch (Exception e1) { + } catch (Exception ignored) { } } return false; @@ -151,14 +151,14 @@ public class XmlRpcFileManagerClient { url, client); transport .setConnectionTimeout(Integer - .getInteger( - "org.apache.oodt.cas.filemgr.system.xmlrpc.connectionTimeout.minutes", - 20).intValue() * 60 * 1000); + .getInteger( + "org.apache.oodt.cas.filemgr.system.xmlrpc.connectionTimeout.minutes", + 20) * 60 * 1000); transport .setTimeout(Integer - .getInteger( - "org.apache.oodt.cas.filemgr.system.xmlrpc.requestTimeout.minutes", - 60).intValue() * 60 * 1000); + .getInteger( + "org.apache.oodt.cas.filemgr.system.xmlrpc.requestTimeout.minutes", + 60) * 60 * 1000); return transport; } @@ -179,12 +179,12 @@ public class XmlRpcFileManagerClient { } public boolean refreshConfigAndPolicy() { - boolean success = false; + boolean success; Vector<Object> argList = new Vector<Object>(); try { - success = ((Boolean) client.execute("filemgr.refreshConfigAndPolicy", - argList)).booleanValue(); + success = (Boolean) client.execute("filemgr.refreshConfigAndPolicy", + argList); } catch (XmlRpcException e) { LOG.log(Level.WARNING, "XmlRpcException when connecting to filemgr: [" + this.fileManagerUrl + "]"); @@ -199,12 +199,11 @@ public class XmlRpcFileManagerClient { } public boolean isAlive() { - boolean connected = false; + boolean connected; Vector<Object> argList = new Vector<Object>(); try { - connected = ((Boolean) client.execute("filemgr.isAlive", argList)) - .booleanValue(); + connected = (Boolean) client.execute("filemgr.isAlive", argList); } catch (XmlRpcException e) { LOG.log(Level.WARNING, "XmlRpcException when connecting to filemgr: [" @@ -226,11 +225,11 @@ public class XmlRpcFileManagerClient { .getXmlRpcProduct(product); argList.add(productHash); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.transferringProduct", - argList)).booleanValue(); + success = (Boolean) client.execute("filemgr.transferringProduct", + argList); } catch (XmlRpcException e) { throw new DataTransferException(e.getMessage()); } catch (IOException e) { @@ -247,12 +246,11 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(productHash); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute( - "filemgr.removeProductTransferStatus", argList)) - .booleanValue(); + success = (Boolean) client.execute( + "filemgr.removeProductTransferStatus", argList); } catch (XmlRpcException e) { throw new DataTransferException(e.getMessage()); } catch (IOException e) { @@ -269,11 +267,11 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(productHash); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.isTransferComplete", - argList)).booleanValue(); + success = (Boolean) client.execute("filemgr.isTransferComplete", + argList); } catch (XmlRpcException e) { throw new DataTransferException(e.getMessage()); } catch (IOException e) { @@ -291,11 +289,10 @@ public class XmlRpcFileManagerClient { argList.add(productHash); argList.add(newPath); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.moveProduct", argList)) - .booleanValue(); + success = (Boolean) client.execute("filemgr.moveProduct", argList); } catch (XmlRpcException e) { throw new DataTransferException(e.getMessage()); } catch (IOException e) { @@ -312,11 +309,11 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(productHash); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.modifyProduct", - argList)).booleanValue(); + success = (Boolean) client.execute("filemgr.modifyProduct", + argList); } catch (XmlRpcException e) { throw new CatalogException(e.getMessage()); } catch (IOException e) { @@ -334,11 +331,11 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(productHash); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.removeProduct", - argList)).booleanValue(); + success = (Boolean) client.execute("filemgr.removeProduct", + argList); } catch (XmlRpcException e) { throw new CatalogException(e.getMessage()); } catch (IOException e) { @@ -354,7 +351,7 @@ public class XmlRpcFileManagerClient { throws DataTransferException { Vector<Object> argList = new Vector<Object>(); - Hashtable<String, Object> statusHash = null; + Hashtable<String, Object> statusHash; FileTransferStatus status = null; try { @@ -379,7 +376,7 @@ public class XmlRpcFileManagerClient { throws DataTransferException { Vector<Object> argList = new Vector<Object>(); - Vector<Hashtable<String, Object>> statusVector = null; + Vector<Hashtable<String, Object>> statusVector; List<FileTransferStatus> statuses = null; try { @@ -405,7 +402,7 @@ public class XmlRpcFileManagerClient { Hashtable<String, Object> productHash = XmlRpcStructFactory .getXmlRpcProduct(product); argList.add(productHash); - Double pct = null; + Double pct; try { pct = (Double) client.execute("filemgr.getProductPctTransferred", @@ -417,7 +414,7 @@ public class XmlRpcFileManagerClient { } if (pct != null) { - return pct.doubleValue(); + return pct; } return -1.0; @@ -429,7 +426,7 @@ public class XmlRpcFileManagerClient { Hashtable<String, Object> refHash = XmlRpcStructFactory .getXmlRpcReference(reference); argList.add(refHash); - Double pct = null; + Double pct; try { pct = (Double) client.execute("filemgr.getRefPctTransferred", @@ -441,7 +438,7 @@ public class XmlRpcFileManagerClient { } if (pct != null) { - return pct.doubleValue(); + return pct; } return -1.0; @@ -457,9 +454,9 @@ public class XmlRpcFileManagerClient { .getXmlRpcProductType(type); argList.add(queryHash); argList.add(typeHash); - argList.add(new Integer(pageNum)); + argList.add(pageNum); - Hashtable<String, Object> pageHash = null; + Hashtable<String, Object> pageHash; try { pageHash = (Hashtable<String, Object>) client.execute( @@ -479,7 +476,7 @@ public class XmlRpcFileManagerClient { argList.add(XmlRpcStructFactory.getXmlRpcProductType(type)); ProductPage page = null; - Hashtable<String, Object> pageHash = null; + Hashtable<String, Object> pageHash; try { pageHash = (Hashtable<String, Object>) client.execute( @@ -504,7 +501,7 @@ public class XmlRpcFileManagerClient { argList.add(XmlRpcStructFactory.getXmlRpcProductType(type)); ProductPage page = null; - Hashtable<String, Object> pageHash = null; + Hashtable<String, Object> pageHash; try { pageHash = (Hashtable<String, Object>) client.execute( @@ -530,7 +527,7 @@ public class XmlRpcFileManagerClient { argList.add(XmlRpcStructFactory.getXmlRpcProductPage(currPage)); ProductPage page = null; - Hashtable<String, Object> pageHash = null; + Hashtable<String, Object> pageHash; try { pageHash = (Hashtable<String, Object>) client.execute( @@ -556,7 +553,7 @@ public class XmlRpcFileManagerClient { argList.add(XmlRpcStructFactory.getXmlRpcProductPage(currPage)); ProductPage page = null; - Hashtable<String, Object> pageHash = null; + Hashtable<String, Object> pageHash; try { pageHash = (Hashtable<String, Object>) client.execute( @@ -576,7 +573,7 @@ public class XmlRpcFileManagerClient { public String addProductType(ProductType type) throws RepositoryManagerException { - String productTypeId = null; + String productTypeId; Vector<Object> argList = new Vector<Object>(); Hashtable<String, Object> typeHash = XmlRpcStructFactory .getXmlRpcProductType(type); @@ -599,11 +596,11 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(productName); - boolean hasProduct = false; + boolean hasProduct; try { - hasProduct = ((Boolean) client.execute("filemgr.hasProduct", - argList)).booleanValue(); + hasProduct = (Boolean) client.execute("filemgr.hasProduct", + argList); } catch (XmlRpcException e) { throw new CatalogException(e.getMessage()); } catch (IOException e) { @@ -618,7 +615,7 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(XmlRpcStructFactory.getXmlRpcProductType(type)); - Integer numProducts = new Integer(-1); + Integer numProducts; try { numProducts = (Integer) client.execute("filemgr.getNumProducts", @@ -629,15 +626,15 @@ public class XmlRpcFileManagerClient { throw new CatalogException(e.getMessage()); } - return numProducts.intValue(); + return numProducts; } @SuppressWarnings("unchecked") public List<Product> getTopNProducts(int n) throws CatalogException { Vector<Object> argList = new Vector<Object>(); - argList.add(new Integer(n)); + argList.add(n); - Vector<Hashtable<String, Object>> topNProducts = null; + Vector<Hashtable<String, Object>> topNProducts; try { topNProducts = (Vector<Hashtable<String, Object>>) client.execute( @@ -648,21 +645,20 @@ public class XmlRpcFileManagerClient { throw new CatalogException(e.getMessage()); } - List<Product> topNProductList = XmlRpcStructFactory - .getProductListFromXmlRpc(topNProducts); - return topNProductList; + return XmlRpcStructFactory + .getProductListFromXmlRpc(topNProducts); } @SuppressWarnings("unchecked") public List<Product> getTopNProducts(int n, ProductType type) throws CatalogException { Vector<Object> argList = new Vector<Object>(); - argList.add(new Integer(n)); + argList.add(n); Hashtable<String, Object> productTypeHash = XmlRpcStructFactory .getXmlRpcProductType(type); argList.add(productTypeHash); - Vector<Hashtable<String, Object>> topNProducts = null; + Vector<Hashtable<String, Object>> topNProducts; try { topNProducts = (Vector<Hashtable<String, Object>>) client.execute( @@ -673,9 +669,8 @@ public class XmlRpcFileManagerClient { throw new CatalogException(e.getMessage()); } - List<Product> topNProductList = XmlRpcStructFactory - .getProductListFromXmlRpc(topNProducts); - return topNProductList; + return XmlRpcStructFactory + .getProductListFromXmlRpc(topNProducts); } public void setProductTransferStatus(Product product) @@ -732,7 +727,7 @@ public class XmlRpcFileManagerClient { argList.add(XmlRpcStructFactory.getXmlRpcProduct(product)); argList.add(met.getHashtable()); - boolean result = false; + boolean result; try { result = (Boolean) client.execute("filemgr.updateMetadata", argList); @@ -750,7 +745,7 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(XmlRpcStructFactory.getXmlRpcProduct(product)); - String productId = null; + String productId; try { productId = (String) client.execute("filemgr.catalogProduct", @@ -771,7 +766,7 @@ public class XmlRpcFileManagerClient { .getXmlRpcProduct(product); argList.add(productHash); - Hashtable<String, Object> metadata = null; + Hashtable<String, Object> metadata; try { metadata = (Hashtable<String, Object>) client.execute( @@ -797,7 +792,7 @@ public class XmlRpcFileManagerClient { argList.add(productHash); argList.add(new Vector(elements)); - Hashtable<String, Object> metadata = null; + Hashtable<String, Object> metadata; try { metadata = (Hashtable<String, Object>) client.execute( @@ -818,11 +813,10 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(filePath); - boolean success = false; + boolean success; try { - success = ((Boolean) client.execute("filemgr.removeFile", argList)) - .booleanValue(); + success = (Boolean) client.execute("filemgr.removeFile", argList); } catch (XmlRpcException e) { throw new DataTransferException(e.getMessage()); } catch (IOException e) { @@ -836,8 +830,8 @@ public class XmlRpcFileManagerClient { throws DataTransferException { Vector<Object> argList = new Vector<Object>(); argList.add(filePath); - argList.add(new Integer(offset)); - argList.add(new Integer(numBytes)); + argList.add(offset); + argList.add(numBytes); try { return (byte[]) client.execute("filemgr.retrieveFile", argList); @@ -853,8 +847,8 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(filePath); argList.add(fileData); - argList.add(new Integer(offset)); - argList.add(new Integer(numBytes)); + argList.add(offset); + argList.add(numBytes); try { client.execute("filemgr.transferFile", argList); @@ -873,7 +867,7 @@ public class XmlRpcFileManagerClient { .getXmlRpcProductType(type); argList.add(productTypeHash); - Vector<Hashtable<String, Object>> productVector = null; + Vector<Hashtable<String, Object>> productVector; try { productVector = (Vector<Hashtable<String, Object>>) client.execute( @@ -900,7 +894,7 @@ public class XmlRpcFileManagerClient { argList.add(productTypeHash); - Vector<Hashtable<String, Object>> elementVector = null; + Vector<Hashtable<String, Object>> elementVector; try { elementVector = (Vector<Hashtable<String, Object>>) client.execute( @@ -924,7 +918,7 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(elementId); - Hashtable<String, Object> elementHash = null; + Hashtable<String, Object> elementHash; try { elementHash = (Hashtable<String, Object>) client.execute( @@ -948,7 +942,7 @@ public class XmlRpcFileManagerClient { Vector<Object> argList = new Vector<Object>(); argList.add(elementName); - Hashtable<String, Object> elementHash = null; + Hashtable<String, Object> elementHash; try { elementHash = (Hashtable<String, Object>) client.execute( @@ -973,7 +967,7 @@ public class XmlRpcFileManagerClient { argList.add(elementName); argList.add(XmlRpcStructFactory.getXmlRpcProductType(type)); - Hashtable<String, Object> elementHash = null; + Hashtable<String, Object> elementHash; try { elementHash = (Hashtable<String, Object>) client.execute( @@ -1020,7 +1014,7 @@ public class XmlRpcFileManagerClient { argList.add(queryHash); argList.add(typeHash); - Vector<Hashtable<String, Object>> productVector = null; + Vector<Hashtable<String, Object>> productVector; try { productVector = (Vector<Hashtable<String, Object>>) client.execute( @@ -1044,7 +1038,7 @@ public class XmlRpcFileManagerClient { @SuppressWarnings("unchecked") public ProductType getProductTypeByName(String productTypeName) throws RepositoryManagerException { - Hashtable<String, Object> productTypeHash = new Hashtable<String, Object>(); + Hashtable<String, Object> productTypeHash; Vector<Object> argList = new Vector<Object>(); argList.add(productTypeName); @@ -1067,7 +1061,7 @@ public class XmlRpcFileManagerClient { @SuppressWarnings("unchecked") public ProductType getProductTypeById(String productTypeId) throws RepositoryManagerException { - Hashtable<String, Object> productTypeHash = new Hashtable<String, Object>(); + Hashtable<String, Object> productTypeHash; Vector<Object> argList = new Vector<Object>(); argList.add(productTypeId); @@ -1092,7 +1086,7 @@ public class XmlRpcFileManagerClient { throws RepositoryManagerException { Vector<Object> argList = new Vector<Object>(); - Vector<Hashtable<String, Object>> productTypeVector = null; + Vector<Hashtable<String, Object>> productTypeVector; try { productTypeVector = (Vector<Hashtable<String, Object>>) client @@ -1116,7 +1110,7 @@ public class XmlRpcFileManagerClient { throws CatalogException { Vector<Object> argList = new Vector<Object>(); - Vector<Hashtable<String, Object>> productReferenceVector = null; + Vector<Hashtable<String, Object>> productReferenceVector; Hashtable<String, Object> productHash = XmlRpcStructFactory .getXmlRpcProduct(product); argList.add(productHash); @@ -1142,7 +1136,7 @@ public class XmlRpcFileManagerClient { public Product getProductById(String productId) throws CatalogException { Vector<Object> argList = new Vector<Object>(); - Hashtable<String, Object> productHash = null; + Hashtable<String, Object> productHash; argList.add(productId); try { @@ -1165,7 +1159,7 @@ public class XmlRpcFileManagerClient { public Product getProductByName(String productName) throws CatalogException { Vector<Object> argList = new Vector<Object>(); - Hashtable<String, Object> productHash = null; + Hashtable<String, Object> productHash; argList.add(productName); try { @@ -1193,7 +1187,7 @@ public class XmlRpcFileManagerClient { .getXmlRpcProduct(product); argList.add(productHash); argList.add(metadata.getHashtable()); - argList.add(Boolean.valueOf(clientTransfer)); + argList.add(clientTransfer); String productId = (String) client.execute("filemgr.ingestProduct", argList); @@ -1226,8 +1220,10 @@ public class XmlRpcFileManagerClient { Versioner versioner = GenericFileManagerObjectFactory .getVersionerFromClassName(product.getProductType() .getVersioner()); - versioner.createDataStoreReferences(product, metadata); - + if (versioner != null) { + versioner.createDataStoreReferences(product, metadata); + } + // add the newly versioned references to the data store try { addProductReferences(product); http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java index 3becd30..c5fddde 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java @@ -19,6 +19,7 @@ package org.apache.oodt.cas.filemgr.util; //OODT imports import org.apache.oodt.cas.filemgr.structs.BooleanQueryCriteria; +import org.apache.oodt.cas.filemgr.structs.Element; import org.apache.oodt.cas.filemgr.structs.ExtractorSpec; import org.apache.oodt.cas.filemgr.structs.FileTransferStatus; import org.apache.oodt.cas.filemgr.structs.Product; @@ -28,7 +29,6 @@ import org.apache.oodt.cas.filemgr.structs.Query; import org.apache.oodt.cas.filemgr.structs.QueryCriteria; import org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria; import org.apache.oodt.cas.filemgr.structs.Reference; -import org.apache.oodt.cas.filemgr.structs.Element; import org.apache.oodt.cas.filemgr.structs.TermQueryCriteria; import org.apache.oodt.cas.filemgr.structs.exceptions.QueryFormulationException; import org.apache.oodt.cas.filemgr.structs.query.ComplexQuery; @@ -38,12 +38,12 @@ import org.apache.oodt.cas.filemgr.structs.query.filter.FilterAlgor; import org.apache.oodt.cas.filemgr.structs.type.TypeHandler; import org.apache.oodt.cas.metadata.Metadata; -//JDK imports import java.util.Hashtable; -import java.util.Iterator; +import java.util.List; import java.util.Properties; import java.util.Vector; -import java.util.List; + +//JDK imports /** * @author mattmann @@ -91,8 +91,7 @@ public final class XmlRpcStructFactory { if (statuses != null && statuses.size() > 0) { - for (Iterator<FileTransferStatus> i = statuses.iterator(); i.hasNext();) { - FileTransferStatus status = i.next(); + for (FileTransferStatus status : statuses) { statusVector.add(getXmlRpcFileTransferStatus(status)); } } @@ -104,8 +103,7 @@ public final class XmlRpcStructFactory { List<FileTransferStatus> statuses = new Vector<FileTransferStatus>(); if (statusVector != null && statusVector.size() > 0) { - for (Iterator<Hashtable<String, Object>> i = statusVector.iterator(); i.hasNext();) { - Hashtable<String, Object> statusHash = i.next(); + fore (Hashtable<String, Object> statusHash : statusVector) { FileTransferStatus status = getFileTransferStatusFromXmlRpc(statusHash); statuses.add(status); } @@ -116,9 +114,9 @@ public final class XmlRpcStructFactory { public static Hashtable<String, Object> getXmlRpcProductPage(ProductPage page) { Hashtable<String, Object>productPageHash = new Hashtable<String, Object>(); - productPageHash.put("totalPages", new Integer(page.getTotalPages())); - productPageHash.put("pageNum", new Integer(page.getPageNum())); - productPageHash.put("pageSize", new Integer(page.getPageSize())); + productPageHash.put("totalPages", page.getTotalPages()); + productPageHash.put("pageNum", page.getPageNum()); + productPageHash.put("pageSize", page.getPageSize()); productPageHash.put("pageProducts", getXmlRpcProductList(page .getPageProducts())); return productPageHash; @@ -127,12 +125,10 @@ public final class XmlRpcStructFactory { @SuppressWarnings("unchecked") public static ProductPage getProductPageFromXmlRpc(Hashtable<String, Object> productPageHash) { ProductPage page = new ProductPage(); - page.setPageNum(((Integer) productPageHash.get("pageNum")).intValue()); + page.setPageNum((Integer) productPageHash.get("pageNum")); page - .setPageSize(((Integer) productPageHash.get("pageSize")) - .intValue()); - page.setTotalPages(((Integer) productPageHash.get("totalPages")) - .intValue()); + .setPageSize((Integer) productPageHash.get("pageSize")); + page.setTotalPages((Integer) productPageHash.get("totalPages")); page.setPageProducts(getProductListFromXmlRpc((Vector<Hashtable<String, Object>>) productPageHash .get("pageProducts"))); return page; @@ -202,7 +198,9 @@ public final class XmlRpcStructFactory { public static FilterAlgor getFilterAlgorFromXmlRpc(Hashtable<String, Object> filterAlgorHash) { FilterAlgor filterAlgor = GenericFileManagerObjectFactory.getFilterAlgorFromClassName((String) filterAlgorHash.get("class")); - filterAlgor.setEpsilon(Long.parseLong((String) filterAlgorHash.get("epsilon"))); + if (filterAlgor != null) { + filterAlgor.setEpsilon(Long.parseLong((String) filterAlgorHash.get("epsilon"))); + } return filterAlgor; } @@ -293,8 +291,7 @@ public final class XmlRpcStructFactory { public static List<Product> getProductListFromXmlRpc(Vector<Hashtable<String, Object>> productVector) { List<Product> productList = new Vector<Product>(); - for (Iterator<Hashtable<String, Object>> i = productVector.iterator(); i.hasNext();) { - Hashtable<String, Object> productHash = i.next(); + for (Hashtable<String, Object> productHash : productVector) { Product product = getProductFromXmlRpc(productHash); productList.add(product); } @@ -309,8 +306,7 @@ public final class XmlRpcStructFactory { return productVector; } - for (Iterator<Product> i = products.iterator(); i.hasNext();) { - Product product = i.next(); + for (Product product : products) { Hashtable<String, Object> productHash = getXmlRpcProduct(product); productVector.add(productHash); } @@ -325,8 +321,7 @@ public final class XmlRpcStructFactory { return productTypeVector; } - for (Iterator<ProductType> i = productTypes.iterator(); i.hasNext();) { - ProductType type = i.next(); + for (ProductType type : productTypes) { Hashtable<String, Object> typeHash = getXmlRpcProductType(type); productTypeVector.add(typeHash); } @@ -335,8 +330,7 @@ public final class XmlRpcStructFactory { public static List<ProductType> getProductTypeListFromXmlRpc(Vector<Hashtable<String, Object>> productTypeVector) { List<ProductType> productTypeList = new Vector<ProductType>(); - for (Iterator<Hashtable<String, Object>> i = productTypeVector.iterator(); i.hasNext();) { - Hashtable<String, Object> productTypeHash = i.next(); + for (Hashtable<String, Object> productTypeHash : productTypeVector) { ProductType type = getProductTypeFromXmlRpc(productTypeHash); productTypeList.add(type); } @@ -402,8 +396,7 @@ public final class XmlRpcStructFactory { Vector<Hashtable<String, Object>> extractorsVector = new Vector<Hashtable<String, Object>>(); if (extractors != null && extractors.size() > 0) { - for (Iterator<ExtractorSpec> i = extractors.iterator(); i.hasNext();) { - ExtractorSpec spec = i.next(); + for (ExtractorSpec spec : extractors) { extractorsVector.add(getXmlRpcExtractorSpec(spec)); } } @@ -423,8 +416,7 @@ public final class XmlRpcStructFactory { Vector<Hashtable<String, Object>> handlersVector = new Vector<Hashtable<String, Object>>(); if (typeHandlers != null && typeHandlers.size() > 0) { - for (Iterator<TypeHandler> i = typeHandlers.iterator(); i.hasNext();) { - TypeHandler typeHandler = i.next(); + for (TypeHandler typeHandler : typeHandlers) { handlersVector.add(getXmlRpcTypeHandler(typeHandler)); } } @@ -445,8 +437,7 @@ public final class XmlRpcStructFactory { List<ExtractorSpec> extractors = new Vector<ExtractorSpec>(); if (extractorsVector != null && extractorsVector.size() > 0) { - for (Iterator<Hashtable<String, Object>> i = extractorsVector.iterator(); i.hasNext();) { - Hashtable<String, Object> extractorSpecHash = i.next(); + for (Hashtable<String, Object> extractorSpecHash : extractorsVector) { extractors.add(getExtractorSpecFromXmlRpc(extractorSpecHash)); } } @@ -469,8 +460,7 @@ public final class XmlRpcStructFactory { List<TypeHandler> handlers = new Vector<TypeHandler>(); if (handlersVector != null && handlersVector.size() > 0) { - for (Iterator<Hashtable<String, Object>> i = handlersVector.iterator(); i.hasNext();) { - Hashtable<String, Object> typeHandlerHash = i.next(); + for (Hashtable<String, Object> typeHandlerHash : handlersVector) { handlers.add(getTypeHandlerFromXmlRpc(typeHandlerHash)); } } @@ -491,8 +481,7 @@ public final class XmlRpcStructFactory { Properties props = new Properties(); if (propHash != null && propHash.keySet().size() > 0) { - for (Iterator<String> i = propHash.keySet().iterator(); i.hasNext();) { - String propName = i.next(); + for (String propName : propHash.keySet()) { String propValue = propHash.get(propName); props.setProperty(propName, propValue); } @@ -505,8 +494,8 @@ public final class XmlRpcStructFactory { Hashtable<String, String> propHash = new Hashtable<String, String>(); if (props != null && props.keySet().size() > 0) { - for (Iterator<Object> i = props.keySet().iterator(); i.hasNext();) { - String propName = (String) i.next(); + for (Object o : props.keySet()) { + String propName = (String) o; String propValue = props.getProperty(propName); propHash.put(propName, propValue); } @@ -522,8 +511,8 @@ public final class XmlRpcStructFactory { return refVector; } - for (Iterator<Reference> i = references.iterator(); i.hasNext();) { - Hashtable<String, Object> refHash = getXmlRpcReference(i.next()); + for (Reference reference : references) { + Hashtable<String, Object> refHash = getXmlRpcReference(reference); refVector.add(refHash); } @@ -532,8 +521,8 @@ public final class XmlRpcStructFactory { public static List<Reference> getReferencesFromXmlRpc(Vector<Hashtable<String, Object>> referenceVector) { List<Reference> references = new Vector<Reference>(); - for (Iterator<Hashtable<String, Object>> i = referenceVector.iterator(); i.hasNext();) { - Reference r = getReferenceFromXmlRpc(i.next()); + for (Hashtable<String, Object> aReferenceVector : referenceVector) { + Reference r = getReferenceFromXmlRpc(aReferenceVector); references.add(r); } return references; @@ -564,8 +553,7 @@ public final class XmlRpcStructFactory { public static Vector<Hashtable<String, Object>> getXmlRpcElementList(List<Element> elementList) { Vector<Hashtable<String, Object>> elementVector = new Vector<Hashtable<String, Object>>(elementList.size()); - for (Iterator<Element> i = elementList.iterator(); i.hasNext();) { - Element element = i.next(); + for (Element element : elementList) { Hashtable<String, Object> elementHash = getXmlRpcElement(element); elementVector.add(elementHash); } @@ -574,8 +562,7 @@ public final class XmlRpcStructFactory { public static List<Element> getElementListFromXmlRpc(Vector<Hashtable<String, Object>> elementVector) { List<Element> elementList = new Vector<Element>(elementVector.size()); - for (Iterator<Hashtable<String, Object>> i = elementVector.iterator(); i.hasNext();) { - Hashtable<String, Object> elementHash = i.next(); + for (Hashtable<String, Object> elementHash : elementVector) { Element element = getElementFromXmlRpc(elementHash); elementList.add(element); } @@ -624,8 +611,7 @@ public final class XmlRpcStructFactory { public static Vector<Hashtable<String, Object>> getXmlRpcQueryCriteriaList(List<QueryCriteria> criteriaList) { Vector<Hashtable<String, Object>> criteriaVector = new Vector<Hashtable<String, Object>>(criteriaList.size()); - for (Iterator<QueryCriteria> i = criteriaList.iterator(); i.hasNext();) { - QueryCriteria criteria = i.next(); + for (QueryCriteria criteria : criteriaList) { Hashtable<String, Object> criteriaHash = getXmlRpcQueryCriteria(criteria); criteriaVector.add(criteriaHash); } @@ -636,8 +622,7 @@ public final class XmlRpcStructFactory { public static List<QueryCriteria> getQueryCriteriaListFromXmlRpc(Vector<Hashtable<String, Object>> criteriaVector) { List<QueryCriteria> criteriaList = new Vector<QueryCriteria>(criteriaVector.size()); - for (Iterator<Hashtable<String, Object>> i = criteriaVector.iterator(); i.hasNext();) { - Hashtable<String, Object> criteriaHash = i.next(); + for (Hashtable<String, Object> criteriaHash : criteriaVector) { QueryCriteria criteria = getQueryCriteriaFromXmlRpc(criteriaHash); criteriaList.add(criteria); } @@ -660,12 +645,11 @@ public final class XmlRpcStructFactory { criteriaHash.put("inclusive", Boolean.toString(((RangeQueryCriteria) criteria).getInclusive())); } else if(criteria instanceof BooleanQueryCriteria){ BooleanQueryCriteria boolQuery = (BooleanQueryCriteria) criteria; - criteriaHash.put("operator", new Integer(boolQuery.getOperator())); + criteriaHash.put("operator", boolQuery.getOperator()); Vector<Hashtable<String, Object>> termsHash = new Vector<Hashtable<String, Object>>(); List<QueryCriteria> terms = boolQuery.getTerms(); - - for(int i=0;i<terms.size();i++){ - QueryCriteria term = terms.get(i); + + for (QueryCriteria term : terms) { Hashtable<String, Object> termHash = getXmlRpcQueryCriteria(term); termsHash.add(termHash); } @@ -679,11 +663,11 @@ public final class XmlRpcStructFactory { public static QueryCriteria getQueryCriteriaFromXmlRpc(Hashtable<String, Object> criteriaHash) { QueryCriteria criteria = null; - if(((String)criteriaHash.get("class")).equals(TermQueryCriteria.class.getCanonicalName())){ + if(criteriaHash.get("class").equals(TermQueryCriteria.class.getCanonicalName())){ criteria = new TermQueryCriteria(); criteria.setElementName((String) criteriaHash.get("elementName")); ((TermQueryCriteria)criteria).setValue((String) criteriaHash.get("elementValue")); - } else if(((String)criteriaHash.get("class")).equals(RangeQueryCriteria.class.getCanonicalName())){ + } else if(criteriaHash.get("class").equals(RangeQueryCriteria.class.getCanonicalName())){ criteria = new RangeQueryCriteria(); criteria.setElementName((String) criteriaHash.get("elementName")); String startVal = criteriaHash.get("elementStartValue").equals("") ? @@ -693,21 +677,20 @@ public final class XmlRpcStructFactory { ((RangeQueryCriteria)criteria).setStartValue(startVal); ((RangeQueryCriteria)criteria).setEndValue(endVal); ((RangeQueryCriteria)criteria).setInclusive(Boolean.parseBoolean((String) criteriaHash.get("inclusive"))); - } else if(((String)criteriaHash.get("class")).equals(BooleanQueryCriteria.class.getCanonicalName())){ + } else if(criteriaHash.get("class").equals(BooleanQueryCriteria.class.getCanonicalName())){ criteria = new BooleanQueryCriteria(); try{ - ((BooleanQueryCriteria)criteria).setOperator( ((Integer)criteriaHash.get("operator")).intValue() ); + ((BooleanQueryCriteria)criteria).setOperator((Integer) criteriaHash.get("operator")); } catch (QueryFormulationException e){ System.out.println("Error generating Boolean Query."); } @SuppressWarnings("unchecked") List<Hashtable<String, Object>> terms = (List<Hashtable<String, Object>>) criteriaHash.get("terms"); - for(int i=0;i<terms.size();i++){ - Hashtable<String, Object> term = terms.get(i); + for (Hashtable<String, Object> term : terms) { QueryCriteria termCriteria = getQueryCriteriaFromXmlRpc(term); - try{ - ((BooleanQueryCriteria)criteria).addTerm(termCriteria); - } catch (QueryFormulationException e){ + try { + ((BooleanQueryCriteria) criteria).addTerm(termCriteria); + } catch (QueryFormulationException e) { System.out.println("Error generating Boolean Query."); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/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 e9a744e..65d30f0 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ConfigServlet.java @@ -164,16 +164,16 @@ public class ConfigServlet extends GridServlet { 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 - Integer index = new Integer(key.substring(6)); // Parse out the index + Integer index = Integer.valueOf(key.substring(6)); // Parse out the index toRemove.add(index); // Add it to the list } } if (!toRemove.isEmpty()) { // And if we have any indexes Collections.sort(toRemove); // Sort 'em and put 'em in reverse ... Collections.reverse(toRemove); // ... order so we can safely remove them - for (Iterator i = toRemove.iterator(); i.hasNext();) { // For each index - // to remove - int index = ((Integer) i.next()).intValue(); // Get the index value + for (Object aToRemove : toRemove) { // For each index + // to remove + int index = (Integer) aToRemove; // Get the index value codeBases.remove(index); // And buh-bye. } needSave = true; // Definitely need to save changes now @@ -212,14 +212,14 @@ public class ConfigServlet extends GridServlet { List toRemove = new ArrayList(); // Start with empty list of indexes to // remove - for (Iterator i = params.entrySet().iterator(); i.hasNext();) { // Go - // through - // each - // parameter - Map.Entry entry = (Map.Entry) i.next(); // Get its key/value + for (Object o : params.entrySet()) { // Go + // through + // each + // parameter + Map.Entry entry = (Map.Entry) o; // Get its key/value String name = (String) entry.getKey(); // The key is a String if (name.startsWith(type + "rm-")) { // Is it an "drm-" or "mrm-"? - Integer index = new Integer(name.substring(4)); // Yes, get it sindex + Integer index = Integer.valueOf(name.substring(4)); // Yes, get it sindex toRemove.add(index); // Add it to the list } } @@ -228,8 +228,8 @@ public class ConfigServlet extends GridServlet { Collections.sort(toRemove); // We need to go through them in reverse ord- Collections.reverse(toRemove); // -er, so that removals don't shift // indexes - for (Iterator i = toRemove.iterator(); i.hasNext();) { // For each index - int index = ((Integer) i.next()).intValue(); // Get its int value + for (Object aToRemove : toRemove) { // For each index + int index = (Integer) aToRemove; // Get its int value servers.remove(index); // and buh-bye } needSave = true; // Gotta save after all that, whew. @@ -272,15 +272,15 @@ public class ConfigServlet extends GridServlet { */ private boolean updateProperties(Properties props, Map params) { boolean needSave = false; // Assume no save for now - for (Iterator i = params.entrySet().iterator(); i.hasNext();) { // Go - // through - // each - // request - // parameter - Map.Entry entry = (Map.Entry) i.next(); // Get the key/value + for (Object o : params.entrySet()) { // Go + // through + // each + // request + // parameter + Map.Entry entry = (Map.Entry) o; // Get the key/value String name = (String) entry.getKey(); // Key is always a string String newValue = ((String[]) entry.getValue())[0]; // Value is String[], - // get the zeroth + // get the zeroth if (name.startsWith("val-")) { // If the param is "val-" String key = name.substring(4); // Then find the key if (props.containsKey(key)) { // If that key exists http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/ExternPreconditionComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/ExternPreconditionComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/ExternPreconditionComparator.java index c5689dd..b93f706 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/ExternPreconditionComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/ExternPreconditionComparator.java @@ -19,17 +19,18 @@ package org.apache.oodt.cas.metadata.preconditions; //JDK imports +import org.apache.oodt.cas.metadata.exceptions.PreconditionComparatorException; +import org.apache.oodt.commons.exec.ExecUtils; + import java.io.File; import java.io.IOException; -import java.util.logging.Logger; import java.util.logging.Level; +import java.util.logging.Logger; -//OODT static imports import static org.apache.oodt.cas.metadata.util.PathUtils.doDynamicReplacement; +//OODT static imports //OODT imports -import org.apache.oodt.cas.metadata.exceptions.PreconditionComparatorException; -import org.apache.oodt.commons.exec.ExecUtils; /** @@ -63,7 +64,7 @@ public class ExternPreconditionComparator extends PreConditionComparator<Long> { protected int performCheck(File product, Long compareItem) throws PreconditionComparatorException { - String envReplacedExecuteCommand = ""; + String envReplacedExecuteCommand; try { envReplacedExecuteCommand = doDynamicReplacement( executeCommand ) + @@ -80,7 +81,7 @@ public class ExternPreconditionComparator extends PreConditionComparator<Long> { // Determine working directory String workingDirPath = product.getParentFile().getAbsolutePath(); File workingDir = new File(workingDirPath); - int status = -1; + int status; try { status = ExecUtils.callProgram(envReplacedExecuteCommand, workingDir); @@ -93,7 +94,7 @@ public class ExternPreconditionComparator extends PreConditionComparator<Long> { return 1; } - return new Long(status).compareTo(compareItem); + return Long.valueOf(status).compareTo(compareItem); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/FileSizeComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/FileSizeComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/FileSizeComparator.java index 463b8dc..41820ac 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/FileSizeComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/FileSizeComparator.java @@ -39,7 +39,7 @@ public class FileSizeComparator extends PreConditionComparator<Long> { @Override protected int performCheck(File product, Long compareItem) throws PreconditionComparatorException { - return new Long(product.length()).compareTo(compareItem); + return Long.valueOf(product.length()).compareTo(compareItem); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/profile/src/main/java/org/apache/oodt/profile/gui/LeafListener.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/gui/LeafListener.java b/profile/src/main/java/org/apache/oodt/profile/gui/LeafListener.java index 9bb6670..2ba8e01 100755 --- a/profile/src/main/java/org/apache/oodt/profile/gui/LeafListener.java +++ b/profile/src/main/java/org/apache/oodt/profile/gui/LeafListener.java @@ -17,23 +17,21 @@ package org.apache.oodt.profile.gui; +import org.apache.oodt.profile.EnumeratedProfileElement; +import org.apache.oodt.profile.Profile; +import org.apache.oodt.profile.ProfileElement; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; + +import javax.swing.JMenuItem; import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreePath; import javax.swing.tree.DefaultTreeModel; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - - -import java.util.Iterator; - -import org.apache.oodt.profile.ProfileElement; -import org.apache.oodt.profile.EnumeratedProfileElement; -import org.apache.oodt.profile.Profile; +import javax.swing.tree.TreePath; @@ -109,7 +107,7 @@ public class LeafListener extends MouseAdapter{ } public DefaultMutableTreeNode generateNewProfileElementTree(String peName){ - DefaultMutableTreeNode peRoot = null; + DefaultMutableTreeNode peRoot; ProfileElement theProfileElement = new EnumeratedProfileElement(new Profile()); @@ -132,17 +130,18 @@ public class LeafListener extends MouseAdapter{ theIDRoot.add(theID); - DefaultMutableTreeNode theMO = new DefaultMutableTreeNode(new Integer(theProfileElement.getMaxOccurrence()).toString()); + DefaultMutableTreeNode theMO = new DefaultMutableTreeNode( + Integer.toString(theProfileElement.getMaxOccurrence())); DefaultMutableTreeNode theMORoot = new DefaultMutableTreeNode("Max Occurence"); theMORoot.add(theMO); DefaultMutableTreeNode theSynonyms = new DefaultMutableTreeNode("Synonyms"); - - for(Iterator i2 = theProfileElement.getSynonyms().iterator(); i2.hasNext(); ){ - String theSynonym = (String)i2.next(); - DefaultMutableTreeNode sNode = new DefaultMutableTreeNode(theSynonym); - theSynonyms.add(sNode); - } + + for (Object o : theProfileElement.getSynonyms()) { + String theSynonym = (String) o; + DefaultMutableTreeNode sNode = new DefaultMutableTreeNode(theSynonym); + theSynonyms.add(sNode); + } DefaultMutableTreeNode theType = new DefaultMutableTreeNode(theProfileElement.getType()); DefaultMutableTreeNode theTypeRoot = new DefaultMutableTreeNode("Type"); @@ -195,7 +194,7 @@ public class LeafListener extends MouseAdapter{ return; } - DefaultMutableTreeNode theAddNode = null; + DefaultMutableTreeNode theAddNode; String childNodeName = (String)JOptionPane.showInputDialog(null,"Add","Enter Node Name", JOptionPane.PLAIN_MESSAGE,null,null,"Child Value"); if(childNodeName == null){return; } //they didn't specify name or hit cancel http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java index 33d9acf..9e99ab5 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/DaemonManager.java @@ -60,11 +60,11 @@ public class DaemonManager implements DaemonListener { } public synchronized void wasRegisteredWith(Daemon daemon) { - this.usedIDs.add(new Integer(daemon.getDaemonID())); + this.usedIDs.add(daemon.getDaemonID()); } public synchronized void wasUnregisteredWith(Daemon daemon) { - this.usedIDs.remove(new Integer(daemon.getDaemonID())); + this.usedIDs.remove(Integer.valueOf(daemon.getDaemonID())); } public void daemonStarting(Daemon daemon) { http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java index b536dc0..7d56680 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java @@ -59,13 +59,13 @@ public class Method { public void addArgSignature(String name, int type) { argNames.add(name); - argTypes.add(new Integer(type)); + argTypes.add(type); } public boolean addArg(String name, String value) { int nextLoc = args.size(); if (nextLoc >= 0) { - switch (argTypes.get(nextLoc).intValue()) { + switch (argTypes.get(nextLoc)) { case INT: addArg(new Variable(null, new Integer(value))); break; @@ -98,7 +98,7 @@ public class Method { // System.out.println("Next C = " + c); switch (c) { case '$': - StringBuffer variable = new StringBuffer(""); + StringBuilder variable = new StringBuilder(""); boolean globalVar = false; // skip $ by incr i and if true then variable is a global @@ -134,7 +134,7 @@ public class Method { // System.out.println(output); break; case '#': - StringBuffer variableIntString = new StringBuffer(""); + StringBuilder variableIntString = new StringBuilder(""); int k = i + 1; for (; k < infixArray.length; k++) { char ch = infixArray[k]; @@ -148,7 +148,7 @@ public class Method { i = k - 1; break; case '"': - StringBuffer variableString = new StringBuffer(""); + StringBuilder variableString = new StringBuilder(""); int l = i + 1; for (; l < infixArray.length; l++) { char ch = infixArray[l]; @@ -217,9 +217,9 @@ public class Method { stack.push(new Variable(null, value)); } else if (((Variable) first).isInteger() && ((Variable) second).isInteger()) { - Integer value = new Integer(((Integer) second - .getValue()).intValue() - + ((Integer) first.getValue()).intValue()); + Integer value = (Integer) second + .getValue() + + (Integer) first.getValue(); stack.push(new Variable(null, value)); } else { throw new MethodException( @@ -229,9 +229,9 @@ public class Method { case '-': if (((Variable) first).isInteger() && ((Variable) second).isInteger()) { - Integer value = new Integer(((Integer) second - .getValue()).intValue() - - ((Integer) first.getValue()).intValue()); + Integer value = (Integer) second + .getValue() + - (Integer) first.getValue(); stack.push(new Variable(null, value)); } else { throw new MethodException( @@ -241,9 +241,9 @@ public class Method { case '*': if (((Variable) first).isInteger() && ((Variable) second).isInteger()) { - Integer value = new Integer(((Integer) second - .getValue()).intValue() - * ((Integer) first.getValue()).intValue()); + Integer value = (Integer) second + .getValue() + * (Integer) first.getValue(); stack.push(new Variable(null, value)); } else { throw new MethodException( @@ -253,11 +253,10 @@ public class Method { case '/': if (((Variable) first).isInteger() && ((Variable) second).isInteger() - && ((Integer) ((Variable) first).getValue()) - .intValue() > 0) { - Integer value = new Integer(((Integer) second - .getValue()).intValue() - / ((Integer) first.getValue()).intValue()); + && (Integer) first.getValue() > 0) { + Integer value = (Integer) second + .getValue() + / (Integer) first.getValue(); stack.push(new Variable(null, value)); } else { throw new MethodException( http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/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 d2c02ca..34fa21d 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 @@ -29,7 +29,6 @@ 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; @@ -208,7 +207,7 @@ public class DirStructXmlParser implements Parser { return input; } - private void parseVariablesXML(NodeList list) throws DOMException, Exception { + private void parseVariablesXML(NodeList list) throws Exception { // loop through all variable elements for (int i = 0; i < list.getLength(); i++) { @@ -265,7 +264,7 @@ public class DirStructXmlParser implements Parser { } // determine if variable is an Integer or a String if (type.equals("int")) { - variable.setValue(new Integer(value)); + variable.setValue(Integer.valueOf(value)); } else variable.setValue(value); http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/resource/src/main/java/org/apache/oodt/cas/resource/examples/LongJob.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/examples/LongJob.java b/resource/src/main/java/org/apache/oodt/cas/resource/examples/LongJob.java index 83bc6e0..d07e57b 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/examples/LongJob.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/examples/LongJob.java @@ -50,8 +50,8 @@ public class LongJob implements JobInstance, JobMetadata { NameValueJobInput input = (NameValueJobInput) in; - int waitTime = 0; - waitTime = new Integer(input.getValue("wait")).intValue(); + int waitTime; + waitTime = new Integer(input.getValue("wait")); System.out.println("LongJob running for " + waitTime + " sec"); http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/resource/src/main/java/org/apache/oodt/cas/resource/examples/TestResmgr.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/examples/TestResmgr.java b/resource/src/main/java/org/apache/oodt/cas/resource/examples/TestResmgr.java index 455ff07..e8e3e70 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/examples/TestResmgr.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/examples/TestResmgr.java @@ -52,7 +52,7 @@ public class TestResmgr { Job hw1 = new Job("JobOne", "HelloWorldJob", "org.apache.oodt.cas.resource.examples.HelloWorldJob", "org.apache.oodt.cas.resource.structs.NameValueJobInput", "quick", - new Integer(1)); + 1); NameValueJobInput hw1Input = new NameValueJobInput(); hw1Input.setNameValuePair("user.name", "Dave"); http://git-wip-us.apache.org/repos/asf/oodt/blob/d5dfd9f1/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java index 024a659..77fb4a2 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java @@ -18,14 +18,15 @@ package org.apache.oodt.cas.resource.monitor; //JDK imports +import org.apache.oodt.cas.resource.structs.ResourceNode; +import org.apache.oodt.cas.resource.structs.exceptions.MonitorException; + import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Vector; //OODT imports -import org.apache.oodt.cas.resource.structs.ResourceNode; -import org.apache.oodt.cas.resource.structs.exceptions.MonitorException; /** * @@ -55,7 +56,7 @@ public class AssignmentMonitor implements Monitor { for (ResourceNode node : nodes) { nodesMap.put(node.getNodeId(), node); - loadMap.put(node.getNodeId(), new Integer(0)); + loadMap.put(node.getNodeId(), 0); } } @@ -73,7 +74,7 @@ public class AssignmentMonitor implements Monitor { if (loadValue <= (loadCap - curLoad)) { loadMap.remove(node.getNodeId()); - loadMap.put(node.getNodeId(), new Integer(curLoad + loadValue)); + loadMap.put(node.getNodeId(), curLoad + loadValue); return true; } else { return false; @@ -88,7 +89,7 @@ public class AssignmentMonitor implements Monitor { if (newVal < 0) newVal = 0; // should not happen but just in case loadMap.remove(node.getNodeId()); - loadMap.put(node.getNodeId(), new Integer(newVal)); + loadMap.put(node.getNodeId(), newVal); return true; } @@ -98,7 +99,7 @@ public class AssignmentMonitor implements Monitor { * @see gov.nasa.jpl.oodt.cas.resource.monitor.Monitor#getLoad(gov.nasa.jpl.oodt.cas.resource.structs.ResourceNode) */ public int getLoad(ResourceNode node) throws MonitorException { - ResourceNode resource = (ResourceNode) nodesMap.get(node.getNodeId()); + ResourceNode resource = nodesMap.get(node.getNodeId()); int i = loadMap.get(node.getNodeId()); return (resource.getCapacity() - i); } @@ -118,7 +119,7 @@ public class AssignmentMonitor implements Monitor { * @see gov.nasa.jpl.oodt.cas.resource.monitor.Monitor#getNodeById(java.lang.String) */ public ResourceNode getNodeById(String nodeId) throws MonitorException { - return (ResourceNode) nodesMap.get(nodeId); + return nodesMap.get(nodeId); } /* @@ -129,9 +130,9 @@ public class AssignmentMonitor implements Monitor { public ResourceNode getNodeByURL(URL ipAddr) throws MonitorException { ResourceNode targetResource = null; List<ResourceNode> nodes = this.getNodes(); - for (int i = 0; i < nodes.size(); i++) { - if (((ResourceNode) nodes.get(i)).getIpAddr() == ipAddr) { - targetResource = (ResourceNode) nodes.get(i); + for (ResourceNode node : nodes) { + if (node.getIpAddr() == ipAddr) { + targetResource = node; break; } } @@ -141,7 +142,7 @@ public class AssignmentMonitor implements Monitor { public void addNode(ResourceNode node) throws MonitorException { nodesMap.put(node.getNodeId(), node); if (!loadMap.containsKey(node.getNodeId())) - loadMap.put(node.getNodeId(), new Integer(0)); + loadMap.put(node.getNodeId(), 0); } public void removeNodeById(String nodeId) throws MonitorException {
