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 2012/08/26 20:42:37 UTC
svn commit: r1377477 - in /oodt/trunk: CHANGES.txt
workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java
workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
Author: mattmann
Date: Sun Aug 26 18:42:37 2012
New Revision: 1377477
URL: http://svn.apache.org/viewvc?rev=1377477&view=rev
Log:
- fix for OODT-468: WorkflowInstance tries to cast null strings into dates causing exceptions on getters/setters
Added:
oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1377477&r1=1377476&r2=1377477&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sun Aug 26 18:42:37 2012
@@ -3,6 +3,9 @@ Apache OODT Change Log
Release 0.5
--------------------------------------------
+* OODT-486: WorkflowInstance tries to cast null strings into dates causing
+ exceptions on getters/setters (mattmann)
+
* OODT-483: Fix to prevent NumberFormatException in XmlRpcStructFactory (rlaidlaw)
* OODT-471: Added namespace definitions to RSS config files for CAS REST API (rlaidlaw)
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java?rev=1377477&r1=1377476&r2=1377477&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java Sun Aug 26 18:42:37 2012
@@ -33,23 +33,24 @@ import org.apache.oodt.commons.util.Date
* status, and in general are data structures intended to be used as a means for
* monitoring the status of an executing {@link Workflow}.
*
- * As of Apache OODT 0.4, the internal {@link Workflow} implementation uses
- * {@link ParentChildWorkflow}, introduced as part of OODT-70, and the
- * PackagedWorkflowRepository. {@link Workflow} instances given to the class will
- * automatically convert to {@link ParentChildWorkflow} implementations internally,
- * and the existing {@link #getWorkflow()} and {@link #setWorkflow(Workflow)} methods
- * have been depcreated in favor of {@link #getParentChildWorkflow()} and
- * {@link #setParentChildWorkflow(ParentChildWorkflow)} which will supersede
+ * As of Apache OODT 0.4, the internal {@link Workflow} implementation uses
+ * {@link ParentChildWorkflow}, introduced as part of OODT-70, and the
+ * PackagedWorkflowRepository. {@link Workflow} instances given to the class
+ * will automatically convert to {@link ParentChildWorkflow} implementations
+ * internally, and the existing {@link #getWorkflow()} and
+ * {@link #setWorkflow(Workflow)} methods have been depcreated in favor of
+ * {@link #getParentChildWorkflow()} and
+ * {@link #setParentChildWorkflow(ParentChildWorkflow)} which will supersede
* those methods, and eventually turn into their concrete implementations.
*
- * In addition, as of Apache OODT 0.4 the internal {@link #state} member variable
- * now uses {@link WorkflowState} for representation. This requires the use of
- * {@link WorkflowLifecycle} which has now moved from being simply a UI utility
- * class for the Worklow Monitor web application to actually being fully integrated
- * with the Workflow Manager. For backwards compatibility the {@link #setStatus(String)}
- * and {@link #getStatus()} methods are still supported, but are deprecated. Developers
- * using this class should move towards using {@link #setState(WorkflowState)} and
- * {@link #getState()}.
+ * In addition, as of Apache OODT 0.4 the internal {@link #state} member
+ * variable now uses {@link WorkflowState} for representation. This requires the
+ * use of {@link WorkflowLifecycle} which has now moved from being simply a UI
+ * utility class for the Worklow Monitor web application to actually being fully
+ * integrated with the Workflow Manager. For backwards compatibility the
+ * {@link #setStatus(String)} and {@link #getStatus()} methods are still
+ * supported, but are deprecated. Developers using this class should move
+ * towards using {@link #setState(WorkflowState)} and {@link #getState()}.
*
* @author mattmann
* @author bfoster
@@ -78,7 +79,6 @@ public class WorkflowInstance {
private Priority priority;
-
/**
* Default Constructor.
*
@@ -92,7 +92,7 @@ public class WorkflowInstance {
String currentTaskId, Date startDate, Date endDate, Date taskStartDate,
Date taskEndDate, Metadata sharedContext, Priority priority) {
this.workflow = workflow != null && workflow instanceof ParentChildWorkflow ? (ParentChildWorkflow) workflow
- : new ParentChildWorkflow(workflow != null ? workflow:new Workflow());
+ : new ParentChildWorkflow(workflow != null ? workflow : new Workflow());
this.id = id;
this.state = state;
this.currentTaskId = currentTaskId;
@@ -124,17 +124,17 @@ public class WorkflowInstance {
*/
@Deprecated
public String getStatus() {
- return state != null ? state.getName():"Null";
+ return state != null ? state.getName() : "Null";
}
-
+
/**
- * Sets the current {@link WorkflowState}
- * to the provided status.
+ * Sets the current {@link WorkflowState} to the provided status.
*
- * @param status The provided status to set.
+ * @param status
+ * The provided status to set.
*/
@Deprecated
- public void setStatus(String status){
+ public void setStatus(String status) {
WorkflowState state = new WorkflowState();
state.setName(status);
this.state = state;
@@ -172,8 +172,9 @@ public class WorkflowInstance {
if (workflow != null && workflow instanceof ParentChildWorkflow) {
this.workflow = (ParentChildWorkflow) workflow;
} else {
- if(workflow == null) workflow = new Workflow();
- this.workflow = new ParentChildWorkflow(workflow);
+ if (workflow == null)
+ workflow = new Workflow();
+ this.workflow = new ParentChildWorkflow(workflow);
}
}
@@ -336,11 +337,13 @@ public class WorkflowInstance {
*/
@Deprecated
public void setEndDateTimeIsoStr(String endDateTimeIsoStr) {
- try {
- this.endDate = DateConvert.isoParse(endDateTimeIsoStr);
- } catch (ParseException e) {
- e.printStackTrace();
- // fail silently besides this: it's just a setter
+ if (endDateTimeIsoStr != null && !endDateTimeIsoStr.equals("")) {
+ try {
+ this.endDate = DateConvert.isoParse(endDateTimeIsoStr);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ // fail silently besides this: it's just a setter
+ }
}
}
@@ -359,11 +362,13 @@ public class WorkflowInstance {
*/
@Deprecated
public void setStartDateTimeIsoStr(String startDateTimeIsoStr) {
- try {
- this.startDate = DateConvert.isoParse(startDateTimeIsoStr);
- } catch (ParseException e) {
- e.printStackTrace();
- // fail silently besides this: it's just a setter
+ if (startDateTimeIsoStr != null && !startDateTimeIsoStr.equals("")) {
+ try {
+ this.startDate = DateConvert.isoParse(startDateTimeIsoStr);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ // fail silently besides this: it's just a setter
+ }
}
}
@@ -383,11 +388,14 @@ public class WorkflowInstance {
@Deprecated
public void setCurrentTaskEndDateTimeIsoStr(
String currentTaskEndDateTimeIsoStr) {
- try {
- this.taskEndDate = DateConvert.isoParse(currentTaskEndDateTimeIsoStr);
- } catch (ParseException e) {
- e.printStackTrace();
- // fail silently besides this: it's just a setter
+ if (currentTaskEndDateTimeIsoStr != null
+ && !currentTaskEndDateTimeIsoStr.equals("")) {
+ try {
+ this.taskEndDate = DateConvert.isoParse(currentTaskEndDateTimeIsoStr);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ // fail silently besides this: it's just a setter
+ }
}
}
@@ -407,11 +415,15 @@ public class WorkflowInstance {
@Deprecated
public void setCurrentTaskStartDateTimeIsoStr(
String currentTaskStartDateTimeIsoStr) {
- try {
- this.taskStartDate = DateConvert.isoParse(currentTaskStartDateTimeIsoStr);
- } catch (ParseException e) {
- e.printStackTrace();
- // fail silently besides this: it's just a setter
+ if (currentTaskStartDateTimeIsoStr != null
+ && !currentTaskStartDateTimeIsoStr.equals("")) {
+ try {
+ this.taskStartDate = DateConvert
+ .isoParse(currentTaskStartDateTimeIsoStr);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ // fail silently besides this: it's just a setter
+ }
}
}
Added: oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java?rev=1377477&view=auto
==============================================================================
--- oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java (added)
+++ oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java Sun Aug 26 18:42:37 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.workflow.structs;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ *
+ * Test harness for WorkflowInstance methods.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class TestWorkflowInstance extends TestCase {
+
+ /**
+ * @since OODT-486
+ */
+ public void testSetStartEndDateTimesNull() {
+ WorkflowInstance inst = new WorkflowInstance();
+ inst.setCurrentTaskEndDateTimeIsoStr(null);
+ inst.setCurrentTaskStartDateTimeIsoStr(null);
+ inst.setStartDateTimeIsoStr(null);
+ inst.setEndDateTimeIsoStr(null);
+
+ assertNull(inst.getEndDate());
+ assertNotNull(inst.getStartDate()); // only one initially set to new Date()
+ assertNull(inst.getTaskStartDate());
+ assertNull(inst.getTaskEndDate());
+ }
+
+}