Skip to content
This repository has been archived by the owner on Jan 6, 2018. It is now read-only.

Commit

Permalink
Closes GH-614 Fixing CLient Proxy to work for toString calls
Browse files Browse the repository at this point in the history
  • Loading branch information
bansalmayank authored and tucu00 committed Mar 31, 2011
1 parent 7d1d2dd commit d4a9db1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public interface JsonTags {
public static final String COORDINATOR_ACTION_DATA = "data";
public static final String COORDINATOR_JOB_DATA = "data";

public static final String TO_STRING = "toString";

public static final String ERROR = "error";
public static final String ERROR_CODE = "code";
public static final String ERROR_MESSAGE = "message";
Expand Down
26 changes: 15 additions & 11 deletions client/src/main/java/org/apache/oozie/client/rest/JsonToBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Property(String label, Class type, boolean isList) {
WF_ACTION.put("getConsoleUrl", new Property(JsonTags.WORKFLOW_ACTION_CONSOLE_URL, String.class));
WF_ACTION.put("getErrorCode", new Property(JsonTags.WORKFLOW_ACTION_ERROR_CODE, String.class));
WF_ACTION.put("getErrorMessage", new Property(JsonTags.WORKFLOW_ACTION_ERROR_MESSAGE, String.class));
WF_ACTION.put("toString", new Property(JsonTags.TO_STRING, String.class));

WF_JOB.put("getAppPath", new Property(JsonTags.WORKFLOW_APP_PATH, String.class));
WF_JOB.put("getAppName", new Property(JsonTags.WORKFLOW_APP_NAME, String.class));
Expand All @@ -91,7 +92,7 @@ public Property(String label, Class type, boolean isList) {
WF_JOB.put("getRun", new Property(JsonTags.WORKFLOW_RUN, Integer.TYPE));
WF_JOB.put("getConsoleUrl", new Property(JsonTags.WORKFLOW_CONSOLE_URL, String.class));
WF_JOB.put("getActions", new Property(JsonTags.WORKFLOW_ACTIONS, WorkflowAction.class, true));

WF_JOB.put("toString", new Property(JsonTags.TO_STRING, String.class));

COORD_ACTION.put("getId", new Property(JsonTags.COORDINATOR_ACTION_ID, String.class));
COORD_ACTION.put("getJobId", new Property(JsonTags.COORDINATOR_JOB_ID, String.class));
Expand All @@ -111,6 +112,7 @@ public Property(String label, Class type, boolean isList) {
COORD_ACTION.put("getConsoleUrl", new Property(JsonTags.COORDINATOR_ACTION_CONSOLE_URL, String.class));
COORD_ACTION.put("getErrorCode", new Property(JsonTags.COORDINATOR_ACTION_ERROR_CODE, String.class));
COORD_ACTION.put("getErrorMessage", new Property(JsonTags.COORDINATOR_ACTION_ERROR_MESSAGE, String.class));
COORD_ACTION.put("toString", new Property(JsonTags.TO_STRING, String.class));

COORD_JOB.put("getAppPath", new Property(JsonTags.COORDINATOR_JOB_PATH, String.class));
COORD_JOB.put("getAppName", new Property(JsonTags.COORDINATOR_JOB_NAME, String.class));
Expand All @@ -133,14 +135,16 @@ public Property(String label, Class type, boolean isList) {
COORD_JOB.put("getGroup", new Property(JsonTags.COORDINATOR_JOB_GROUP, String.class));
COORD_JOB.put("getConsoleUrl", new Property(JsonTags.COORDINATOR_JOB_CONSOLE_URL, String.class));
COORD_JOB.put("getActions", new Property(JsonTags.COORDINATOR_ACTIONS, CoordinatorAction.class, true));
COORD_JOB.put("toString", new Property(JsonTags.TO_STRING, String.class));

}

/**
* The dynamic proxy invocation handler used to convert JSON values to bean properties using a mapping.
*/
private static class JsonInvocationHandler implements InvocationHandler {
private Map<String, Property> mapping;
private JSONObject json;
private final Map<String, Property> mapping;
private final JSONObject json;

/**
* Invocation handler constructor.
Expand Down Expand Up @@ -203,7 +207,7 @@ else if (type == WorkflowAction.class) {

/**
* Creates a workflow action bean from a JSON object.
*
*
* @param json json object.
* @return a workflow action bean populated with the JSON object values.
*/
Expand All @@ -215,7 +219,7 @@ public static WorkflowAction createWorkflowAction(JSONObject json) {

/**
* Creates a list of workflow action beans from a JSON array.
*
*
* @param json json array.
* @return a list of workflow action beans from a JSON array.
*/
Expand All @@ -229,7 +233,7 @@ public static List<WorkflowAction> createWorkflowActionList(JSONArray json) {

/**
* Creates a workflow job bean from a JSON object.
*
*
* @param json json object.
* @return a workflow job bean populated with the JSON object values.
*/
Expand All @@ -241,7 +245,7 @@ public static WorkflowJob createWorkflowJob(JSONObject json) {

/**
* Creates a list of workflow job beans from a JSON array.
*
*
* @param json json array.
* @return a list of workflow job beans from a JSON array.
*/
Expand All @@ -255,7 +259,7 @@ public static List<WorkflowJob> createWorkflowJobList(JSONArray json) {

/**
* Creates a coordinator action bean from a JSON object.
*
*
* @param json json object.
* @return a coordinator action bean populated with the JSON object values.
*/
Expand All @@ -267,7 +271,7 @@ public static CoordinatorAction createCoordinatorAction(JSONObject json) {

/**
* Creates a list of coordinator action beans from a JSON array.
*
*
* @param json json array.
* @return a list of coordinator action beans from a JSON array.
*/
Expand All @@ -281,7 +285,7 @@ public static List<CoordinatorAction> createCoordinatorActionList(JSONArray json

/**
* Creates a coordinator job bean from a JSON object.
*
*
* @param json json object.
* @return a coordinator job bean populated with the JSON object values.
*/
Expand All @@ -293,7 +297,7 @@ public static CoordinatorJob createCoordinatorJob(JSONObject json) {

/**
* Creates a list of coordinator job beans from a JSON array.
*
*
* @param json json array.
* @return a list of coordinator job beans from a JSON array.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public JSONObject toJSONObject() {
json.put(JsonTags.COORDINATOR_ACTION_CONSOLE_URL, consoleUrl);
json.put(JsonTags.COORDINATOR_ACTION_ERROR_CODE, errorCode);
json.put(JsonTags.COORDINATOR_ACTION_ERROR_MESSAGE, errorMessage);
json.put(JsonTags.TO_STRING, toString());
return json;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class JsonCoordinatorJob implements CoordinatorJob, JsonBean {
@Column(name = "concurrency")
private int concurrency = 0;


@Transient
private Timeunit timeUnit = CoordinatorJob.Timeunit.MINUTE;

Expand Down Expand Up @@ -140,6 +141,7 @@ public JSONObject toJSONObject() {
json.put(JsonTags.COORDINATOR_JOB_GROUP, group);
json.put(JsonTags.COORDINATOR_JOB_CONSOLE_URL, consoleUrl);
json.put(JsonTags.COORDINATOR_ACTIONS, JsonCoordinatorAction.toJSONArray(actions));
json.put(JsonTags.TO_STRING,toString());

return json;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public JSONObject toJSONObject() {
json.put(JsonTags.WORKFLOW_ACTION_CONSOLE_URL, consoleUrl);
json.put(JsonTags.WORKFLOW_ACTION_ERROR_CODE, errorCode);
json.put(JsonTags.WORKFLOW_ACTION_ERROR_MESSAGE, errorMessage);
json.put(JsonTags.TO_STRING, toString());
return json;
}

Expand Down Expand Up @@ -243,6 +244,7 @@ public void setErrorInfo(String errorCode, String errorMessage) {
this.errorMessage = errorMessage;
}

@Override
public String toString() {
return MessageFormat.format("Action name[{0}] status[{1}]", getName(), getStatus());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public JSONObject toJSONObject() {
json.put(JsonTags.WORKFLOW_RUN, (long) run);
json.put(JsonTags.WORKFLOW_CONSOLE_URL, consoleUrl);
json.put(JsonTags.WORKFLOW_ACTIONS, JsonWorkflowAction.toJSONArray(actions));
json.put(JsonTags.TO_STRING,toString());
return json;
}

Expand Down Expand Up @@ -243,6 +244,7 @@ public void setActions(List<? extends JsonWorkflowAction> nodes) {
this.actions = (nodes != null) ? nodes : new ArrayList<JsonWorkflowAction>();
}

@Override
public String toString() {
return MessageFormat.format("Workflow id[{0}] status[{1}]", getId(), getStatus());
}
Expand Down
1 change: 1 addition & 0 deletions release-log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Oozie 2.3.2 release

GH-0614 Fixing CLient Proxy to work for toString calls
GH-0480 Support new Pig API to submit pig job
GH-0529 Update Tomcat download URL
GH-0125 Query GET_WORKFLOWS_COLUMNS should order by createdTimestamp instead of starttime
Expand Down

0 comments on commit d4a9db1

Please sign in to comment.