Search in sources :

Example 1 with Parameter

use of com.centurylink.mdw.service.Parameter in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method getVariableInfo.

/**
 * Must be called from the UI thread.
 */
public VariableTypeVO getVariableInfo(final VariableInstanceInfo varInstInfo) {
    String varType = varInstInfo.getType();
    VariableTranslator varTrans = getVariableTranslator(varType);
    final VariableTypeVO varTypeVO = new VariableTypeVO(0L, varType, varTrans == null ? null : varTrans.getClass().getName());
    if (varInstInfo.getStringValue() != null && varTypeVO.isJavaObjectType()) {
        BusyIndicator.showWhile(MdwPlugin.getShell().getDisplay(), new Runnable() {

            public void run() {
                DocumentReference docRef = new DocumentReference(varInstInfo.getStringValue());
                try {
                    Object obj = new JavaObjectTranslator().realToObject(getDocument(docRef).getContent());
                    varTypeVO.setVariableType(obj.getClass().getName());
                    varTypeVO.setUpdateable(obj instanceof SelfSerializable);
                } catch (TranslationException ex) {
                    if (MdwPlugin.getSettings().isLogConnectErrors())
                        PluginMessages.log(ex);
                    try {
                        if (!project.checkRequiredVersion(6, 1, 1)) {
                            String path = "DocumentValue?format=xml&id=" + docRef.getDocumentId() + "&type=" + varTypeVO.getVariableType();
                            String resp = getRestfulServer().invokeResourceService(path);
                            Resource res = Resource.Factory.parse(resp, Compatibility.namespaceOptions());
                            for (Parameter param : res.getParameterList()) {
                                if ("className".equals(param.getName()))
                                    varTypeVO.setVariableType(param.getStringValue());
                                else if ("isUpdateable".equals(param.getName()))
                                    varTypeVO.setUpdateable(Boolean.parseBoolean(param.getStringValue()));
                            }
                        }
                    } catch (Exception ex2) {
                        throw new RuntimeException(ex2.getMessage(), ex2);
                    }
                }
            }
        });
    }
    return varTypeVO;
}
Also used : JavaObjectTranslator(com.centurylink.mdw.common.translator.impl.JavaObjectTranslator) Resource(com.centurylink.mdw.service.Resource) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator) TranslationException(com.centurylink.mdw.common.exception.TranslationException) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) SelfSerializable(com.centurylink.mdw.common.translator.SelfSerializable) Parameter(com.centurylink.mdw.service.Parameter) JSONObject(org.json.JSONObject) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Example 2 with Parameter

use of com.centurylink.mdw.service.Parameter in project mdw-designer by CenturyLinkCloud.

the class RestfulServer method launchSynchronousProcess.

public String launchSynchronousProcess(Long processId, String masterRequestId, String owner, Long ownerId, Map<VariableVO, String> variables, String responseVarName, boolean oldFormat) throws XmlException, JSONException, IOException {
    if (isSchemaVersion61()) {
        return launchProcess(processId, masterRequestId, owner, ownerId, variables);
    } else {
        ActionRequestDocument actionRequestDoc = getLaunchProcessBaseDoc(processId, masterRequestId, owner, ownerId);
        Parameter syncParam = actionRequestDoc.getActionRequest().getAction().addNewParameter();
        syncParam.setName("mdw.Synchronous");
        syncParam.setStringValue("true");
        Parameter responseVarParam = actionRequestDoc.getActionRequest().getAction().addNewParameter();
        responseVarParam.setName("mdw.ResponseVariableName");
        responseVarParam.setStringValue(responseVarName);
        for (VariableVO variableVO : variables.keySet()) {
            Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
            parameter.setName(variableVO.getVariableName());
            parameter.setType(variableVO.getVariableType());
            String stringValue = variables.get(variableVO);
            parameter.setStringValue(stringValue);
        }
        try {
            HttpHelper httpHelper = getHttpHelper(getMdwWebUrl() + "/Services/REST");
            httpHelper.setConnectTimeout(getConnectTimeout());
            httpHelper.setReadTimeout(getReadTimeout());
            String request;
            if (oldFormat)
                request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
            else
                request = actionRequestDoc.xmlText(getXmlOptions());
            return httpHelper.post(request);
        } catch (SocketTimeoutException ex) {
            throw new RemoteException("Timeout after " + getReadTimeout() + " ms", ex);
        } catch (IOException ex) {
            throw new RemoteException("Unable to connect to " + getMdwWebUrl(), ex);
        }
    }
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) Parameter(com.centurylink.mdw.service.Parameter) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 3 with Parameter

use of com.centurylink.mdw.service.Parameter in project mdw-designer by CenturyLinkCloud.

the class Server method buildActionOnActivityInstanceRequest.

private String buildActionOnActivityInstanceRequest(Long activityId, Long activityInstanceId, String actionType, String completionCode, boolean oldFormat) throws XmlException {
    ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
    ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
    Action action = actionRequest.addNewAction();
    action.setName("PerformInstanceLevelAction");
    Parameter parameter = action.addNewParameter();
    parameter.setName("mdw.WorkType");
    parameter.setStringValue(WorkType.ACTIVITY.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.Action");
    parameter.setStringValue(actionType);
    parameter = action.addNewParameter();
    parameter.setName("mdw.DefinitionId");
    parameter.setStringValue(activityId.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.InstanceId");
    parameter.setStringValue(activityInstanceId.toString());
    if (completionCode != null) {
        parameter = action.addNewParameter();
        parameter.setName("mdw.CompletionCode");
        parameter.setStringValue(completionCode);
    }
    String request;
    if (oldFormat)
        request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
    else
        request = actionRequestDoc.xmlText(getXmlOptions());
    return request;
}
Also used : Action(com.centurylink.mdw.service.Action) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) Parameter(com.centurylink.mdw.service.Parameter) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 4 with Parameter

use of com.centurylink.mdw.service.Parameter in project mdw-designer by CenturyLinkCloud.

the class Server method getLaunchProcessBaseDoc.

protected ActionRequestDocument getLaunchProcessBaseDoc(Long processId, String masterRequestId, String owner, Long ownerId) {
    ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
    ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
    Action action = actionRequest.addNewAction();
    action.setName("PerformInstanceLevelAction");
    Parameter parameter = action.addNewParameter();
    parameter.setName("mdw.WorkType");
    parameter.setStringValue(WorkType.PROCESS.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.Action");
    parameter.setStringValue("Launch");
    parameter = action.addNewParameter();
    parameter.setName("mdw.DefinitionId");
    parameter.setStringValue(processId.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.MasterRequestId");
    parameter.setStringValue(masterRequestId);
    parameter = action.addNewParameter();
    parameter.setName("mdw.Owner");
    parameter.setStringValue(owner);
    parameter = action.addNewParameter();
    parameter.setName("mdw.OwnerId");
    if (ownerId == null)
        ownerId = new Date().getTime();
    parameter.setStringValue(ownerId.toString());
    return actionRequestDoc;
}
Also used : Action(com.centurylink.mdw.service.Action) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) Parameter(com.centurylink.mdw.service.Parameter) Date(java.util.Date) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 5 with Parameter

use of com.centurylink.mdw.service.Parameter in project mdw-designer by CenturyLinkCloud.

the class RestfulServer method refreshCache.

public MDWStatusMessageDocument refreshCache(String type, String cacheName, boolean global, boolean oldFormat, boolean includeDynamicJava) throws DataAccessException, XmlException, IOException {
    if (isSchemaVersion61())
        return refreshCache("WorkflowCache", cacheName, global, includeDynamicJava);
    else {
        ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
        ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
        Action action = actionRequest.addNewAction();
        action.setName("RefreshCache");
        if (type != null) {
            Parameter typeParam = action.addNewParameter();
            typeParam.setName("RefreshType");
            typeParam.setStringValue(type);
        }
        if (cacheName != null) {
            Parameter cacheNameParam = action.addNewParameter();
            cacheNameParam.setName("CacheName");
            cacheNameParam.setStringValue(cacheName);
        }
        if (global) {
            Parameter parameter = action.addNewParameter();
            parameter.setName("GlobalRefresh");
            parameter.setStringValue("true");
        }
        if (!includeDynamicJava) {
            Parameter parameter = action.addNewParameter();
            parameter.setName("ExcludedFormats");
            parameter.setStringValue(RuleSetVO.JAVA);
        }
        String request;
        if (oldFormat)
            request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
        else
            request = actionRequestDoc.xmlText(getXmlOptions());
        return invokeService(request);
    }
}
Also used : Action(com.centurylink.mdw.service.Action) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) Parameter(com.centurylink.mdw.service.Parameter) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Aggregations

Parameter (com.centurylink.mdw.service.Parameter)11 ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)9 Action (com.centurylink.mdw.service.Action)6 ActionRequest (com.centurylink.mdw.service.ActionRequestDocument.ActionRequest)6 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)3 IOException (java.io.IOException)3 RemoteException (java.rmi.RemoteException)2 JSONObject (org.json.JSONObject)2 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 StatusMessage (com.centurylink.mdw.common.service.types.StatusMessage)1 SelfSerializable (com.centurylink.mdw.common.translator.SelfSerializable)1 VariableTranslator (com.centurylink.mdw.common.translator.VariableTranslator)1 JavaObjectTranslator (com.centurylink.mdw.common.translator.impl.JavaObjectTranslator)1 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)1