http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolException.java deleted file mode 100644 index 5d23fb6..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class ProtocolException extends PushPullFrameworkException { - - private static final long serialVersionUID = -5585263924925230711L; - - public ProtocolException() { - super(); - } - - public ProtocolException(String msg) { - super(msg); - } - -}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolFileException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolFileException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolFileException.java deleted file mode 100644 index cc2b9ac..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ProtocolFileException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class ProtocolFileException extends PushPullFrameworkException { - - private static final long serialVersionUID = 5518075265972710679L; - - public ProtocolFileException() { - super(); - } - - public ProtocolFileException(String msg) { - super(msg); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/PushPullFrameworkException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/PushPullFrameworkException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/PushPullFrameworkException.java deleted file mode 100644 index 511bea8..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/PushPullFrameworkException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class PushPullFrameworkException extends Exception { - - private static final long serialVersionUID = 1500358666243383567L; - - public PushPullFrameworkException() { - super(); - } - - public PushPullFrameworkException(String msg) { - super(PushPullFrameworkException.addCallingClassToMsg(msg)); - } - - public PushPullFrameworkException(String msg, Throwable t) { - super(PushPullFrameworkException.addCallingClassToMsg(msg), t); - } - - private static String addCallingClassToMsg(String msg) { - try { - Throwable stack = new Throwable(); - stack.fillInStackTrace(); - String[] splitName = stack.getStackTrace()[3].getClassName().split( - "\\."); - return "[" + splitName[splitName.length - 1] + "] " + msg; - } catch (Exception e) { - return "[Unknown] " + msg; - } - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RemoteConnectionException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RemoteConnectionException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RemoteConnectionException.java deleted file mode 100644 index b9d5c5c..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RemoteConnectionException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class RemoteConnectionException extends PushPullFrameworkException { - - private static final long serialVersionUID = -8694907817201161502L; - - public RemoteConnectionException() { - super(); - } - - public RemoteConnectionException(String msg) { - super(msg); - } - - public RemoteConnectionException(String msg, Throwable t) { - super(msg, t); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java deleted file mode 100644 index b43e716..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/RetrievalMethodException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class RetrievalMethodException extends PushPullFrameworkException { - - private static final long serialVersionUID = 310484176199522L; - - public RetrievalMethodException() { - super(); - } - - public RetrievalMethodException(String msg) { - super(msg); - } - - public RetrievalMethodException(String msg, Throwable t) { - super(msg, t); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ThreadEvaluatorException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ThreadEvaluatorException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ThreadEvaluatorException.java deleted file mode 100644 index 194230e..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ThreadEvaluatorException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class ThreadEvaluatorException extends PushPullFrameworkException { - - private static final long serialVersionUID = 1974215121420264162L; - - public ThreadEvaluatorException() { - super(); - } - - public ThreadEvaluatorException(String msg) { - super(msg); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ToManyFailedDownloadsException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ToManyFailedDownloadsException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ToManyFailedDownloadsException.java deleted file mode 100644 index 961cb4b..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/ToManyFailedDownloadsException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class ToManyFailedDownloadsException extends PushPullFrameworkException { - - private static final long serialVersionUID = -5603700192543496505L; - - public ToManyFailedDownloadsException() { - super(); - } - - public ToManyFailedDownloadsException(String msg) { - super(msg); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/UndefinedTypeException.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/UndefinedTypeException.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/UndefinedTypeException.java deleted file mode 100644 index e853ee8..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/exceptions/UndefinedTypeException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.exceptions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class UndefinedTypeException extends PushPullFrameworkException { - - private static final long serialVersionUID = -5217518860967878598L; - - public UndefinedTypeException() { - super(); - } - - public UndefinedTypeException(String msg) { - super(msg); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/GlobalVariables.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/GlobalVariables.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/GlobalVariables.java deleted file mode 100644 index 12e2038..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/GlobalVariables.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -//JDK imports -import java.util.concurrent.ConcurrentHashMap; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class GlobalVariables { - - public static final ConcurrentHashMap<String, Variable> ConcurrentHashMap = new ConcurrentHashMap<String, Variable>(); - - private GlobalVariables() { - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/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 deleted file mode 100644 index d61d21b..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Method.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -import org.apache.oodt.cas.pushpull.exceptions.MethodException; - -import java.util.LinkedList; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class Method { - - private static Logger LOG = Logger.getLogger(Method.class.getName()); - private String name; - - private String infix; - - private LinkedList<Variable> args; - - private LinkedList<String> argNames; - - private LinkedList<Integer> argTypes; - - public final int INT = 0; - - public final int STRING = 1; - - public Method(String name) { - this.name = name; - args = new LinkedList<Variable>(); - argNames = new LinkedList<String>(); - argTypes = new LinkedList<Integer>(); - } - - public void addArgSignature(String name, int type) { - argNames.add(name); - argTypes.add(type); - } - - public boolean addArg(String name, String value) { - int nextLoc = args.size(); - if (nextLoc >= 0) { - switch (argTypes.get(nextLoc)) { - case INT: - addArg(new Variable(null, Integer.valueOf(value))); - break; - case STRING: - addArg(new Variable(null, value)); - break; - default: - return false; - } - return true; - } else { - return false; - } - } - - public void addArg(Variable v) { - args.addLast(v); - } - - public void setBehavoir(String infix) { - this.infix = infix; - } - - private LinkedList<ValidInput> convert(String infix) throws MethodException { - try { - LinkedList<ValidInput> output = new LinkedList<ValidInput>(); - Stack<ValidInput> stack = new Stack<ValidInput>(); - char[] infixArray = infix.toCharArray(); - for (int i = 0; i < infixArray.length; i++) { - char c = infixArray[i]; - // System.out.println("Next C = " + c); - switch (c) { - case '$': - StringBuilder variable = new StringBuilder(""); - boolean globalVar = false; - - // skip $ by incr i and if true then variable is a global - // variable and skip '{' by incr i again - if (infixArray[++i] == '{') { - globalVar = true; - i++; - } - - for (; i < infixArray.length; i++) { - char ch = infixArray[i]; - // System.out.println("ch = " + ch); - if ((ch <= 'Z' && ch >= 'A') - || (ch <= 'z' && ch >= 'a') - || (ch <= '9' && ch >= '0') || ch == '_') { - variable.append(ch); - } else { - break; - } - } - - if (globalVar) { - try { - output.addLast(GlobalVariables.ConcurrentHashMap.get(variable - .toString())); - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - } - } else { - i--; - output.addLast(args.get(argNames.indexOf(variable - .toString()))); - } - break; - case '#': - StringBuilder variableIntString = new StringBuilder(""); - int k = i + 1; - for (; k < infixArray.length; k++) { - char ch = infixArray[k]; - if (ch <= '9' && ch >= '0') { - variableIntString.append(ch); - } else { - break; - } - } - output.addLast(new Variable(null, Integer.valueOf( - variableIntString.toString()))); - i = k - 1; - break; - case '"': - StringBuilder variableString = new StringBuilder(""); - int l = i + 1; - for (; l < infixArray.length; l++) { - char ch = infixArray[l]; - if (ch == '"') { - break; - } else { - variableString.append(ch); - } - } - output - .addLast(new Variable(null, variableString - .toString())); - i = l; - break; - case '+': - case '-': - case '/': - case '*': - while (!stack.empty() - && hasHigherPrecedence(stack.peek().toString() - .charAt(0), c)) { - output.addLast(stack.pop()); - } - stack.push(new Operator(c + "")); - break; - case ')': - while (!stack.empty()) { - ValidInput vi = stack.pop(); - if (vi.toString().charAt(0) == '(') { - break; - } - output.addLast(vi); - } - break; - case '(': - stack.push(new Punctuation(c + "")); - break; - - } - } - while (!stack.empty()) { - output.addLast(stack.pop()); - } - - return output; - } catch (Exception e) { - throw new MethodException("Failed to convert infix to postfix : " - + e.getMessage()); - } - } - - public Object execute() throws MethodException { - try { - Stack<ValidInput> stack = new Stack<ValidInput>(); - LinkedList<ValidInput> postfix = convert(infix); - for (ValidInput vi : postfix) { - if (vi instanceof Variable) { - stack.push(vi); - } else if (vi instanceof Operator) { - ValidInput first = stack.pop(); - ValidInput second = stack.pop(); - switch (vi.toString().charAt(0)) { - case '+': - if (((Variable) first).isString() - || ((Variable) second).isString()) { - String value = second.toString() + first.toString(); - stack.push(new Variable(null, value)); - } else if (((Variable) first).isInteger() - && ((Variable) second).isInteger()) { - Integer value = (Integer) second - .getValue() - + (Integer) first.getValue(); - stack.push(new Variable(null, value)); - } else { - throw new MethodException( - "Invalid Concatination/Addition types. . .must be String or Integer"); - } - break; - case '-': - if (((Variable) first).isInteger() - && ((Variable) second).isInteger()) { - Integer value = (Integer) second - .getValue() - - (Integer) first.getValue(); - stack.push(new Variable(null, value)); - } else { - throw new MethodException( - "Invalid Subtraction types. . .must be Integer"); - } - break; - case '*': - if (((Variable) first).isInteger() - && ((Variable) second).isInteger()) { - Integer value = (Integer) second - .getValue() - * (Integer) first.getValue(); - stack.push(new Variable(null, value)); - } else { - throw new MethodException( - "Invalid Multiplication types. . .must be Integer"); - } - break; - case '/': - if (((Variable) first).isInteger() - && ((Variable) second).isInteger() - && (Integer) first.getValue() > 0) { - Integer value = (Integer) second - .getValue() - / (Integer) first.getValue(); - stack.push(new Variable(null, value)); - } else { - throw new MethodException( - "Invalid Division types. . .must be Integer and denominator must be greater than 0"); - } - break; - } - } - } - return stack.pop().getValue(); - } catch (Exception e) { - throw new MethodException("Failed to execute method " + name - + " : " + e.getMessage()); - } - } - - // does first have higher precedence than second - private boolean hasHigherPrecedence(char first, char second) { - switch (first) { - case '+': - case '-': - switch (second) { - case '+': - case '-': - return true; - } - return false; - case '*': - case '/': - return true; - } - return false; - } - - public String getName() { - return name; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Operator.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Operator.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Operator.java deleted file mode 100644 index d6f16a9..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Operator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class Operator implements ValidInput { - - private String value; - - public Operator(String value) { - this.value = value; - } - - public Object getValue() { - return value; - } - - public String toString() { - return value; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Punctuation.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Punctuation.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Punctuation.java deleted file mode 100644 index fb108ad..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Punctuation.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class Punctuation implements ValidInput { - - private String value; - - public Punctuation(String value) { - this.value = value; - } - - public Object getValue() { - return value; - } - - public String toString() { - return value; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/ValidInput.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/ValidInput.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/ValidInput.java deleted file mode 100644 index 729722b..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/ValidInput.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public interface ValidInput { - - Object getValue(); - - String toString(); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Variable.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Variable.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Variable.java deleted file mode 100644 index 7dde7ae..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/expressions/Variable.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.expressions; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class Variable implements ValidInput { - - private String name; - - private Object value; - - private int fillSide; - - private String fillString; - - private int precision; - - private int type; - - public final int FILL_FRONT = 0; - - public final int FILL_BACK = 1; - - public final int TYPE_STRING = 2; - - public final int TYPE_INTEGER = 3; - - public Variable(String name) { - this(name, null); - } - - public Variable(String name, Object value) { - this.name = name; - this.value = value; - fillSide = FILL_FRONT; - fillString = " "; - precision = -1; - } - - public boolean isString() { - return value instanceof String; - } - - public boolean isInteger() { - return value instanceof Integer; - } - - public void setValue(Object value) { - this.value = value; - if (value instanceof String) { - type = TYPE_STRING; - } else if (value instanceof Integer) { - type = TYPE_INTEGER; - } - } - - public void setPrecision(int precision) { - this.precision = precision; - } - - public void setFillString(String fillString) { - this.fillString = fillString; - } - - public void setFillSide(int fillSide) { - this.fillSide = fillSide; - } - - public Object getValue() { - return value; - } - - public int getPrecision() { - return precision; - } - - public String getFillString() { - return fillString; - } - - public int getFillSide() { - return fillSide; - } - - public String getName() { - return name; - } - - public String toString() { - String strValue = value.toString(); - if (strValue.length() < this.precision) { - while (strValue.length() < this.precision) { - if (fillSide == FILL_FRONT) { - strValue = fillString + strValue; - } else { - strValue = strValue + fillString; - } - } - } - return strValue; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java deleted file mode 100644 index 38f5ecb..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/FileRestrictions.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.filerestrictions; - -//OODT imports -import org.apache.oodt.cas.pushpull.protocol.ProtocolPath; - -//JDK imports -import java.util.LinkedList; - - -/** - * This class allows the creation of restrictions for files and directories created below an actual directory which is passed - * into the constructor. These restriction are loaded by passing a FileInputStream which contains a XML File - * into the method and can be tested against by using the method. - * - * <pre> - * The XML file schema is: - * {@literal <root> - * <variables> - * <variable name="variable-name"> - * <type>INT-or-STRING</type> - * <value>variable-value</value> - * <precision> - * <locations>number-of-fill-locations</locations> - * <fill>fill-value</fill> - * <side>front-or-back</side> - * </precision> - * </variable> - * ... - * ... - * </variables> - * - * <methods> - * <method name="method-name"> - * <args> - * <arg name="argument-name"> - * <type>INT-or-STRING</type> - * </arg> - * ... - * ... - * </args> - * <action>method-behavior</action> - * </method> - * ... - * ... - * </methods> - * - * <dirstruct name="root-directory-name"> - * <nodirs/> - * <nofiles/> - * <file name="file-name"/> - * <dir name="directory-name"> - * <nodirs/> - * <nofiles/> - * <file name="file-name"/> - * <dir name="directory-name"> - * ... - * ... - * </dir> - * </dir> - * ... - * ... - * </dirstruct> - * </root>} - * </pre> - * - * <i>{@literal <variables>}</i> and <i>{@literal <methods>}</i> can be created in this XML file so that they can be used in the <i>{@literal <dirstruct>}</i> - * portion of the XML file. These <i>{@literal <variables>}</i> and <i>{@literal <methods>}</i> can be used inside the <i>{@literal <dir>}</i> and - * <i>{@literal <file>}</i> elements within the <i>{@literal <dirstruct>}</i> element to allow for varrying directory and file names beyond the capability - * of regular expressions (which are also allowed). - * - * <h2>VARIABLES (OPTIONAL):</h2> - * Let's start with describing the <i>{@literal <variables>}</i> portion of the XML file. As many <i>{@literal <variable>}</i> elements as you would like - * can be specified inside the <i>{@literal <variables>}</i> tag. The <i>{@literal <variable>}</i> element must have a parameter, 'name', which is the name - * of this <i>{@literal <variable>}</i>. Every <i>{@literal <variable>}</i> is a global variable (that is, global in the scope of the XML file it is declared - * in -- it is not usable in other XML file, unless redeclared) so variable names are unique (however, are case sensitive) so thus a name can only - * be applied to one <i>{@literal <variable>}</i>. Within the <i>{@literal <variable>}</i> element there are three possible sub-elements that can be included. - * <i>{@literal <type>}</i> and <i>{@literal <value>}</i> are required and <i>{@literal <precision>}</i> is optional. <i>{@literal <type>}</i> can be either (and it must be - * in all UPPERCASE) INT or STRING (sorry, floating point numbers are not supported as of yet). This specifies what type of value will be given in - * <i>{@literal <value>}</i>. This allows you to both use numerical values as either an integer or a string. <i>{@literal <precision>}</i> can also be specified - * for each <i>{@literal <variable>}</i>. This allows you to insure that an integer or string will take up a certain amount of space. This is especially - * useful when dealing with dates. For instance, say you had the following in your XML file: - * - * <pre> - * {@literal <variable name="myVariable"> - * <type>INT</type> - * <value>3</value> - * </variable>} - * </pre> - * - * When myVariable was finally returned it would look like 3, however many times for dates you would like 03 returned. You can specify this by adding - * precision to the following XML: - * - * <pre> - * {@literal <variable name="myVariable"> - * <type>INT</type> - * <value>3</value> - * <precision> - * <locations>2</locations> - * <fill>0</fill> - * <side>front</side> - * </precision> - * </variable>} - * </pre> - * - * This insures that the number is always printed with 2 digits and if the number does not take up 2 digits worth of space a fill value 0 will be added - * to the front side of the integer, thus, in this example would give us 03. Note: <i>{@literal <value>03</value>}</i> would NOT accomplish the same!!!! - * - * <h2>METHODS (OPTIONAL):</h2> - * Next let's look at the <i>{@literal <methods>}</i> portion of the XML file. <i>{@literal <method>}</i> elements must have a 'name' parameter, which is the name of the - * <i>{@literal <method>}</i>. Every <i>{@literal <method>}</i> is also global in the same way as is every <i>{@literal <variable>}</i> and are also case-sensitive, thus method - * names must be unique. A <i>{@literal <method>}</i> element may contain an <i>{@literal <args>}</i> sub-element, however this is optional and only needed if the method - * is to take any arguments. If an <i>{@literal <args>}</i> element is given, then it should contain at least one <i>{@literal <arg>}</i> element. A <i>{@literal <method>}</i> - * may contain as many <i>{@literal <arg>}</i> elements as it needs. What is being specified by a <i>{@literal <method>}</i> element is what would be known in java code - * as the method signature. Thus all we are going to specify is each argument's name and type. Thus each <i>{@literal <arg>}</i> element must contain - * a 'name' parameter, which is the name of the argument and must contain a <i>{@literal <type>}</i> sub-element, so it is known how to treat the arguments when - * the method is used within the <i>{@literal <dirstruct>}</i> section of the XML file. Another sub-element, which is required, for the <i>{@literal <method>}</i> - * element is the <i>{@literal <action>}</i> element. This element contains the behavior of the <i>{@literal <method>}</i>. Before going into detail about what can be - * placed within the <i>{@literal <action>}</i> element let's first cover some syntax requirements for the XML file. - * - * <h2>SYNTAX REQUIREMENTS:</h2> - * When a <i>{@literal <variable>}</i> is used it must be preceded by $ and inclosed in {} (e.g. ${myVariable}).<br> - * When a <i>{@literal <method>}</i> is used it must be preceded by % and end with () (e.g. %myMethod(), however if arguments are given then %myMethod(12,9)).<br> - * When a <i>{@literal <method>}</i> argument (<i>{@literal <arg>}</i> element) is used is must be preceded by $ (e.g. $myArg).<br> - * When a literal integer is used it must be preceded by # (e.g. #234).<br> - * When a literal string is used it must be inclosed in " (e.g. "my age is 56 -- no not really").<br> - * - * <p>NOTE: When passing arguments into methods the string and integer literal rules do not need to be followed because you have already defined what each - * argument type should be and they will be evaluated as such.</p> - * <p>NOTE*: Also note that at present a <i>{@literal <variable>}</i> cannot be passed as an argument to the methods. Just use the <i>{@literal <variable>}</i> where needed - * inside the <i>{@literal <action>}</i> element. This feature should hopefully be added in a later release.</p> - * - * <h2>METHOD'S ACTION ELEMENT USAGE:</h2> - * The <i>{@literal <action>}</i> element will evaluate expressions that contain both integers and strings. It obeys the rules of mathematical precedence and will - * also handle parentheses. It also, like Java, still follows the order of precedence when strings are present. That is, if you have the expression:<br> - *    <i>#2+#4+" years old, going on "+#2+#4</i><br> - * It would evaluate to:<br> - *    <i>6 years old, going on 24</i><br> - * You may use any <i>{@literal <variable>}</i> declared within the same XML file and may also use any argument (<i>{@literal <arg>}</i> element) declared within that - * <i>{@literal <method>}</i>. Also string and integer literals may be used. Currently the only operators supported are +,-,*,/ (which are respectively: - * addition, subtraction, multiplication, and division). Parentheses, (), and embedded parentheses, (()()), are also all allowed. - * - * <h2>DIRSTRUCT:</h2> - * The final section of the XML file is the actual main purpose of the XML file. This is the XML that controls which directories the crawler will be allowed - * to crawl and which files will be allowed. The <i>{@literal <dirstruct>}</i> element requires a 'name' parameter which is the path to the root - * directory that is to be considered (that is, all other directories below the given directory are unimportant and will not be crawled). You want your root - * directory path to stop at the first directory in which you are interested in more than one of its sub-directories or want file(s) inside it. - * For example, let say we want to crawl a remote site that has the following directory structure: - * - * <pre> - * -parent - * -child1 - * -grandChild1 - * -greatGrandChild1 - * -file1 - * -greatGrandChild2 - * -grandChild2 - * -file1 - * -child2 - * -file1 - * -child3 - * -file1 - * -file2 - * -grandChild1 - * -file1 - * -file2 - * -child4 - * </pre> - * - * Now, say, we only are interested in directories and files below the two shown 'grandChild1' directories. This would mean that for our <i>{@literal <dirstruct>}</i> - * 'name' parameter we would put name="parent". This is because we need access to both 'child1' and 'child3' subdirectories. Now in order to avoid crawling - * 'child2' and 'child4' directories we have to specify <i>{@literal <dir>}</i> elements. This would give us the following XML: - * - * <pre> - * {@literal <dirstruct name="/parent"> - * <dir name="child1"/> - * <dir name="child3"/> - * </dirstruct>} - * </pre> - * - * This would restrict the directories allowed under 'parent' to only be directories with names either 'child1' or 'child3', all other directory names will - * be rejected. However, more must be added to this example because we have not yet specified any restrictions on files allowed beneath 'parent', - * we have to add the <i>{@literal <nofiles/>}</i> element: - * - * <pre> - * {@literal <dirstruct name="/parent">} - * <i><b>{@literal <nofiles/>}</b></i> - * {@literal <dir name="child1"/> - * <dir name="child3"/> - * </dirstruct>} - * </pre> - * - * Now the only thing acceptable below parent is 'child1' and 'child3'. We have to still further our restrictions under 'child1' and 'child3'. Since under - * 'child1' we only want 'grandChild1' we would have to make another <i>{@literal <dir>}</i> element and also add a <i>{@literal <nofiles/>}</i> element: - * - * <pre> - * {@literal <dirstruct name="/parent"> - * <nofiles/> - * <dir name="child1">} - * <i><b>{@literal <nofiles/> - * <dir name="grandChild1"/>}</b></i> - * {@literal </dir> - * <dir name="child3"/> - * </dirstruct>} - * </pre> - * - * We have to do the same also for 'child3', giving us: - * - * <pre> - * {@literal <dirstruct name="/parent"> - * <nofiles/> - * <dir name="child1"> - * <nofiles/> - * <dir name="grandChild1"/> - * </dir> - * <dir name="child3">} - * <i><b>{@literal <nofiles/> - * <dir name="grandChild1"/>}</b></i> - * {@literal </dir> - * </dirstruct>} - * </pre> - * - * From the example directory structure above, with this XML file specified, that directory structure would be limited to: - * - * <pre> - * -parent - * -child1 - * -grandChild1 - * -greatGrandChild1 - * -file1 - * -greatGrandChild2 - * -child3 - * -grandChild1 - * -file1 - * -file2 - * </pre> - * - * Say we now decide that we only want files below the two 'grandChild1' directories -- that is, no directories. So we would change or XML by adding - * in the <i>{@literal <nodir/>}</i> element: - * - * <pre> - * {@literal <dirstruct name="/parent"> - * <nofiles/> - * <dir name="child1"> - * <nofiles/> - * <dir name="grandChild1">} - * <i><b>{@literal <nodirs/>}</b></i> - * {@literal </dir> - * </dir> - * <dir name="child3"> - * <nofiles/> - * <dir name="grandChild1">} - * <i><b>{@literal <nodirs/>}</b></i> - * {@literal </dir> - * </dir> - * </dirstruct>} - * </pre> - * - * Which now restricts our directory structure to: - * - * <pre> - * -parent - * -child1 - * -grandChild1 - * -child3 - * -grandChild1 - * -file1 - * -file2 - * </pre> - * - * Let's further specify now that we only want 'file1' in the '/parent/child3/grandChild1' directory. This would change the XML to: - * - * <pre> - * {@literal <dirstruct name="/parent"> - * <nofiles/> - * <dir name="child1"> - * <nofiles/> - * <dir name="grandChild1"> - * <nodirs/> - * </dir> - * </dir> - * <dir name="child3"> - * <nofiles/> - * <dir name="grandChild1"> - * <nodirs/>} - * <i><b>{@literal <file name="file1"/>}</b></i> - * {@literal </dir> - * </dir> - * </dirstruct>} - * </pre> - * - * Our new allowed directory structure would now be: - * - * <pre> - * -parent - * -child1 - * -grandChild1 - * -child3 - * -grandChild1 - * -file1 - * </pre> - * - * NOTES: - * -You would not want to use the <i>{@literal <nofiles/>}</i> and <i>{@literal <file>}</i> elements in the same directory (same goes for the - * <i>{@literal <nodirs/>}</i> and <i>{@literal <dir>}</i> elements) because you would be specifying that you don't want any files in that - * directory, and then contradict yourself by specifying a <i>{@literal <file>}</i> element that is okay to have. The <i>{@literal <file>}</i> - * element states that no other file but the file I specified is allowed. The only exception is if you have two or more <i>{@literal <file>}</i> - * elements in the same directory -- this is allowed. It follows the same rules as the <i>{@literal <dir>}</i> element in the example - * given above where only 'child1' and 'child3' were allow. The two don't cancel each other out. - * - * <h2>ADVANCED USAGES OF DIRSTRUCT:</h2> - * Regular expressions are allowed in the 'name' parameter of both <i>{@literal <dir>}</i> and <i>{@literal <file>}</i> elements. Also any - * <i>{@literal <method>}</i> or <i>{@literal <variable>}</i> element declared can be used within the 'name' parameter of both <i>{@literal <dir>}</i> - * and <i>{@literal <file>}</i> elements. There are also several predefined variables that can be used. - * - * <h4>REGULAR EXPRESSIONS:</h4> - * The regular expressions are parsed by the <a href=http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html>Pattern</a> class - * (See its documentation on rule for specifying regular expressions). Here is an example use of a regular expression: - * - * <pre> - * {@literal <dirstruct name="/.../temp/test"> - * <nofiles/> - * <dir name="\d{4}-\d{2}-\d{2}"> - * <nodirs/> - * </dir> - * </dirstruct>} - * </pre> - * - * This would restrict the directory files in directories below /.../temp/test to only directories whose names are dates of the - * format: YYYY-MM-DD. - * - * <h4>PREDEFINED DATE VARIABLES:</h4> - * There are several predefined date variables than can be put as the <i>{@literal <value>}</i> of a <i>{@literal <variable>}</i> and then used. - * - * These variables are: - * <pre> - * [DATE.DAY] - day of today's date - * [DATE.MONTH] - month of today's date - * [DATE.YEAR] - year of today's date - * [DATE-N.DAY] - the day of the date N days ago - * [DATE-N.MONTH] - the month of the date N days ago - * [DATE-N.YEAR] - the year of the date N days ago - * [DATE+N.DAY] - the day of the date N days from now - * [DATE+N.MONTH] - the month of the date N days from now - * [DATE+N.YEAR] - the year of the date N days from now - * - * -sorry, no DayOfYear implemented yet -- hopefully in a later release - * </pre> - * - * Usage: - * <pre> - * {@literal <root> - * <variables> - * <variable name="todaysDay"> - * <type>INT</type> - * <value>[DATE.DAY]</value> - * <precision> - * <locations>2</locations> - * <fill>0</fill> - * <side>front</side> - * </precision> - * </variable> - * </variabls> - * <dirstruct name="/path/to/parent/dir"> - * <nofiles/> - * <dir name="MyFiles"> - * <nodirs/> - * <file name="MyPaper_${todaysDay}"/> - * </dir> - * </dirstruct> - * </root>} - * </pre> - * - * This would allow only a file in /path/to/parent/dir/MyFiles which had the name which started with MyPaper_ and ended with the - * day of the current day of the month. For example, if to days date was 03/23/2005, then the file name allowed would be - * MyPaper_23. - * - * <h4>METHOD AND VARIABLE USAGE IN DIRSTRUCT:</h4> - * Here is an example of using <i>{@literal <variables>}</i> and <i>{@literal <methods>}</i>: - * - * <pre> - * {@literal <root> - * <variables> - * <variable name="DAY"> - * <type>INT</type> - * <value>[DATE.DAY]</value> - * <precision> - * <locations>2</locations> - * <fill>0</fill> - * <side>front</side> - * </precision> - * </variable> - * <variable name="MONTH"> - * <type>INT</type> - * <value>[DATE.MONTH]</value> - * <precision> - * <locations>2</locations> - * <fill>0</fill> - * <side>front</side> - * </precision> - * </variable> - * <variable name="YEAR"> - * <type>INT</type> - * <value>[DATE.YEAR]</value> - * </variable> - * </variables> - * - * <methods> - * <method name="ADD"> - * <args> - * <arg name="1"> - * <type>INT</type> - * </arg> - * </args> - * <action>"THE_YEAR_PLUS_"+$1+": "+(${YEAR}+$1)</action> - * </method> - * <method name="HOW_OLD_AM_I"> - * <action>${YEAR}-#1984</action> - * </method> - * <method name="DATE"> - * <action>${YEAR}+"-"+${MONTH}+"-"+${DAY}</action> - * </method> - * </methods> - * - * <dirstruct name="/path/to/parent/dir"> - * <nofiles/> - * <dir name="AGE_%HOW_OLD_AM_I()"/> - * <dir name="DATE"> - * <nodirs/> - * <file name="%ADD(5)"/> - * </dir> - * </dirstruct> - * </root>} - * </pre> - * - * This would accept only the directories under /path/to/parent/dir which had the name (given today is 9/7/2007) 'AGE_23' or '2007-09-07'. - * This would allow any file or directory in under 'AGE_23', but would only allow a file with the name 'THE_YEAR_PLUS_5: 2012' in the - * directory '2007-09-07'. - * - * - * @author bfoster - * - */ -public class FileRestrictions { - - private FileRestrictions() throws InstantiationException{ - throw new InstantiationException("Don't construct FileRestrictions!"); - } - - /** - * - * @param path - * @return The initial cd directory which needs to be changed to (in order - * to take care of possible auto-mounted directories) - */ - public static boolean isAllowed(ProtocolPath path, VirtualFile root) { - return (isValidPath(path) && isAllowed(new VirtualFile(path - .getPathString(), path.isDirectory()), root)); - } - - public static boolean isAllowed(VirtualFile file, VirtualFile root) { - boolean vfDoesNotExist = false, lastFileIsDir = file.isDir(); - VirtualFile vf; - while ((vf = root.getChildRecursive(file)) == null) { - vfDoesNotExist = true; - lastFileIsDir = file.isDir(); - file = file.getParentFile(); - if (file == null) { - break; - } - } - return !(file == null || (vfDoesNotExist && ((lastFileIsDir && !vf - .allowNewDirs()) || (!lastFileIsDir && !vf.allowNewFiles())))); - } - - private static boolean isValidPath(ProtocolPath path) { - return path != null && !path.getFileName().equals(".") - && !path.getFileName().equals(".."); - } - - public static LinkedList<String> toStringList(VirtualFile root) { - LinkedList<String> stringList = new LinkedList<String>(); - stringList.addAll(toStringList(root.getChildren(), "")); - return stringList; - } - - private static LinkedList<String> toStringList( - LinkedList<VirtualFile> children, String curPath) { - LinkedList<String> stringList = new LinkedList<String>(); - for (VirtualFile child : children) { - String currentPath = curPath + "/" + child.getRegExp(); - if (!child.isDir()) { - stringList.add(currentPath); - } else { - stringList - .addAll(toStringList(child.getChildren(), currentPath)); - } - } - return stringList; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/Parser.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/Parser.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/Parser.java deleted file mode 100644 index 2d49fe4..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/Parser.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.filerestrictions; - -//JDK imports -import java.io.FileInputStream; - - -import org.apache.oodt.cas.metadata.Metadata; -//OODT imports -import org.apache.oodt.cas.pushpull.exceptions.ParserException; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public interface Parser { - - VirtualFileStructure parse(FileInputStream inputFile, Metadata metadata) - throws ParserException; - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java deleted file mode 100644 index ae16686..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFile.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.filerestrictions; - -import java.util.LinkedList; -import java.util.StringTokenizer; -import java.util.regex.Pattern; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p> - * Describe your class here - * </p>. - */ -public class VirtualFile { - - private String regExp; - - private LinkedList<VirtualFile> children; - - private VirtualFile parent; - - private boolean noDirs; - - private boolean noFiles; - - private boolean isDir; - - private boolean allowNewFiles; - - private boolean allowNewDirs; - - private VirtualFile(boolean isDir) { - this.isDir = isDir; - children = new LinkedList<VirtualFile>(); - noDirs = noFiles = !isDir; - allowNewFiles = allowNewDirs = isDir; - } - - public VirtualFile(String path, boolean isDir) { - this(isDir); - - if (path != null) { - StringTokenizer st = new StringTokenizer(path, "/"); - - if (st.countTokens() > 1) { - VirtualFile vf = path.startsWith("/") ? VirtualFile - .createRootDir() - : new VirtualFile(st.nextToken(), true); - String curRegExp = st.nextToken(); - - while (st.hasMoreTokens()) { - VirtualFile temp = new VirtualFile(curRegExp, true); - vf.addChild(temp); - vf = temp; - curRegExp = st.nextToken(); - } - this.regExp = curRegExp; - vf.addChild(this); - } else if (st.countTokens() > 0) { - this.regExp = st.nextToken(); - if (path.startsWith("/")) { - VirtualFile.createRootDir().addChild(this); - } - } else { - this.copy(VirtualFile.createRootDir()); - } - } else { - this.copy(VirtualFile.createRootDir()); - } - } - - public VirtualFile(VirtualFile root, String path, boolean isDir) { - this(isDir); - - if (path != null) { - StringTokenizer st = new StringTokenizer(path, "/"); - - if (st.countTokens() > 0) { - VirtualFile vf = root; - String curRegExp = st.nextToken(); - - while (st.hasMoreTokens()) { - VirtualFile temp = new VirtualFile(curRegExp, true); - vf.addChild(temp); - vf = temp; - curRegExp = st.nextToken(); - } - this.regExp = curRegExp; - vf.addChild(this); - } else { - this.copy(root); - } - } else { - this.copy(root); - } - } - - public static VirtualFile createRootDir() { - VirtualFile root = new VirtualFile(true); - root.regExp = "/"; - return root; - } - - public VirtualFile getRootDir() { - VirtualFile vf = this; - while (vf.getParentFile() != null) { - vf = vf.getParentFile(); - } - return vf; - } - - public static VirtualFile mergeTwoFiles(VirtualFile vf1, VirtualFile vf2) { - if (vf1.isDir) { - VirtualFile newFile = VirtualFile.createRootDir(); - newFile.children.addAll(vf1.children); - newFile.children.addAll(vf2.children); - return newFile; - } else { - return null; - } - } - - public void addChild(VirtualFile vf) { - if (this.isDir) { - VirtualFile existingChildWithSameName = this.getChild(vf.regExp, - vf.isDir); - if (existingChildWithSameName == null) { - children.add(vf); - if (vf.isDir()) { - allowNewDirs = false; - } else { - allowNewFiles = false; - } - vf.parent = this; - } else { - vf.copy(existingChildWithSameName); - } - } - } - - public LinkedList<VirtualFile> getChildren() { - return children; - } - - public VirtualFile getChild(String regExp, boolean isDirectory) { - for (VirtualFile vf : children) { - if ((regExp.equals(vf.regExp) || Pattern.matches(vf.regExp, regExp)) - && vf.isDir == isDirectory) { - return vf; - } - } - return null; - } - - public VirtualFile getChildRecursive(VirtualFile vf) { - return this.getChildRecursive(vf.getAbsolutePath(), vf.isDir); - } - - public VirtualFile getChildRecursive(String path, boolean isDirectory) { - StringTokenizer st = new StringTokenizer(path, "/"); - VirtualFile vf = this; - while (st.hasMoreTokens()) { - String curRegExp = st.nextToken(); - if (st.hasMoreTokens()) { - if ((vf = vf.getChild(curRegExp, true)) == null) { - return null; - } - } else { - return vf.getChild(curRegExp, isDirectory); - } - } - return null; - } - - public boolean hasChild(VirtualFile vf) { - return children.contains(vf); - } - - public String getAbsolutePath() { - if (regExp == null) { - return null; - } - StringBuilder path = new StringBuilder(this.regExp); - VirtualFile parent = this.parent; - while (parent != null) { - path.insert(0, (!parent.regExp.equals("/") ? parent.regExp : "") + "/"); - parent = parent.parent; - } - return path.toString(); - } - - public VirtualFile getParentFile() { - return parent; - } - - public String getRegExp() { - return regExp; - } - - public void setNoDirs(boolean noDirs) { - if (this.isDir) { - if (noDirs) { - allowNewDirs = false; - } - this.noDirs = noDirs; - } - } - - public void setNoFiles(boolean noFiles) { - if (this.isDir) { - if (noFiles) { - allowNewFiles = false; - } - this.noFiles = noFiles; - } - } - - public boolean allowNewDirs() { - return allowNewDirs; - } - - public boolean allowNewFiles() { - return allowNewFiles; - } - - public boolean allowNoDirs() { - return noDirs; - } - - public boolean allowNoFiles() { - return noFiles; - } - - public boolean isDir() { - return isDir; - } - - public void copy(VirtualFile vf) { - this.allowNewDirs = vf.allowNewDirs; - this.allowNewFiles = vf.allowNewFiles; - this.children = vf.children; - this.isDir = vf.isDir; - this.noDirs = vf.noDirs; - this.noFiles = vf.noFiles; - this.parent = vf.parent; - this.regExp = vf.regExp; - } - - // TODO: make it compare against all variables - public boolean equals(Object obj) { - if (obj instanceof VirtualFile) { - VirtualFile compareFile = (VirtualFile) obj; - if (compareFile.getRegExp().equals(regExp) - && compareFile.isDir() == this.isDir) { - return true; - } - } - return false; - } - - public String toString() { - StringBuilder sb = new StringBuilder( - "-<VirtualFile>\t : allowNewDirs/noDirs\t : allowNewFiles/noFiles\n------------\n"); - LinkedList<VirtualFile> printFiles = new LinkedList<VirtualFile>(); - printFiles.add(this); - sb.append(printVirtualFiles(printFiles, "-")); - return sb.toString(); - } - - private StringBuffer printVirtualFiles(LinkedList<VirtualFile> list, - String spacer) { - StringBuffer output = new StringBuffer(""); - for (VirtualFile vf : list) { - output.append(spacer); - output.append(vf.getRegExp()).append(vf.isDir && !vf.regExp.equals("/") ? "/" : "").append("\t : ") - .append(vf.allowNewDirs).append("/").append(vf.noDirs).append("\t\t : ").append(vf.allowNewFiles) - .append("/").append(vf.noFiles).append("\n"); - output.append(printVirtualFiles(vf.getChildren(), " " + spacer)); - } - return output; - } - - @Override - public int hashCode() { - int result = regExp != null ? regExp.hashCode() : 0; - result = 31 * result + (children != null ? children.hashCode() : 0); - result = 31 * result + (parent != null ? parent.hashCode() : 0); - result = 31 * result + (noDirs ? 1 : 0); - result = 31 * result + (noFiles ? 1 : 0); - result = 31 * result + (isDir ? 1 : 0); - result = 31 * result + (allowNewFiles ? 1 : 0); - result = 31 * result + (allowNewDirs ? 1 : 0); - return result; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFileStructure.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFileStructure.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFileStructure.java deleted file mode 100644 index cca4983..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/VirtualFileStructure.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.filerestrictions; - -//OODT imports -import org.apache.oodt.cas.pushpull.protocol.RemoteSite; - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p>Describe your class here</p>. - */ -public class VirtualFileStructure { - - private String pathToRoot; - - private VirtualFile root; - - private RemoteSite remoteSite; - - public VirtualFileStructure(String pathToRoot, VirtualFile root) { - this.pathToRoot = pathToRoot; - this.root = root; - } - - public VirtualFileStructure(RemoteSite remoteSite, String pathToRoot, - VirtualFile root) { - this(pathToRoot, root); - this.remoteSite = remoteSite; - } - - public String getPathToRoot() { - return this.pathToRoot; - } - - public VirtualFile getRootVirtualFile() { - return this.root; - } - - public RemoteSite getRemoteSite() { - return this.remoteSite; - } - - public boolean isRootBased() { - return this.pathToRoot.startsWith("/"); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java deleted file mode 100644 index b3dd672..0000000 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/ClassNoaaEmailParser.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.cas.pushpull.filerestrictions.parsers; - -//OODT imports - -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.pushpull.exceptions.ParserException; -import org.apache.oodt.cas.pushpull.filerestrictions.Parser; -import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFile; -import org.apache.oodt.cas.pushpull.filerestrictions.VirtualFileStructure; -import org.apache.oodt.cas.pushpull.protocol.RemoteSite; - -import java.io.FileInputStream; -import java.net.URL; -import java.util.Scanner; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -//JDK imports - -/** - * - * @author bfoster - * @version $Revision$ - * - * <p>Describe your class here</p>. - */ -public class ClassNoaaEmailParser implements Parser { - private static Logger LOG = Logger.getLogger(ClassNoaaEmailParser.class.getName()); - public ClassNoaaEmailParser() {} - - public VirtualFileStructure parse(FileInputStream emailFile, Metadata metadata) - throws ParserException { - try { - VirtualFile root = VirtualFile.createRootDir(); - Scanner s = new Scanner(emailFile); - StringBuffer sb = new StringBuffer(""); - while (s.hasNextLine()) { - sb.append(s.nextLine()).append("\n"); - } - - if (!validEmail(sb.toString())) { - throw new ParserException( - "Email not a IASI data processed notification email"); - } - - Pattern cdPattern = Pattern.compile("\\s*cd\\s{1,}.{1,}?(?:\\s|$)"); - Matcher cdMatcher = cdPattern.matcher(sb); - Pattern getPattern = Pattern.compile("\\s*get\\s{1,}.{1,}?(?:\\s|$)"); - Matcher getMatcher = getPattern.matcher(sb); - - VirtualFile vf; - while (cdMatcher.find() && getMatcher.find()) { - String cdCommand = sb.substring(cdMatcher.start(), cdMatcher.end()); - String directory = cdCommand.trim().split(" ")[1]; - - vf = new VirtualFile(root, directory, true); - vf.setNoDirs(true); - - String getCommand = sb.substring(getMatcher.start(), getMatcher.end()); - String file = getCommand.trim().split(" ")[1]; - - if (file.endsWith("*")) { - vf.addChild(new VirtualFile(file.substring(0, - file.length() - 1), false)); - vf.addChild(new VirtualFile(file.substring(0, - file.length() - 1) - + ".sig", false)); - } else { - vf.addChild(new VirtualFile(file, false)); - } - } - - Pattern ftpPattern = Pattern.compile("\\sftp\\..*?\\s"); - Matcher ftpMatcher = ftpPattern.matcher(sb); - RemoteSite remoteSite = null; - if (ftpMatcher.find()) { - String ftpSite = sb.substring(ftpMatcher.start(), ftpMatcher.end()).trim(); - remoteSite = new RemoteSite(null, new URL("ftp://" - + ftpSite), "anonymous", System - .getenv("user.name") - + "@jpl.nasa.gov"); - } - - return new VirtualFileStructure(remoteSite, "/", root); - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new ParserException("Failed to parse IASI email : " - + e.getMessage()); - } - } - - private boolean validEmail(String email) { - String[] containsStrings = (System.getProperties() - .getProperty("org.apache.oodt.cas.pushpull.filerestrictions.parsers.class.noaa.email.parser.contains.exprs") - + ",").split(","); - for (String containsString : containsStrings) { - if (!email.contains(containsString)) { - return false; - } - } - return true; - } -}
