You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2015/11/01 01:44:57 UTC
[07/12] oodt git commit: OODT-911 make code clearer
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 bf4b5f5..f2927d9 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
@@ -77,15 +77,18 @@ public class RMIContext implements Context {
* @param environment Its environment, currently unused.
*/
private void initEnv(Hashtable environment) {
- if (environment == null)
- throw new IllegalArgumentException("Nonnull environment required");
+ if (environment == null) {
+ throw new IllegalArgumentException("Nonnull environment required");
+ }
this.environment = (Hashtable) environment.clone();
}
public Object lookup(String name) throws NamingException {
checkName(name);
name = toRMIName(name);
- if (name.length() == 0) return new RMIContext(environment);
+ if (name.length() == 0) {
+ return new RMIContext(environment);
+ }
Registry registry = getRegistry();
try {
return registry.lookup(name);
@@ -157,8 +160,9 @@ public class RMIContext implements Context {
}
public NamingEnumeration list(String name) throws NamingException {
- if (name.length() > 0)
- throw new NotContextException("Subcontexts not supported");
+ if (name.length() > 0) {
+ throw new NotContextException("Subcontexts not supported");
+ }
final Iterator i = getCurrentBindings().iterator();
return new NamingEnumeration() {
@@ -195,8 +199,9 @@ public class RMIContext implements Context {
}
public NamingEnumeration listBindings(String name) throws NamingException {
- if (name.length() > 0)
- throw new NotContextException("Subcontexts not supported");
+ if (name.length() > 0) {
+ throw new NotContextException("Subcontexts not supported");
+ }
final Iterator i = getCurrentBindings().iterator();
return new NamingEnumeration() {
public void close() {}
@@ -270,17 +275,23 @@ public class RMIContext implements Context {
}
public Object addToEnvironment(String propName, Object propVal) throws NamingException {
- if (environment == null) environment = new Hashtable();
+ if (environment == null) {
+ environment = new Hashtable();
+ }
return environment.put(propName, propVal);
}
public Object removeFromEnvironment(String propName) throws NamingException {
- if (environment == null) return null;
+ if (environment == null) {
+ return null;
+ }
return environment.remove(propName);
}
public Hashtable getEnvironment() throws NamingException {
- if (environment == null) return new Hashtable();
+ if (environment == null) {
+ return new Hashtable();
+ }
return (Hashtable) environment.clone();
}
@@ -315,11 +326,15 @@ public class RMIContext implements Context {
* @return rmiregistry name.
*/
private String toRMIName(String name) {
- if (name == null) return "";
- if (name.startsWith("urn:eda:rmi:"))
- return name.substring(12);
- if (name.startsWith("rmi:"))
- return name.substring(4);
+ if (name == null) {
+ return "";
+ }
+ if (name.startsWith("urn:eda:rmi:")) {
+ return name.substring(12);
+ }
+ if (name.startsWith("rmi:")) {
+ return name.substring(4);
+ }
return name;
}
@@ -330,7 +345,9 @@ public class RMIContext implements Context {
* @throws NamingException if an error occurs.
*/
private Registry getRegistry() throws NamingException {
- if (registry != null) return registry;
+ if (registry != null) {
+ return registry;
+ }
try {
String host = environment.containsKey("host")? (String) environment.get("host") : "localhost";
int port = environment.containsKey("port")? (Integer) environment.get("port")
@@ -354,12 +371,15 @@ public class RMIContext implements Context {
* @throws InvalidNameException If <var>name</var>'s not an RMI object context name.
*/
private void checkName(String name) throws InvalidNameException {
- if (name == null)
- throw new IllegalArgumentException("Can't check a null name");
- if (name.length() == 0)
- throw new InvalidNameException("Name's length is zero");
- if (!name.startsWith("urn:eda:rmi:"))
- throw new InvalidNameException("Not an RMI name; try urn:eda:rmi:yadda-yadda");
+ if (name == null) {
+ throw new IllegalArgumentException("Can't check a null name");
+ }
+ if (name.length() == 0) {
+ throw new InvalidNameException("Name's length is zero");
+ }
+ if (!name.startsWith("urn:eda:rmi:")) {
+ throw new InvalidNameException("Not an RMI name; try urn:eda:rmi:yadda-yadda");
+ }
}
/** Context's environment; currently unused. */
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java b/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java
index 927748b..597a294 100644
--- a/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java
+++ b/commons/src/main/java/org/apache/oodt/commons/pagination/PaginationUtils.java
@@ -82,22 +82,25 @@ public final class PaginationUtils {
final int totalSize = originalList.size();
int endIndex = startIndex + pageSize;
- if (endIndex > totalSize)
+ if (endIndex > totalSize) {
endIndex = totalSize;
+ }
return originalList.subList(startIndex, endIndex);
}
public static int getTotalPage(List originalList, int pageSize) {
- if (originalList == null || originalList.size() <= 0)
+ if (originalList == null || originalList.size() <= 0) {
return 0;
+ }
final int totalSize = originalList.size();
return ((totalSize - 1) / pageSize) + 1;
}
public static int getTotalPage(int numTotal, int pageSize) {
- if (numTotal <= 0)
+ if (numTotal <= 0) {
return 0;
+ }
return ((numTotal - 1) / pageSize) + 1;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java b/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java
index 0a3189e..0247f6c 100755
--- a/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java
+++ b/commons/src/main/java/org/apache/oodt/commons/spring/postprocessor/SetIdBeanPostProcessor.java
@@ -36,8 +36,9 @@ public class SetIdBeanPostProcessor implements BeanPostProcessor {
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
- if (bean instanceof SpringSetIdInjectionType)
- ((SpringSetIdInjectionType) bean).setId(beanName);
+ if (bean instanceof SpringSetIdInjectionType) {
+ ((SpringSetIdInjectionType) bean).setId(beanName);
+ }
return bean;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/Base64.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/Base64.java b/commons/src/main/java/org/apache/oodt/commons/util/Base64.java
index fb1c7b3..5f4654d 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/Base64.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/Base64.java
@@ -61,13 +61,19 @@ public class Base64 {
* @return Base-64 encoded <var>data</var>
*/
public static byte[] encode(final byte[] data, int offset, int length) {
- if (data == null) return null;
- if (offset < 0 || offset > data.length)
- throw new IndexOutOfBoundsException("Can't encode at index " + offset + " which is beyond array bounds 0.."
- + data.length);
- if (length < 0) throw new IllegalArgumentException("Can't encode a negative amount of data");
- if (offset + length > data.length)
- throw new IndexOutOfBoundsException("Can't encode beyond right edge of array");
+ if (data == null) {
+ return null;
+ }
+ if (offset < 0 || offset > data.length) {
+ throw new IndexOutOfBoundsException("Can't encode at index " + offset + " which is beyond array bounds 0.."
+ + data.length);
+ }
+ if (length < 0) {
+ throw new IllegalArgumentException("Can't encode a negative amount of data");
+ }
+ if (offset + length > data.length) {
+ throw new IndexOutOfBoundsException("Can't encode beyond right edge of array");
+ }
int i, j;
byte dest[] = new byte[((length+2)/3)*4];
@@ -86,21 +92,30 @@ public class Base64 {
if (i < offset + length - 1) {
dest[j++] = (byte) ((data[i+1] >>> 4) & 017 | (data[i] << 4) & 077);
dest[j++] = (byte) ((data[i+1] << 2) & 077);
- } else
- dest[j++] = (byte) ((data[i] << 4) & 077);
+ } else {
+ dest[j++] = (byte) ((data[i] << 4) & 077);
+ }
}
// Now, map those onto base 64 printable ASCII.
for (i = 0; i <j; i++) {
- if (dest[i] < 26) dest[i] = (byte)(dest[i] + 'A');
- else if (dest[i] < 52) dest[i] = (byte)(dest[i] + 'a'-26);
- else if (dest[i] < 62) dest[i] = (byte)(dest[i] + '0'-52);
- else if (dest[i] < 63) dest[i] = (byte) '+';
- else dest[i] = (byte) '/';
+ if (dest[i] < 26) {
+ dest[i] = (byte) (dest[i] + 'A');
+ } else if (dest[i] < 52) {
+ dest[i] = (byte) (dest[i] + 'a' - 26);
+ } else if (dest[i] < 62) {
+ dest[i] = (byte) (dest[i] + '0' - 52);
+ } else if (dest[i] < 63) {
+ dest[i] = (byte) '+';
+ } else {
+ dest[i] = (byte) '/';
+ }
}
// Pad the result with and we're done.
- for (; i < dest.length; i++) dest[i] = (byte) '=';
+ for (; i < dest.length; i++) {
+ dest[i] = (byte) '=';
+ }
return dest;
}
@@ -127,31 +142,42 @@ public class Base64 {
* @return Decoded <var>data</var>.
*/
public static byte[] decode(final byte[] data, int offset, int length) {
- if (data == null) return null;
- if (offset < 0 || offset >= data.length)
- throw new IndexOutOfBoundsException("Can't decode at index " + offset + " which is beyond array bounds 0.."
- + (data.length-1));
- if (length < 0) throw new IllegalArgumentException("Can't decode a negative amount of data");
- if (offset + length > data.length)
- throw new IndexOutOfBoundsException("Can't decode beyond right edge of array");
+ if (data == null) {
+ return null;
+ }
+ if (offset < 0 || offset >= data.length) {
+ throw new IndexOutOfBoundsException("Can't decode at index " + offset + " which is beyond array bounds 0.."
+ + (data.length - 1));
+ }
+ if (length < 0) {
+ throw new IllegalArgumentException("Can't decode a negative amount of data");
+ }
+ if (offset + length > data.length) {
+ throw new IndexOutOfBoundsException("Can't decode beyond right edge of array");
+ }
// Ignore any padding at the end.
int tail = offset + length - 1;
- while (tail >= offset && data[tail] == '=')
- --tail;
+ while (tail >= offset && data[tail] == '=') {
+ --tail;
+ }
byte dest[] = new byte[tail + offset + 1 - length/4];
// First, convert from base-64 ascii to 6 bit bytes.
for (int i = offset; i < offset+length; i++) {
- if (data[i] == '=') data[i] = 0;
- else if (data[i] == '/') data[i] = 63;
- else if (data[i] == '+') data[i] = 62;
- else if (data[i] >= '0' && data[i] <= '9')
- data[i] = (byte)(data[i] - ('0' - 52));
- else if (data[i] >= 'a' && data[i] <= 'z')
- data[i] = (byte)(data[i] - ('a' - 26));
- else if (data[i] >= 'A' && data[i] <= 'Z')
- data[i] = (byte)(data[i] - 'A');
+ if (data[i] == '=') {
+ data[i] = 0;
+ } else if (data[i] == '/') {
+ data[i] = 63;
+ } else if (data[i] == '+') {
+ data[i] = 62;
+ } else if (data[i] >= '0' && data[i] <= '9') {
+ data[i] = (byte) (data[i] - ('0' - 52));
+ } else if (data[i] >= 'a' && data[i] <= 'z') {
+ data[i] = (byte) (data[i] - ('a' - 26));
+ } else if (data[i] >= 'A' && data[i] <= 'Z') {
+ data[i] = (byte) (data[i] - 'A');
+ }
}
// Map those from 4 6-bit byte groups onto 3 8-bit byte groups.
@@ -163,10 +189,12 @@ public class Base64 {
}
// And get the leftover ...
- if (j < dest.length)
- dest[j] = (byte) (((data[i] << 2) & 255) | ((data[i+1] >>> 4) & 003));
- if (++j < dest.length)
- dest[j] = (byte) (((data[i+1] << 4) & 255) | ((data[i+2] >>> 2) & 017));
+ if (j < dest.length) {
+ dest[j] = (byte) (((data[i] << 2) & 255) | ((data[i + 1] >>> 4) & 003));
+ }
+ if (++j < dest.length) {
+ dest[j] = (byte) (((data[i + 1] << 4) & 255) | ((data[i + 2] >>> 2) & 017));
+ }
// That's it.
return dest;
@@ -188,11 +216,11 @@ public class Base64 {
System.exit(1);
}
boolean encode = true;
- if ("encode".equals(argv[0]))
- encode = true;
- else if ("decode".equals(argv[0]))
- encode = false;
- else {
+ if ("encode".equals(argv[0])) {
+ encode = true;
+ } else if ("decode".equals(argv[0])) {
+ encode = false;
+ } else {
System.err.println("Specify either \"encode\" or \"decode\"");
System.exit(1);
}
@@ -208,8 +236,9 @@ public class Base64 {
}
byte[] buf = new byte[512];
int numRead;
- while ((numRead = in.read(buf)) != -1)
- out.write(buf, 0, numRead);
+ while ((numRead = in.read(buf)) != -1) {
+ out.write(buf, 0, numRead);
+ }
in.close();
out.close();
System.exit(0);
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/CacheMap.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/CacheMap.java b/commons/src/main/java/org/apache/oodt/commons/util/CacheMap.java
index 6ed5e5d..4134f2b 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/CacheMap.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/CacheMap.java
@@ -71,8 +71,9 @@ public class CacheMap implements Map {
public CacheMap(int capacity) {
// FXN: [ c, C, M := capacity, {}, {} ]
- if (capacity < 0)
- throw new IllegalArgumentException("Can't have a negative size " + capacity + " cache map");
+ if (capacity < 0) {
+ throw new IllegalArgumentException("Can't have a negative size " + capacity + " cache map");
+ }
this.capacity = capacity;
}
@@ -150,8 +151,9 @@ public class CacheMap implements Map {
}
cache.addFirst(key);
- if (cache.size() > capacity)
- map.remove(cache.removeLast());
+ if (cache.size() > capacity) {
+ map.remove(cache.removeLast());
+ }
return null;
}
@@ -159,8 +161,9 @@ public class CacheMap implements Map {
// FXN: [ key in M -> C, M, return value := C - key, M - (key, v), v
// | true -> return value := null ]
- if (!map.containsKey(key))
- return null;
+ if (!map.containsKey(key)) {
+ return null;
+ }
cache.remove(key);
return map.remove(key);
}
@@ -189,8 +192,12 @@ public class CacheMap implements Map {
}
public boolean equals(Object rhs) {
- if (rhs == this) return true;
- if (rhs == null || !(rhs instanceof CacheMap)) return false;
+ if (rhs == this) {
+ return true;
+ }
+ if (rhs == null || !(rhs instanceof CacheMap)) {
+ return false;
+ }
CacheMap obj = (CacheMap) rhs;
return obj.cache.equals(cache);
}
@@ -209,7 +216,9 @@ public class CacheMap implements Map {
// FXN: [ C = advance(key, C) ]
boolean present = cache.remove(key);
- if (!present) return;
+ if (!present) {
+ return;
+ }
cache.addFirst(key);
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java b/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java
index 0a9ad8b..b9c3139 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/DOMParser.java
@@ -48,8 +48,9 @@ public class DOMParser {
* @return The document.
*/
public Document getDocument() {
- if (document == null)
- throw new IllegalStateException("Must parse something first");
+ if (document == null) {
+ throw new IllegalStateException("Must parse something first");
+ }
return document;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/EnterpriseEntityResolver.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/EnterpriseEntityResolver.java b/commons/src/main/java/org/apache/oodt/commons/util/EnterpriseEntityResolver.java
index bc91a10..a70c86b 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/EnterpriseEntityResolver.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/EnterpriseEntityResolver.java
@@ -56,9 +56,9 @@ public class EnterpriseEntityResolver implements EntityResolver {
token.append(ch, start, length);
}
public void endElement(String ns, String name, String qual) {
- if ("pi".equals(qual))
- pi = token.toString().trim();
- else if ("filename".equals(qual)) {
+ if ("pi".equals(qual)) {
+ pi = token.toString().trim();
+ } else if ("filename".equals(qual)) {
entities.put(pi, token.toString().trim());
}
token.delete(0, token.length());
@@ -78,20 +78,26 @@ public class EnterpriseEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicID, String systemID) throws SAXException, IOException {
String filename = computeFilename(publicID, systemID);
- if (filename == null) return null;
+ if (filename == null) {
+ return null;
+ }
// Resolve it using class loader first. Any DTD in the toplevel directory
// of any jar present to the application is a potential source.
InputStream in = getClass().getResourceAsStream("/" + filename);
- if (in != null)
- return new InputSource(new BufferedReader(new InputStreamReader(in)));
+ if (in != null) {
+ return new InputSource(new BufferedReader(new InputStreamReader(in)));
+ }
// OK, try the filesystem next. You can control what directories get
// searched by setting the entity.dirs property.
File file = findFile(getEntityRefDirs(System.getProperty("entity.dirs", "")), filename);
- if (file != null) try {
+ if (file != null) {
+ try {
return new InputSource(new BufferedReader(new FileReader(file)));
- } catch (IOException ignore) {}
+ } catch (IOException ignore) {
+ }
+ }
// No luck either way.
return null;
@@ -109,11 +115,14 @@ public class EnterpriseEntityResolver implements EntityResolver {
*/
static String computeFilename(String publicID, String systemID) {
String name = (String) entities.get(publicID);
- if (name == null) try {
+ if (name == null) {
+ try {
URL url = new URL(systemID);
File file = new File(url.getFile());
name = file.getName();
- } catch (MalformedURLException ignore) {}
+ } catch (MalformedURLException ignore) {
+ }
+ }
return name;
}
@@ -125,8 +134,9 @@ public class EnterpriseEntityResolver implements EntityResolver {
*/
static List getEntityRefDirs(String spec) {
List dirs = new ArrayList();
- for (StringTokenizer t = new StringTokenizer(spec, ",;|"); t.hasMoreTokens();)
- dirs.add(t.nextToken());
+ for (StringTokenizer t = new StringTokenizer(spec, ",;|"); t.hasMoreTokens();) {
+ dirs.add(t.nextToken());
+ }
return dirs;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java b/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
index 890eac7..4e69691 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/JDBC_DB.java
@@ -96,17 +96,21 @@ public class JDBC_DB
{
String url, classname;
- if (stmt != null)
- stmt.close();
+ if (stmt != null) {
+ stmt.close();
+ }
- if (rs != null)
- rs.close();
+ if (rs != null) {
+ rs.close();
+ }
- if (keep_connect_open)
- return;
+ if (keep_connect_open) {
+ return;
+ }
- if (connect != null)
- connect.close();
+ if (connect != null) {
+ connect.close();
+ }
rs_meta = null;
@@ -117,8 +121,9 @@ public class JDBC_DB
Properties props = new Properties();
props.put("user", username);
- if (password != null)
- props.put("password", password);
+ if (password != null) {
+ props.put("password", password);
+ }
classname = serverProps.getProperty("org.apache.oodt.commons.util.JDBC_DB.driver", "oracle.jdbc.driver.OracleDriver");
@@ -202,26 +207,32 @@ public class JDBC_DB
*/
sql_command = cmd;
- if (stmt!=null)
- stmt.close();
+ if (stmt!=null) {
+ stmt.close();
+ }
- if (connect == null) openConnection();
+ if (connect == null) {
+ openConnection();
+ }
if (connect == null) {
keep_connect_open = false;
openConnection();
}
- if (connect == null)
- throw new IllegalStateException("Connection is null!!!");
+ if (connect == null) {
+ throw new IllegalStateException("Connection is null!!!");
+ }
if (connect.isClosed()) {
connect = null;
keep_connect_open = false;
openConnection();
}
- if (connect == null)
- throw new IllegalStateException("Connection is still null!!!");
- if (connect.isClosed())
- throw new IllegalStateException("Connection got closed!");
+ if (connect == null) {
+ throw new IllegalStateException("Connection is still null!!!");
+ }
+ if (connect.isClosed()) {
+ throw new IllegalStateException("Connection got closed!");
+ }
stmt = connect.createStatement();
affected = stmt.executeUpdate(sql_command);
@@ -239,26 +250,32 @@ public class JDBC_DB
sql_command = cmd;
- if (stmt!=null)
- stmt.close();
+ if (stmt!=null) {
+ stmt.close();
+ }
- if (connect == null) openConnection();
+ if (connect == null) {
+ openConnection();
+ }
if (connect == null) {
keep_connect_open = false;
openConnection();
}
- if (connect == null)
- throw new IllegalStateException("Connection is null!!!");
+ if (connect == null) {
+ throw new IllegalStateException("Connection is null!!!");
+ }
if (connect.isClosed()) {
connect = null;
keep_connect_open = false;
openConnection();
}
- if (connect == null)
- throw new IllegalStateException("Connection is still null!!!");
- if (connect.isClosed())
- throw new IllegalStateException("Connection got closed!");
+ if (connect == null) {
+ throw new IllegalStateException("Connection is still null!!!");
+ }
+ if (connect.isClosed()) {
+ throw new IllegalStateException("Connection got closed!");
+ }
//long time0 = System.currentTimeMillis();
@@ -267,8 +284,9 @@ public class JDBC_DB
//System.err.println("###### Creating a new statement: " + (time - time0));
//time0 = time;
- if (rs!=null)
- rs.close();
+ if (rs!=null) {
+ rs.close();
+ }
rs = stmt.executeQuery(sql_command);
//time = System.currentTimeMillis();
@@ -294,13 +312,15 @@ public class JDBC_DB
int count;
- if (stmt!=null)
- stmt.close();
+ if (stmt!=null) {
+ stmt.close();
+ }
stmt = connect.createStatement();
- if (rs!=null)
- rs.close();
+ if (rs!=null) {
+ rs.close();
+ }
rs = stmt.executeQuery(sql_command);
@@ -342,8 +362,9 @@ public class JDBC_DB
{
try
{
- if (connect != null)
- connect.rollback();
+ if (connect != null) {
+ connect.rollback();
+ }
}
catch (SQLException ignored)
@@ -410,13 +431,16 @@ public class JDBC_DB
public Connection getConnection() throws SQLException
{
- if (connect == null) openConnection();
+ if (connect == null) {
+ openConnection();
+ }
if (connect == null) {
keep_connect_open = false;
openConnection();
}
- if (connect == null)
- throw new IllegalStateException("getConnection can't get a connection pointer");
+ if (connect == null) {
+ throw new IllegalStateException("getConnection can't get a connection pointer");
+ }
return(connect);
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java b/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java
index 41d86aa..55f13e4 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/LogInit.java
@@ -66,15 +66,17 @@ public class LogInit {
// Another destination is any user-specified logger.
String userSpecifiedListener = props.getProperty("org.apache.oodt.commons.util.LogInit.listener");
- if (userSpecifiedListener != null)
- mux.addListener((LogListener) Class.forName(userSpecifiedListener).newInstance());
+ if (userSpecifiedListener != null) {
+ mux.addListener((LogListener) Class.forName(userSpecifiedListener).newInstance());
+ }
// Ahead of the multiplexer is the filter.
String categoryList = props.getProperty("org.apache.oodt.commons.util.LogInit.categories", "");
StringTokenizer tokens = new StringTokenizer(categoryList);
Object[] categories = new Object[tokens.countTokens()];
- for (int i = 0; i < categories.length; ++i)
- categories[i] = tokens.nextToken();
+ for (int i = 0; i < categories.length; ++i) {
+ categories[i] = tokens.nextToken();
+ }
EnterpriseLogFilter filter = new EnterpriseLogFilter(mux, true, categories);
Log.addLogListener(filter);
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/MemoryLogger.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/MemoryLogger.java b/commons/src/main/java/org/apache/oodt/commons/util/MemoryLogger.java
index 28dbf03..4e0cee1 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/MemoryLogger.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/MemoryLogger.java
@@ -69,13 +69,20 @@ public class MemoryLogger implements LogListener {
* @param size The new maximum cache size.
*/
public void setSize(int size) {
- if (size < 0) throw new IllegalArgumentException("Log cache size can't be negative");
+ if (size < 0) {
+ throw new IllegalArgumentException("Log cache size can't be negative");
+ }
int delta = this.size - size;
this.size = size;
- if (delta <= 0) return;
- if (messages.size() < size) return;
- while (delta-- > 0)
- messages.removeFirst();
+ if (delta <= 0) {
+ return;
+ }
+ if (messages.size() < size) {
+ return;
+ }
+ while (delta-- > 0) {
+ messages.removeFirst();
+ }
}
public void streamStarted(LogEvent ignore) {}
@@ -85,8 +92,9 @@ public class MemoryLogger implements LogListener {
public void messageLogged(LogEvent event) {
messages.add(DateConvert.isoFormat(event.getTimestamp()) + " " + event.getSource() + " " + event.getCategory()
+ ": " + event.getMessage());
- if (messages.size() > size)
- messages.removeFirst();
+ if (messages.size() > size) {
+ messages.removeFirst();
+ }
}
/** The list of messages. */
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/Utility.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/Utility.java b/commons/src/main/java/org/apache/oodt/commons/util/Utility.java
index 60a7f6e..e54b9bc 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/Utility.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/Utility.java
@@ -66,9 +66,12 @@ public class Utility {
} catch (IOException ex) {
System.err.println("I/O exception while loading \"" + resourceName + "\": " + ex.getMessage());
} finally {
- if (in != null) try {
+ if (in != null) {
+ try {
in.close();
- } catch (IOException ignore) {}
+ } catch (IOException ignore) {
+ }
+ }
}
}
@@ -82,21 +85,26 @@ public class Utility {
* @return The iterator over unique elements in the <var>list</var>.
*/
public static Iterator parseCommaList(final String list) {
- if (list == null) return new Iterator() {
+ if (list == null) {
+ return new Iterator() {
public boolean hasNext() {
- return false;
+ return false;
}
+
public Object next() {
- throw new java.util.NoSuchElementException("There weren't ANY elements in this iterator, ever");
+ throw new java.util.NoSuchElementException("There weren't ANY elements in this iterator, ever");
}
+
public void remove() {
- throw new UnsupportedOperationException("Can't remove elements from this iterator");
+ throw new UnsupportedOperationException("Can't remove elements from this iterator");
}
- };
+ };
+ }
HashSet set = new HashSet();
StringTokenizer tokens = new StringTokenizer(list, ",");
- while (tokens.hasMoreTokens())
- set.add(tokens.nextToken().trim());
+ while (tokens.hasMoreTokens()) {
+ set.add(tokens.nextToken().trim());
+ }
return set.iterator();
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/util/XML.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/util/XML.java b/commons/src/main/java/org/apache/oodt/commons/util/XML.java
index 2c862a8..2212c5e 100644
--- a/commons/src/main/java/org/apache/oodt/commons/util/XML.java
+++ b/commons/src/main/java/org/apache/oodt/commons/util/XML.java
@@ -377,7 +377,9 @@ public class XML {
* @throws DOMException If a DOM error occurs.
*/
public static void addNonNull(Node node, String name, String text) throws DOMException {
- if (text == null) return;
+ if (text == null) {
+ return;
+ }
add(node, name, text);
}
@@ -402,11 +404,17 @@ public class XML {
* @throws DOMException If a DOM error occurs.
*/
public static void add(Node node, String name, String text) throws DOMException {
- if (name == null) return;
- if (node == null) throw new IllegalArgumentException("Can't add to a null node");
+ if (name == null) {
+ return;
+ }
+ if (node == null) {
+ throw new IllegalArgumentException("Can't add to a null node");
+ }
Document doc = node.getOwnerDocument();
Element element = doc.createElement(name);
- if (text != null) element.appendChild(doc.createTextNode(text));
+ if (text != null) {
+ element.appendChild(doc.createTextNode(text));
+ }
node.appendChild(element);
}
@@ -456,7 +464,9 @@ public class XML {
* @return The text in its children, unwrapped.
*/
public static String unwrappedText(Node node) {
- if (node == null) return null;
+ if (node == null) {
+ return null;
+ }
StringBuffer buffer = new StringBuffer();
StringBuilder wrapped = new StringBuilder(text1(node, buffer));
boolean newline = false;
@@ -470,8 +480,9 @@ public class XML {
if (Character.isWhitespace(wrapped.charAt(i))) {
wrapped.deleteCharAt(i);
--i;
- } else
- newline = false;
+ } else {
+ newline = false;
+ }
}
}
return wrapped.toString().trim();
@@ -560,16 +571,19 @@ public class XML {
// reference. Non printables are below ASCII space but not tab or
// line terminator, ASCII delete, or above a certain Unicode
// threshold.
- if ((ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r') || ch > LAST_PRINTABLE || ch == 0xF7)
- result.append("&#").append(Integer.toString(ch)).append(';');
- else {
+ if ((ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r') || ch > LAST_PRINTABLE || ch == 0xF7) {
+ result.append("&#").append(Integer.toString(ch)).append(';');
+ } else {
// If there is a suitable entity reference for this
// character, print it. The list of available entity
// references is almost but not identical between XML and
// HTML.
charRef = getEntityRef(ch);
- if (charRef == null) result.append(ch);
- else result.append('&').append(charRef).append(';');
+ if (charRef == null) {
+ result.append(ch);
+ } else {
+ result.append('&').append(charRef).append(';');
+ }
}
}
return result.toString();
@@ -581,9 +595,9 @@ public class XML {
* @param node Node to search.
*/
private static void findCommentNodes(List list, Node node) {
- if (node.getNodeType() == Node.COMMENT_NODE)
- list.add(node);
- else {
+ if (node.getNodeType() == Node.COMMENT_NODE) {
+ list.add(node);
+ } else {
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
findCommentNodes(list, children.item(i));
@@ -616,10 +630,11 @@ public class XML {
*/
private static String text1(Node node, StringBuffer buffer) {
for (Node ch = node.getFirstChild(); ch != null; ch = ch.getNextSibling()) {
- if (ch.getNodeType() == Node.ELEMENT_NODE || ch.getNodeType() == Node.ENTITY_REFERENCE_NODE)
- buffer.append(text(ch));
- else if (ch.getNodeType() == Node.TEXT_NODE)
- buffer.append(ch.getNodeValue());
+ if (ch.getNodeType() == Node.ELEMENT_NODE || ch.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
+ buffer.append(text(ch));
+ } else if (ch.getNodeType() == Node.TEXT_NODE) {
+ buffer.append(ch.getNodeValue());
+ }
}
return buffer.toString();
}
@@ -633,12 +648,14 @@ public class XML {
* @param node The tree to output.
*/
private static void dump(PrintWriter writer, Node node, int indentAmt) {
- for (int i = 0; i < indentAmt; ++i)
- writer.print(' ');
+ for (int i = 0; i < indentAmt; ++i) {
+ writer.print(' ');
+ }
writer.println(typeOf(node) + "(" + node.getNodeName() + ", " + node.getNodeValue() + ")");
NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); ++i)
- dump(writer, children.item(i), indentAmt + 2);
+ for (int i = 0; i < children.getLength(); ++i) {
+ dump(writer, children.item(i), indentAmt + 2);
+ }
}
/** Return a human-readable representation of the type of the given node.
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/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 b2ed7f8..3c2bcc6 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
@@ -77,8 +77,9 @@ public class XMLRPC {
* @throws DOMException If we can't construct the <value>.
*/
private static Element createValueElement(Document doc, Object value) throws DOMException {
- if (value == null)
- throw new IllegalArgumentException("Nulls not supported in XML-RPC");
+ if (value == null) {
+ throw new IllegalArgumentException("Nulls not supported in XML-RPC");
+ }
Element valueElement = doc.createElement("value");
if (value instanceof Integer || value instanceof Short) {
XML.add(valueElement, "int", value.toString());
@@ -119,7 +120,9 @@ public class XMLRPC {
for (Object aCollection : collection) {
dataElement.appendChild(createValueElement(doc, aCollection));
}
- } else throw new IllegalArgumentException(value.getClass().getName() + " not supported in XML-RPC");
+ } else {
+ throw new IllegalArgumentException(value.getClass().getName() + " not supported in XML-RPC");
+ }
return valueElement;
}
@@ -138,8 +141,9 @@ public class XMLRPC {
doc.normalize();
XML.removeComments(doc);
Element methodResponseElement = doc.getDocumentElement();
- if (!"methodResponse".equals(methodResponseElement.getNodeName()))
- throw new SAXException("Not a <methodResponse> document");
+ if (!"methodResponse".equals(methodResponseElement.getNodeName())) {
+ throw new SAXException("Not a <methodResponse> document");
+ }
Node child = methodResponseElement.getFirstChild();
if ("params".equals(child.getNodeName())) {
return parseValue(child.getFirstChild().getFirstChild());
@@ -151,7 +155,9 @@ public class XMLRPC {
} catch (ClassCastException ex) {
throw new SAXException("XML-RPC <fault> invalid");
}
- } else throw new SAXException("XML-RPC response does not contain <params> or <fault>");
+ } else {
+ throw new SAXException("XML-RPC response does not contain <params> or <fault>");
+ }
} catch (SAXException ex) {
throw new IllegalArgumentException(ex.getMessage());
} catch (IOException ex) {
@@ -166,7 +172,9 @@ public class XMLRPC {
*/
private static Object parseValue(Node node) {
String n = node.getNodeName();
- if (!"value".equals(n)) throw new IllegalArgumentException("Expecting a <value>, not a <" + n + ">");
+ if (!"value".equals(n)) {
+ throw new IllegalArgumentException("Expecting a <value>, not a <" + n + ">");
+ }
Node t = node.getFirstChild();
n = t.getNodeName();
@@ -180,9 +188,13 @@ public class XMLRPC {
if ("i4".equals(n) || "int".equals(n)) {
return Integer.valueOf(txt);
} else if ("boolean".equals(n)) {
- 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");
+ 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;
} else if ("double".equals(n)) {
@@ -200,28 +212,35 @@ public class XMLRPC {
NodeList memberNodes = t.getChildNodes();
for (int i = 0; i < memberNodes.getLength(); ++i) {
Node memberNode = memberNodes.item(i);
- if (!"member".equals(memberNode.getNodeName()))
- throw new IllegalArgumentException(n + " contains <" + memberNode.getNodeName()
- + ">, not <member>");
+ if (!"member".equals(memberNode.getNodeName())) {
+ throw new IllegalArgumentException(n + " contains <" + memberNode.getNodeName()
+ + ">, not <member>");
+ }
Node nameNode = memberNode.getFirstChild();
- if (nameNode == null || !"name".equals(nameNode.getNodeName()))
- throw new IllegalArgumentException("<member> missing <name> element");
+ if (nameNode == null || !"name".equals(nameNode.getNodeName())) {
+ throw new IllegalArgumentException("<member> missing <name> element");
+ }
Node valueNode = nameNode.getNextSibling();
- if (valueNode == null || !"value".equals(valueNode.getNodeName()))
- throw new IllegalArgumentException("<member> missing <value> element");
+ if (valueNode == null || !"value".equals(valueNode.getNodeName())) {
+ throw new IllegalArgumentException("<member> missing <value> element");
+ }
m.put(XML.unwrappedText(nameNode), parseValue(valueNode));
}
return m;
} else if ("array".equals(n)) {
Node dataNode = t.getFirstChild();
- if (dataNode == null || !"data".equals(dataNode.getNodeName()))
- throw new IllegalArgumentException("<array> missing <data> element");
+ if (dataNode == null || !"data".equals(dataNode.getNodeName())) {
+ throw new IllegalArgumentException("<array> missing <data> element");
+ }
NodeList children = dataNode.getChildNodes();
List x = new ArrayList(children.getLength());
- for (int i = 0; i < children.getLength(); ++i)
- x.add(parseValue(children.item(i)));
+ for (int i = 0; i < children.getLength(); ++i) {
+ x.add(parseValue(children.item(i)));
+ }
return x;
- } else throw new IllegalArgumentException("Illegal type " + n + " in <value>");
+ } else {
+ throw new IllegalArgumentException("Illegal type " + n + " in <value>");
+ }
}
/** Constructor that causes a runtime exception since this is a utility class.
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java b/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java
index 466b374..ba6b791 100644
--- a/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java
+++ b/commons/src/main/java/org/apache/oodt/commons/xml/XMLUtils.java
@@ -139,8 +139,9 @@ public class XMLUtils {
NodeList list = root.getElementsByTagName(name);
if (list.getLength()>0) {
return (Element) list.item(0);
- } else
+ } else {
return null;
+ }
}
public static String getSimpleElementText(Element node, boolean trim) {
@@ -153,8 +154,9 @@ public class XMLUtils {
}
return elemTxt;
- } else
+ } else {
return null;
+ }
}
public static String getSimpleElementText(Element node) {
@@ -166,8 +168,9 @@ public class XMLUtils {
Element elem = getFirstElement(elemName, root);
if (elem != null) {
return getSimpleElementText(elem, trim);
- } else
+ } else {
return null;
+ }
}
public static String getElementText(String elemName, Element root) {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java
index 9e66c6d..d663e84 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/MetExtractorProductCrawler.java
@@ -60,8 +60,9 @@ public class MetExtractorProductCrawler extends ProductCrawler {
if (this.getPreCondIds() != null) {
for (String preCondId : this.getPreCondIds()) {
if (!((PreConditionComparator<?>) this.getApplicationContext()
- .getBean(preCondId)).passes(product))
- return false;
+ .getBean(preCondId)).passes(product)) {
+ return false;
+ }
}
}
return product.exists() && product.length() > 0;
@@ -89,8 +90,9 @@ public class MetExtractorProductCrawler extends ProductCrawler {
IllegalAccessException, ClassNotFoundException {
this.metExtractor = (MetExtractor) Class.forName(metExtractor)
.newInstance();
- if (metExtractorConfig != null && !metExtractorConfig.equals(""))
- this.metExtractor.setConfigFile(metExtractorConfig);
+ if (metExtractorConfig != null && !metExtractorConfig.equals("")) {
+ this.metExtractor.setConfigFile(metExtractorConfig);
+ }
}
@Required
@@ -98,8 +100,9 @@ public class MetExtractorProductCrawler extends ProductCrawler {
throws MetExtractionException {
this.metExtractorConfig = metExtractorConfig;
if (this.metExtractor != null && metExtractorConfig != null
- && !metExtractorConfig.equals(""))
- this.metExtractor.setConfigFile(metExtractorConfig);
+ && !metExtractorConfig.equals("")) {
+ this.metExtractor.setConfigFile(metExtractorConfig);
+ }
}
public List<String> getPreCondIds() {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
index 2e70a79..974d5a7 100755
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
@@ -50,10 +50,11 @@ public class GroupAction extends CrawlerAction {
try {
LOG.info("Performing action (id = " + action.getId()
+ " : description = " + action.getDescription() + ")");
- if (!action.performAction(product, metadata))
+ if (!action.performAction(product, metadata)) {
throw new Exception("Action (id = " + action.getId()
- + " : description = " + action.getDescription()
- + ") returned false");
+ + " : description = " + action.getDescription()
+ + ") returned false");
+ }
} catch (Exception e) {
allSucceeded = false;
LOG.warning("Failed to perform crawler action : " + e.getMessage());
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MimeTypeCrawlerAction.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MimeTypeCrawlerAction.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MimeTypeCrawlerAction.java
index 79b9e73..4baae5e 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MimeTypeCrawlerAction.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MimeTypeCrawlerAction.java
@@ -51,8 +51,9 @@ public class MimeTypeCrawlerAction extends CrawlerAction {
throws CrawlerActionException {
List<String> mimeTypeHierarchy = productMetadata
.getAllMetadata(MIME_TYPES_HIERARCHY);
- if (mimeTypeHierarchy == null)
+ if (mimeTypeHierarchy == null) {
mimeTypeHierarchy = new Vector<String>();
+ }
if (mimeTypes == null || (!Collections.disjoint(mimeTypes,
mimeTypeHierarchy))) {
return this.actionToCall.performAction(product, productMetadata);
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java
index 42809a0..e1061a3 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java
@@ -56,13 +56,15 @@ public class MoveFile extends CrawlerAction {
try {
if (mvFile == null) {
mvFile = product.getAbsolutePath();
- if (this.fileExtension != null)
+ if (this.fileExtension != null) {
mvFile += "." + this.fileExtension;
+ }
}
File srcFile = new File(mvFile);
File toFile = new File(toDir + "/" + srcFile.getName());
- if (createToDir)
+ if (createToDir) {
toFile.getParentFile().mkdirs();
+ }
LOG.log(Level.INFO, "Moving file " + srcFile.getAbsolutePath()
+ " to " + toFile.getAbsolutePath());
if(!srcFile.renameTo(toFile)) {//If the file failed to copy
@@ -72,8 +74,9 @@ public class MoveFile extends CrawlerAction {
FileUtils.forceDelete(srcFile); //Need to delete the old file
return true; //File copied on second attempt
}
- else
- return true; //File copied
+ else {
+ return true; //File copied
+ }
} catch (Exception e) {
throw new CrawlerActionException("Failed to move file from " + mvFile
+ " to " + this.toDir + " : " + e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ToggleAction.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ToggleAction.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ToggleAction.java
index 3a7fc61..e27d9be 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ToggleAction.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ToggleAction.java
@@ -49,8 +49,9 @@ public class ToggleAction extends CrawlerAction {
&& (currentAction = toggle.getCrawlerAction())
.performAction(product, productMetadata)) {
globalSuccess = true;
- if (this.shortCircuit)
+ if (this.shortCircuit) {
return true;
+ }
}
} catch (Exception e) {
LOG.log(Level.WARNING, "Failed to run toggle action '"
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/cli/option/handler/CrawlerActionInfoHandler.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/cli/option/handler/CrawlerActionInfoHandler.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/cli/option/handler/CrawlerActionInfoHandler.java
index 656e2c2..ddbe378 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/cli/option/handler/CrawlerActionInfoHandler.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/cli/option/handler/CrawlerActionInfoHandler.java
@@ -50,9 +50,10 @@ public class CrawlerActionInfoHandler extends BeanInfoHandler {
ps.println(" Id: " + ca.getId());
ps.println(" Description: " + ca.getDescription());
ps.println(" Phases: " + ca.getPhases());
- if (ca instanceof MimeTypeCrawlerAction)
- ps.println(" MimeTypes: "
- + ((MimeTypeCrawlerAction) ca).getMimeTypes());
+ if (ca instanceof MimeTypeCrawlerAction) {
+ ps.println(" MimeTypes: "
+ + ((MimeTypeCrawlerAction) ca).getMimeTypes());
+ }
ps.println();
}
ps.close();
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java
index d201d44..9485b29 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemonController.java
@@ -209,8 +209,9 @@ public class CrawlDaemonController {
controller.stop();
System.out.println("Crawl Daemon: [" + controller.client.getURL()
+ "]: shutdown successful");
- } else
+ } else {
throw new IllegalArgumentException("Unknown Operation!");
+ }
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MetExtractorSpec.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MetExtractorSpec.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MetExtractorSpec.java
index 70f109d..d3a386b 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MetExtractorSpec.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MetExtractorSpec.java
@@ -91,8 +91,9 @@ public class MetExtractorSpec {
ClassNotFoundException, MetExtractionException {
this.metExtractor = (MetExtractor) Class.forName(extractorClassName)
.newInstance();
- if (this.configFile != null)
+ if (this.configFile != null) {
this.metExtractor.setConfigFile(this.configFile);
+ }
}
/**
@@ -103,8 +104,9 @@ public class MetExtractorSpec {
public void setExtractorConfigFile(String extractorConfigFile)
throws MetExtractionException {
this.configFile = extractorConfigFile;
- if (this.configFile != null && this.metExtractor != null)
+ if (this.configFile != null && this.metExtractor != null) {
this.metExtractor.setConfigFile(this.configFile);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java
index 307aa52..d4140a1 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorConfigReader.java
@@ -83,9 +83,10 @@ public final class MimeExtractorConfigReader implements
if (preCondsElem != null) {
NodeList preCondComparators =
preCondsElem.getElementsByTagName(PRECONDITION_COMPARATOR_TAG);
- for (int k = 0; k < preCondComparators.getLength(); k++)
- preCondComparatorIds.add(((Element) preCondComparators
- .item(k)).getAttribute(ID_ATTR));
+ for (int k = 0; k < preCondComparators.getLength(); k++) {
+ preCondComparatorIds.add(((Element) preCondComparators
+ .item(k)).getAttribute(ID_ATTR));
+ }
}
// This seems wrong, so added support for CLASS_ATTR while still
// supporting EXTRACTOR_CLASS_TAG as an attribute for specifying
@@ -150,10 +151,11 @@ public final class MimeExtractorConfigReader implements
NodeList preCondComparators = preCondsElem
.getElementsByTagName(PRECONDITION_COMPARATOR_TAG);
LinkedList<String> preCondComparatorIds = new LinkedList<String>();
- for (int k = 0; k < preCondComparators.getLength(); k++)
- preCondComparatorIds
- .add(((Element) preCondComparators.item(k))
- .getAttribute(ID_ATTR));
+ for (int k = 0; k < preCondComparators.getLength(); k++) {
+ preCondComparatorIds
+ .add(((Element) preCondComparators.item(k))
+ .getAttribute(ID_ATTR));
+ }
spec.setPreConditionComparatorIds(preCondComparatorIds);
}
@@ -203,8 +205,9 @@ public final class MimeExtractorConfigReader implements
Element elem = XMLUtils.getFirstElement(elemName, root);
if (elem != null) {
filePath = elem.getAttribute(FILE_ATTR);
- if (Boolean.valueOf(elem.getAttribute(ENV_REPLACE_ATTR)))
- filePath = PathUtils.replaceEnvVariables(filePath);
+ if (Boolean.valueOf(elem.getAttribute(ENV_REPLACE_ATTR))) {
+ filePath = PathUtils.replaceEnvVariables(filePath);
+ }
}
return filePath;
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorRepo.java
----------------------------------------------------------------------
diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorRepo.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorRepo.java
index 068d48f..b6e01f7 100644
--- a/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorRepo.java
+++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/typedetection/MimeExtractorRepo.java
@@ -94,8 +94,9 @@ public class MimeExtractorRepo {
MetExtractorSpec spec) {
List<MetExtractorSpec> specs = this.mimeTypeToMetExtractorSpecsMap
.remove(mimeType);
- if (specs == null)
- specs = new LinkedList<MetExtractorSpec>();
+ if (specs == null) {
+ specs = new LinkedList<MetExtractorSpec>();
+ }
specs.add(spec);
this.mimeTypeToMetExtractorSpecsMap.put(mimeType, specs);
}
@@ -104,8 +105,9 @@ public class MimeExtractorRepo {
List<MetExtractorSpec> specs) {
List<MetExtractorSpec> existingSpecs = this.mimeTypeToMetExtractorSpecsMap
.remove(mimeType);
- if (existingSpecs == null)
- existingSpecs = new LinkedList<MetExtractorSpec>();
+ if (existingSpecs == null) {
+ existingSpecs = new LinkedList<MetExtractorSpec>();
+ }
existingSpecs.addAll(specs);
this.mimeTypeToMetExtractorSpecsMap.put(mimeType, existingSpecs);
}
@@ -115,8 +117,9 @@ public class MimeExtractorRepo {
List<MetExtractorSpec> extractorSpecs = new LinkedList<MetExtractorSpec>();
while (mimeType != null && !mimeType.equals("application/octet-stream")) {
List<MetExtractorSpec> specs = this.mimeTypeToMetExtractorSpecsMap.get(mimeType);
- if (specs != null)
- extractorSpecs.addAll(specs);
+ if (specs != null) {
+ extractorSpecs.addAll(specs);
+ }
mimeType = this.mimeRepo.getSuperTypeForMimeType(mimeType);
}
return !extractorSpecs.isEmpty() ? extractorSpecs : this
@@ -126,9 +129,10 @@ public class MimeExtractorRepo {
public synchronized List<MetExtractorSpec> getExtractorSpecsForFile(
File file) throws IOException {
String mimeType = this.mimeRepo.getMimeType(file);
- if (mimeType == null && magic)
- mimeType = this.mimeRepo.getMimeTypeByMagic(MimeTypeUtils
- .readMagicHeader(new FileInputStream(file)));
+ if (mimeType == null && magic) {
+ mimeType = this.mimeRepo.getMimeTypeByMagic(MimeTypeUtils
+ .readMagicHeader(new FileInputStream(file)));
+ }
return this.getExtractorSpecsForMimeType(mimeType);
}
@@ -169,8 +173,9 @@ public class MimeExtractorRepo {
*/
public void setMagic(boolean magic) {
this.magic = magic;
- if (this.mimeRepo != null)
- this.mimeRepo.setMimeMagic(magic);
+ if (this.mimeRepo != null) {
+ this.mimeRepo.setMimeMagic(magic);
+ }
}
/**
@@ -178,8 +183,9 @@ public class MimeExtractorRepo {
*/
public void setMimeRepoFile(String mimeRepoFile)
throws FileNotFoundException {
- if (mimeRepoFile != null)
- this.mimeRepo = new MimeTypeUtils(mimeRepoFile, this.magic);
+ if (mimeRepoFile != null) {
+ this.mimeRepo = new MimeTypeUtils(mimeRepoFile, this.magic);
+ }
}
public String getMimeType(File file) {
@@ -197,8 +203,9 @@ public class MimeExtractorRepo {
String mimeType = getMimeType(file);
mimeTypes.add(mimeType);
while ((mimeType = this.mimeRepo.getSuperTypeForMimeType(mimeType)) != null
- && !mimeType.equals("application/octet-stream"))
- mimeTypes.add(mimeType);
+ && !mimeType.equals("application/octet-stream")) {
+ mimeTypes.add(mimeType);
+ }
return mimeTypes;
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/curator/services/src/main/java/org/apache/oodt/cas/curation/service/IngestionResource.java
----------------------------------------------------------------------
diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/IngestionResource.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/IngestionResource.java
index fffeb8b..3c43174 100644
--- a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/IngestionResource.java
+++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/IngestionResource.java
@@ -334,8 +334,9 @@ public class IngestionResource extends CurationService {
return -1;
} else if (o1.getCreateDate().equals(o2.getCreateDate())) {
return 0;
- } else
+ } else {
return 1;
+ }
}
});
return taskList;
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java
----------------------------------------------------------------------
diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java
index 1335240..4492850 100644
--- a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java
+++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java
@@ -732,8 +732,9 @@ public class MetadataResource extends CurationService {
if (catalog==null) {
String catalogFactoryClass = this.context.getInitParameter(CATALOG_FACTORY_CLASS);
// preserve backward compatibility
- if (!StringUtils.hasText(catalogFactoryClass))
- catalogFactoryClass = "org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory";
+ if (!StringUtils.hasText(catalogFactoryClass)) {
+ catalogFactoryClass = "org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory";
+ }
catalog = GenericFileManagerObjectFactory.getCatalogServiceFromFactory(catalogFactoryClass);
}
@@ -913,8 +914,9 @@ public class MetadataResource extends CurationService {
try {
for(ProductType type : xmlRepo.getProductTypes()) {
for(Element el : vLayer.getElements(type)) {
- if(el.getElementId().equals(elementId))
- typeids.add(type.getProductTypeId());
+ if(el.getElementId().equals(elementId)) {
+ typeids.add(type.getProductTypeId());
+ }
}
}
} catch (Exception e) {
@@ -941,8 +943,9 @@ public class MetadataResource extends CurationService {
}
}
for(Element el: elements) {
- if(!usedElementIds.containsKey(el.getElementId()))
- vLayer.removeElement(el);
+ if(!usedElementIds.containsKey(el.getElementId())) {
+ vLayer.removeElement(el);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/curator/services/src/main/java/org/apache/oodt/cas/curation/util/ExtractorConfigWriter.java
----------------------------------------------------------------------
diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/ExtractorConfigWriter.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/ExtractorConfigWriter.java
index 3ca26a5..ec0ffc3 100644
--- a/curator/services/src/main/java/org/apache/oodt/cas/curation/util/ExtractorConfigWriter.java
+++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/util/ExtractorConfigWriter.java
@@ -39,8 +39,9 @@ public class ExtractorConfigWriter {
for (Iterator<File> i = config.getConfigFiles().iterator(); i.hasNext();) {
File file = i.next();
files.append(file.toURI());
- if (i.hasNext())
+ if (i.hasNext()) {
files.append(",");
+ }
}
props.setProperty(ExtractorConfig.PROP_CONFIG_FILES, files.toString());
OutputStream os = new FileOutputStream(new File(configDir, "config.properties"));
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/curator/webapp/src/main/java/org/apache/oodt/cas/curation/CurationApp.java
----------------------------------------------------------------------
diff --git a/curator/webapp/src/main/java/org/apache/oodt/cas/curation/CurationApp.java b/curator/webapp/src/main/java/org/apache/oodt/cas/curation/CurationApp.java
index 2decb08..00140a7 100644
--- a/curator/webapp/src/main/java/org/apache/oodt/cas/curation/CurationApp.java
+++ b/curator/webapp/src/main/java/org/apache/oodt/cas/curation/CurationApp.java
@@ -109,10 +109,12 @@ public class CurationApp extends WebApplication {
private Set<String> filterBenchResources(Set<String> bench,
Set<String> local, String localPrefix) {
- if (local == null || (local.size() == 0))
+ if (local == null || (local.size() == 0)) {
return bench;
- if (bench == null || (bench.size() == 0))
+ }
+ if (bench == null || (bench.size() == 0)) {
return bench;
+ }
Set<String> filtered = new HashSet<String>();
for (String bResource : bench) {
String localName = new File(bResource).getName();
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java
index b37e8aa..327a80a 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java
@@ -296,7 +296,9 @@ public class DataSourceCatalog implements Catalog {
// reuse the existing product id if possible, or generate a new UUID string
String productId = product.getProductId();
- if (!StringUtils.hasText(productId)) productId = UUID.randomUUID().toString();
+ if (!StringUtils.hasText(productId)) {
+ productId = UUID.randomUUID().toString();
+ }
// insert product in database
addProductSql = "INSERT INTO products (product_id, product_name, product_structure, product_transfer_status, product_type_id, product_datetime) "
+ "VALUES ('"
@@ -806,7 +808,9 @@ public class DataSourceCatalog implements Catalog {
+ product.getProductType().getName() + "_reference"
+ " WHERE product_id = " + quoteIt(product.getProductId()));
- if(this.orderedValues) getProductRefSql.append(" ORDER BY pkey");
+ if(this.orderedValues) {
+ getProductRefSql.append(" ORDER BY pkey");
+ }
LOG.log(Level.FINE, "getProductReferences: Executing: "
+ getProductRefSql);
@@ -1042,7 +1046,9 @@ public class DataSourceCatalog implements Catalog {
+ product.getProductType().getName() + "_metadata"
+ " WHERE product_id = " + quoteIt(product.getProductId()));
- if(this.orderedValues) metadataSql.append(" ORDER BY pkey");
+ if(this.orderedValues) {
+ metadataSql.append(" ORDER BY pkey");
+ }
LOG.log(Level.FINE, "getMetadata: Executing: " + metadataSql);
rs = statement.executeQuery(metadataSql.toString());
@@ -1124,15 +1130,18 @@ public class DataSourceCatalog implements Catalog {
elementIds.append(" AND (element_id = '")
.append(this.validationLayer.getElementByName(elems.get(0)).getElementId
()).append("'");
- for (int i = 1; i < elems.size(); i++)
- elementIds.append(" OR element_id = '").append(this.validationLayer.getElementByName(elems.get(i))
- .getElementId()).append("'");
+ for (int i = 1; i < elems.size(); i++) {
+ elementIds.append(" OR element_id = '").append(this.validationLayer.getElementByName(elems.get(i))
+ .getElementId()).append("'");
+ }
elementIds.append(")");
}
StringBuilder metadataSql = new StringBuilder("SELECT element_id,metadata_value FROM "
+ product.getProductType().getName() + "_metadata"
+ " WHERE product_id = " + quoteIt(product.getProductId()) + elementIds);
- if(this.orderedValues) metadataSql.append(" ORDER BY pkey");
+ if(this.orderedValues) {
+ metadataSql.append(" ORDER BY pkey");
+ }
LOG.log(Level.FINE, "getMetadata: Executing: " + metadataSql);
rs = statement.executeQuery(metadataSql.toString());
@@ -2096,14 +2105,16 @@ public class DataSourceCatalog implements Catalog {
}else {
sqlQuery.append("(").append(this.getSqlQuery(bqc.getTerms().get(0), type));
String op = bqc.getOperator() == BooleanQueryCriteria.AND ? "INTERSECT" : "UNION";
- for (int i = 1; i < bqc.getTerms().size(); i++)
- sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(bqc.getTerms().get(i), type));
+ for (int i = 1; i < bqc.getTerms().size(); i++) {
+ sqlQuery.append(") ").append(op).append(" (").append(this.getSqlQuery(bqc.getTerms().get(i), type));
+ }
sqlQuery.append(")");
}
}else {
String elementIdStr = this.validationLayer.getElementByName(queryCriteria.getElementName()).getElementId();
- if (fieldIdStringFlag)
- elementIdStr = "'" + elementIdStr + "'";
+ if (fieldIdStringFlag) {
+ elementIdStr = "'" + elementIdStr + "'";
+ }
if (!this.productIdString) {
sqlQuery.append("SELECT DISTINCT product_id FROM ").append(type.getName())
.append("_metadata WHERE element_id = ").append(elementIdStr).append(" AND ");
@@ -2119,13 +2130,19 @@ public class DataSourceCatalog implements Catalog {
} else if (queryCriteria instanceof RangeQueryCriteria) {
RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria;
String rangeSubQuery = null;
- if (rqc.getStartValue() != null)
- rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
+ if (rqc.getStartValue() != null) {
+ rangeSubQuery =
+ "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
+ }
if (rqc.getEndValue() != null) {
- if (rangeSubQuery == null)
- rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
- else
- rangeSubQuery = "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
+ if (rangeSubQuery == null) {
+ rangeSubQuery =
+ "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
+ } else {
+ rangeSubQuery =
+ "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'"
+ + rqc.getEndValue() + "')";
+ }
}
sqlQuery.append(rangeSubQuery);
} else {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LenientDataSourceCatalog.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LenientDataSourceCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LenientDataSourceCatalog.java
index f9ff91d..c09e767 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LenientDataSourceCatalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LenientDataSourceCatalog.java
@@ -222,7 +222,9 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
String metadataSql = "SELECT * FROM "
+ product.getProductType().getName() + "_metadata "
+ "WHERE product_id = '" + product.getProductId()+"'";
- if(this.orderedValues) metadataSql += " ORDER BY pkey" ;
+ if(this.orderedValues) {
+ metadataSql += " ORDER BY pkey";
+ }
LOG.log(Level.FINE, "getMetadata: Executing: " + metadataSql);
rs = statement.executeQuery(metadataSql);
@@ -333,15 +335,19 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
if (getValidationLayer()!=null) {
// validation layer: column "element_id" contains the element identifier (e.g. "urn:oodt:ProductReceivedTime")
elementIds += " AND (element_id = '" + this.getValidationLayer().getElementByName(elems.get(0)).getElementId() + "'";
- for (int i = 1; i < elems.size(); i++)
- elementIds += " OR element_id = '" + this.getValidationLayer().getElementByName(elems.get(i)).getElementId() + "'";
+ for (int i = 1; i < elems.size(); i++) {
+ elementIds +=
+ " OR element_id = '" + this.getValidationLayer().getElementByName(elems.get(i)).getElementId()
+ + "'";
+ }
elementIds += ")";
} else {
// no validation layer: column "element_id" contains the element name (e.g. "CAS.ProductReceivedTime")
elementIds += " AND (element_id = '" + elems.get(0) + "'";
- for (int i = 1; i < elems.size(); i++)
- elementIds += " OR element_id = '" + elems.get(i) + "'";
+ for (int i = 1; i < elems.size(); i++) {
+ elementIds += " OR element_id = '" + elems.get(i) + "'";
+ }
elementIds += ")";
}
@@ -350,7 +356,9 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
String metadataSql = "SELECT element_id,metadata_value FROM "
+ product.getProductType().getName() + "_metadata"
+ " WHERE product_id = " + quoteIt(product.getProductId()) + elementIds;
- if(this.orderedValues) metadataSql += " ORDER BY pkey";
+ if(this.orderedValues) {
+ metadataSql += " ORDER BY pkey";
+ }
LOG.log(Level.FINE, "getMetadata: Executing: " + metadataSql);
rs = statement.executeQuery(metadataSql);
@@ -768,8 +776,9 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
} else {
sqlQuery = "(" + this.getSqlQuery(bqc.getTerms().get(0), type);
String op = bqc.getOperator() == BooleanQueryCriteria.AND ? "INTERSECT" : "UNION";
- for (int i = 1; i < bqc.getTerms().size(); i++)
- sqlQuery += ") " + op + " (" + this.getSqlQuery(bqc.getTerms().get(i), type);
+ for (int i = 1; i < bqc.getTerms().size(); i++) {
+ sqlQuery += ") " + op + " (" + this.getSqlQuery(bqc.getTerms().get(i), type);
+ }
sqlQuery += ")";
}
}else {
@@ -778,8 +787,9 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
elementIdStr = this.getValidationLayer().getElementByName(queryCriteria.getElementName()).getElementId();
}
- if (fieldIdStringFlag)
- elementIdStr = "'" + elementIdStr + "'";
+ if (fieldIdStringFlag) {
+ elementIdStr = "'" + elementIdStr + "'";
+ }
if (!this.productIdString) {
sqlQuery = "SELECT DISTINCT product_id FROM " + type.getName() + "_metadata WHERE element_id = " + elementIdStr + " AND ";
} else {
@@ -792,13 +802,19 @@ public class LenientDataSourceCatalog extends DataSourceCatalog {
} else if (queryCriteria instanceof RangeQueryCriteria) {
RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria;
String rangeSubQuery = null;
- if (rqc.getStartValue() != null)
- rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
+ if (rqc.getStartValue() != null) {
+ rangeSubQuery =
+ "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
+ }
if (rqc.getEndValue() != null) {
- if (rangeSubQuery == null)
- rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
- else
- rangeSubQuery = "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
+ if (rangeSubQuery == null) {
+ rangeSubQuery =
+ "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
+ } else {
+ rangeSubQuery =
+ "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc
+ .getEndValue() + "')";
+ }
}
sqlQuery += rangeSubQuery;
} else {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
index f439c4e..465a181 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
@@ -448,8 +448,9 @@ public class LuceneCatalog implements Catalog {
Product prod = getProductById(product.getProductId(), true);
if (prod != null) {
return prod.getProductReferences();
- } else
+ } else {
return null;
+ }
}
/*
@@ -602,8 +603,9 @@ public class LuceneCatalog implements Catalog {
Metadata fullMetadata = getMetadata(product);
Metadata reducedMetadata = new Metadata();
for (String element : elements) {
- if (fullMetadata.containsKey(element))
+ if (fullMetadata.containsKey(element)) {
reducedMetadata.replaceMetadata(element, fullMetadata.getAllMetadata(element));
+ }
}
return reducedMetadata;
}
@@ -1057,8 +1059,9 @@ public class LuceneCatalog implements Catalog {
r.setOrigReference(origRefs[i]);
r.setDataStoreReference(dataStoreRefs[i]);
r.setFileSize((Long.parseLong(refLengths[i])));
- if (refMimeTypes != null)
+ if (refMimeTypes != null) {
r.setMimeType(refMimeTypes[i]);
+ }
references.add(r);
}
@@ -1185,10 +1188,12 @@ public class LuceneCatalog implements Catalog {
}
return true;
- } else
+ } else {
return false;
- } else
+ }
+ } else {
return false;
+ }
}
@@ -1210,8 +1215,9 @@ public class LuceneCatalog implements Catalog {
booleanQuery.add(prodTypeTermQuery, BooleanClause.Occur.MUST);
//convert filemgr query into a lucene query
- for (QueryCriteria queryCriteria : query.getCriteria())
+ for (QueryCriteria queryCriteria : query.getCriteria()) {
booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
+ }
LOG.log(Level.FINE, "Querying LuceneCatalog: q: [" + booleanQuery
+ "]");
@@ -1258,8 +1264,9 @@ public class LuceneCatalog implements Catalog {
booleanQuery.add(prodTypeTermQuery, BooleanClause.Occur.MUST);
//convert filemgr query into a lucene query
- for (QueryCriteria queryCriteria : query.getCriteria())
+ for (QueryCriteria queryCriteria : query.getCriteria()) {
booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
+ }
Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
SortField.STRING, true));
@@ -1343,8 +1350,9 @@ public class LuceneCatalog implements Catalog {
throw new CatalogException("Invalid BooleanQueryCriteria opertor ["
+ ((BooleanQueryCriteria) queryCriteria).getOperator() + "]");
}
- for (QueryCriteria qc : ((BooleanQueryCriteria) queryCriteria).getTerms())
+ for (QueryCriteria qc : ((BooleanQueryCriteria) queryCriteria).getTerms()) {
booleanQuery.add(this.getQuery(qc), occur);
+ }
return booleanQuery;
} else if (queryCriteria instanceof TermQueryCriteria) {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/MappedDataSourceCatalog.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/MappedDataSourceCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/MappedDataSourceCatalog.java
index 39f5164..08d3e8c 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/MappedDataSourceCatalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/MappedDataSourceCatalog.java
@@ -219,8 +219,9 @@ public class MappedDataSourceCatalog extends DataSourceCatalog {
protected String getProductTypeTableName(String origName) {
if (typeMap != null && typeMap.containsKey(origName)) {
return typeMap.getProperty(origName);
- } else
+ } else {
return origName;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/DefaultProductSerializer.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/DefaultProductSerializer.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/DefaultProductSerializer.java
index 796bf96..2e9c53b 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/DefaultProductSerializer.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/DefaultProductSerializer.java
@@ -277,9 +277,15 @@ public class DefaultProductSerializer implements ProductSerializer {
}
List<String> docs = new ArrayList<String>();
- if (!delFields.isEmpty()) docs.add( toDoc(productId, delFields) );
- if (!setFields.isEmpty()) docs.add( toDoc(productId, setFields) );
- if (!addFields.isEmpty()) docs.add( toDoc(productId, addFields) );
+ if (!delFields.isEmpty()) {
+ docs.add(toDoc(productId, delFields));
+ }
+ if (!setFields.isEmpty()) {
+ docs.add(toDoc(productId, setFields));
+ }
+ if (!addFields.isEmpty()) {
+ docs.add(toDoc(productId, addFields));
+ }
return docs;
}
@@ -403,7 +409,9 @@ public class DefaultProductSerializer implements ProductSerializer {
if (name.startsWith(Parameters.NS)) {
for (int k=0; k<values.getLength(); k++) {
// create this reference
- if (references.size()<=k) references.add(new Reference());
+ if (references.size()<=k) {
+ references.add(new Reference());
+ }
if (name.equals(Parameters.REFERENCE_ORIGINAL)) {
references.get(k).setOrigReference(vals.get(k));
} else if (name.equals(Parameters.REFERENCE_DATASTORE)) {
@@ -449,7 +457,9 @@ public class DefaultProductSerializer implements ProductSerializer {
// CAS root reference
} else if (name.startsWith(Parameters.NS+Parameters.ROOT)) {
- if (rootReference==null) rootReference = new Reference();
+ if (rootReference==null) {
+ rootReference = new Reference();
+ }
if (name.equals(Parameters.ROOT_REFERENCE_ORIGINAL)) {
rootReference.setOrigReference(value);
} else if (name.equals(Parameters.ROOT_REFERENCE_DATASTORE)) {
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrCatalog.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrCatalog.java
index 382b9e3..bfaf3cd 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrCatalog.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/solr/SolrCatalog.java
@@ -285,8 +285,12 @@ public class SolrCatalog implements Catalog {
queryResponse.setNumFound( qr.getNumFound() );
start = offset+queryResponse.getCompleteProducts().size();
- if (limit<0) limit = queryResponse.getNumFound(); // retrieve ALL results
- if (start>=queryResponse.getNumFound()) break; // don't query any longer
+ if (limit<0) {
+ limit = queryResponse.getNumFound(); // retrieve ALL results
+ }
+ if (start>=queryResponse.getNumFound()) {
+ break; // don't query any longer
+ }
}
@@ -415,7 +419,9 @@ public class SolrCatalog implements Catalog {
public ProductPage getNextPage(ProductType type, ProductPage currentPage) {
int nextPageNumber = currentPage.getPageNum()+1;
- if (nextPageNumber>currentPage.getTotalPages()) throw new RuntimeException("Invalid next page number: "+nextPageNumber);
+ if (nextPageNumber>currentPage.getTotalPages()) {
+ throw new RuntimeException("Invalid next page number: " + nextPageNumber);
+ }
try {
return this.pagedQuery(new Query(), type, currentPage.getPageNum()+1);
@@ -430,7 +436,9 @@ public class SolrCatalog implements Catalog {
public ProductPage getPrevPage(ProductType type, ProductPage currentPage) {
int prevPageNumber = currentPage.getPageNum()-1;
- if (prevPageNumber<=0) throw new RuntimeException("Invalid previous page number: "+prevPageNumber);
+ if (prevPageNumber<=0) {
+ throw new RuntimeException("Invalid previous page number: " + prevPageNumber);
+ }
try {
return this.pagedQuery(new Query(), type, prevPageNumber);