Example usage for com.liferay.portal.kernel.servlet SessionMessages add

List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionMessages add.

Prototype

public static void add(PortletRequest portletRequest, String key) 

Source Link

Usage

From source file:org.opencps.paymentmgt.portlet.PaymentMgtBackOfficePortlet.java

License:Open Source License

/**
 * @param actionRequest/*www  . j a v a  2  s .c om*/
 * @param actionResponse
 */
public void updateConfirmPaymentCash(ActionRequest actionRequest, ActionResponse actionResponse) {

    long paymentFileId = ParamUtil.getLong(actionRequest, "paymentFileId");
    PaymentFile paymentFile = null;
    try {
        paymentFile = PaymentFileLocalServiceUtil.getPaymentFile(paymentFileId);
        paymentFile.setPaymentStatus(PaymentMgtUtil.PAYMENT_STATUS_APPROVED);
        paymentFile.setPaymentMethod(PaymentMgtUtil.PAYMENT_METHOD_CASH);
        PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);
        addProcessActionSuccessMessage = false;
        SessionMessages.add(actionRequest, "confirm-payment-cash-success");
    } catch (PortalException e) {
        SessionErrors.add(actionRequest, "confirm-payment-cash-error");
    } catch (SystemException e) {
        SessionErrors.add(actionRequest, "confirm-payment-cash-error");
    }

}

From source file:org.opencps.paymentmgt.portlet.PaymentMgtFrontOfficePortlet.java

License:Open Source License

/**
 * @param actionRequest/*from   w w  w  . j  a v  a2  s.  c om*/
 * @param actionResponse
 * @return
 * @throws PortalException
 * @throws SystemException
 * @throws IOException
 */
public void requestBankPayment(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    long paymentFileId = ParamUtil.getLong(actionRequest, PaymentFileDisplayTerms.PAYMENT_FILE_ID);

    String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");
    String returnURL = ParamUtil.getString(actionRequest, "returnURL");

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    System.out.println("----PAYMENT FILE ID----" + paymentFileId);
    try {
        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        if (paymentFileId <= 0) {
            FileEntry fileEntry = updateFileEntry(actionRequest, actionResponse);

            if (Validator.isNotNull(fileEntry)) {
            } else {
                throw new IOFileUploadException("File upload exception");
            }

        } else {
            FileEntry fileEntry = updateFileEntry(actionRequest, actionResponse);
            System.out.println("----CONFIRM FILE----" + fileEntry.getFileEntryId());
            PaymentFile paymentFile = null;
            try {
                paymentFile = PaymentFileLocalServiceUtil.getPaymentFile(paymentFileId);
                if (paymentFile != null) {
                    paymentFile.setConfirmFileEntryId(fileEntry.getFileEntryId());
                    paymentFile.setPaymentStatus(PaymentMgtUtil.PAYMENT_STATUS_CONFIRMED);
                    paymentFile.setPaymentMethod(PaymentMgtUtil.PAYMENT_METHOD_BANK);
                    PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);
                }
            } catch (NoSuchPaymentFileException e) {

            }

            SessionMessages.add(actionRequest, MessageKeys.PAYMENT_FILE_CONFIRM_BANK_SUCCESS);
        }
    } catch (Exception e) {
        if (e instanceof DuplicateFileNameException) {
            SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_NAME_EXCEPTION);
        } else if (e instanceof DuplicateFileNoException) {
            SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_NO_EXCEPTION);

        } else if (e instanceof IOFileUploadException) {
            SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_UPLOAD_EXCEPTION);
        } else {
            SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_EXCEPTION_OCCURRED);
        }
    }

}

From source file:org.opencps.paymentmgt.portlet.PaymentMgtPaymentConfigPortlet.java

License:Open Source License

/**
 * @param actionRequest//from www. j a v a 2s .c o  m
 * @param actionResponse
 * @throws IOException
 */
public void updatePaymentConfig(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    long paymentConfigId = ParamUtil.getLong(actionRequest, PaymentConfigDisplayTerms.PAYMENT_CONFIG_ID);
    long govAgencyOrganizationId = ParamUtil.getLong(actionRequest,
            PaymentConfigDisplayTerms.GOV_AGENCY_ORGANIZATION_ID);
    String govAgencyName = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.GOV_AGENCY_NAME);
    String govAgencyTaxNo = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.GOV_AGENCY_TAX_NO);
    String invoiceTemplateNo = ParamUtil.getString(actionRequest,
            PaymentConfigDisplayTerms.INVOICE_TEMPLATE_NO);
    String invoiceIssueNo = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.INVOICE_ISSUE_NO);
    String invoiceLastNo = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.INVOICE_LAST_NO);
    String bankInfo = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.BANK_INFO);
    String placeInfo = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.PLACE_INFO);
    String keypayDomain = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.KEYPAY_DOMAIN);
    String keypayVersion = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.KEYPAY_VERSION);
    String keypayMerchantCode = ParamUtil.getString(actionRequest,
            PaymentConfigDisplayTerms.KEYPAY_MERCHANT_CODE);
    String keypaySecureKey = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.KEYPAY_SECURE_KEY);
    String reportTemplate = ParamUtil.getString(actionRequest, PaymentConfigDisplayTerms.REPORT_TEMPLATE);

    String returnURL = ParamUtil.getString(actionRequest, "returnURL");
    String currentURL = ParamUtil.getString(actionRequest, "currentURL");
    String backURL = ParamUtil.getString(actionRequest, "backURL");

    try {

        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
        if (paymentConfigId == 0) {
            PaymentConfig c = PaymentConfigLocalServiceUtil.addPaymentConfig(govAgencyOrganizationId,
                    govAgencyName, govAgencyTaxNo, invoiceTemplateNo, invoiceIssueNo, invoiceLastNo, bankInfo,
                    placeInfo, keypayDomain, keypayVersion, keypayMerchantCode, keypaySecureKey, reportTemplate,
                    serviceContext.getUserId(), serviceContext);
            paymentConfigId = c.getPaymentConfigId();
        } else {
            PaymentConfigLocalServiceUtil.updatePaymentConfig(paymentConfigId, govAgencyOrganizationId,
                    govAgencyName, govAgencyTaxNo, invoiceTemplateNo, invoiceIssueNo, invoiceLastNo, bankInfo,
                    placeInfo, keypayDomain, keypayVersion, keypayMerchantCode, keypaySecureKey, reportTemplate,
                    serviceContext.getUserId(), serviceContext);
        }

        addProcessActionSuccessMessage = false;
        actionResponse.setRenderParameter(PaymentConfigDisplayTerms.PAYMENT_CONFIG_ID,
                String.valueOf(paymentConfigId));
        SessionMessages.add(actionRequest, "update-payment-config-success");
    } catch (Exception e) {
        SessionErrors.add(actionRequest, "update-payment-config-error");
    }

}

From source file:org.opencps.postal.portlet.PostalConfigPortlet.java

License:Open Source License

public void updatePostalConfig(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    long postalConfigId = ParamUtil.getLong(actionRequest, PostalConfigDisplayTerms.POSTAL_CONFIG_ID, 0);
    long govAgencyOrganizationId = ParamUtil.getLong(actionRequest,
            PostalConfigDisplayTerms.GOV_AGENCY_ORGANIZATION_ID);
    String postalDomain = ParamUtil.getString(actionRequest, PostalConfigDisplayTerms.POSTAL_DOMAIN,
            StringPool.BLANK);/*from   w ww . ja va2  s .c  o m*/
    String postalTokenCode = ParamUtil.getString(actionRequest, PostalConfigDisplayTerms.POSTAL_TOKENCODE,
            StringPool.BLANK);
    String postalCustomerCode = ParamUtil.getString(actionRequest, PostalConfigDisplayTerms.POSTAL_CUSTOMERCODE,
            StringPool.BLANK);
    boolean postalConfigStatus = ParamUtil.getBoolean(actionRequest, PostalConfigDisplayTerms.STATUS, true);
    String postalGateType = ParamUtil.getString(actionRequest, PostalConfigDisplayTerms.POSTAL_GATETYPE,
            StringPool.BLANK);

    List<PostalConfig> postalConfigs = new ArrayList<PostalConfig>();

    try {

        postalConfigs = PostalConfigLocalServiceUtil.getPostalConfigByOrgId(govAgencyOrganizationId);

        if (postalConfigs.size() > 0) {

            for (PostalConfig postalConfig : postalConfigs) {

                postalConfig.setStatus(false);

                PostalConfigLocalServiceUtil.updatePostalConfig(postalConfig);
            }
        }

        PostalConfig postalConfig = PostalConfigLocalServiceUtil.updateConfig(postalConfigId,
                govAgencyOrganizationId, postalCustomerCode, postalTokenCode, postalDomain, postalGateType,
                postalConfigStatus);

        actionResponse.setRenderParameter(PostalConfigDisplayTerms.POSTAL_CONFIG_ID,
                String.valueOf(postalConfig.getPostalConfigId()));
        actionResponse.setRenderParameter("tabs1", PostalKeys.TOP_TABS_POSTALCONFIG);

        SessionMessages.add(actionRequest, "update-postal-config-success");

    } catch (Exception e) {
        SessionErrors.add(actionRequest, "update-postal-config-error");
    }

}

From source file:org.opencps.postal.portlet.PostalConfigPortlet.java

License:Open Source License

public void updatePostOfficeMapping(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException {

    String postOfficeCode = ParamUtil.getString(actionRequest,
            PostOfficeMappingDisplayTerms.POSTOFFICE_CODE_TXT);
    String postOfficeName = ParamUtil.getString(actionRequest,
            PostOfficeMappingDisplayTerms.POSTOFFICE_NAME_TXT, StringPool.BLANK);
    String opencpsCityCode = ParamUtil.getString(actionRequest, PostOfficeMappingDisplayTerms.OPENCPS_CITY_CODE,
            StringPool.BLANK);// www  .  j  ava2 s  .co  m
    PostOfficeMapping postOfficeMapping = null;

    try {
        postOfficeMapping = PostOfficeMappingLocalServiceUtil.updatePostOffce(postOfficeCode, postOfficeName,
                opencpsCityCode);

        actionResponse.setRenderParameter("tabs1", PostalKeys.TOP_TABS_POSTOFFICEMAPPING);
        actionResponse.setRenderParameter(PostOfficeMappingDisplayTerms.POSTOFFICEMAPPING_ID,
                String.valueOf(postOfficeMapping.getPostOfficeMappingId()));

        SessionMessages.add(actionRequest, "update-post-office-mapping-success");
    } catch (Exception e) {

        SessionErrors.add(actionRequest, "update-post-office-mapping-error");
    }

}

From source file:org.opencps.processmgt.portlet.ConfigurationProcessOrderImpl.java

License:Open Source License

@Override
public void processAction(PortletConfig arg0, ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");

    PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest,
            portletResource);/*from   w ww  .j a va 2s . c om*/

    String tabs2 = ParamUtil.getString(actionRequest, "tabs2", "todolist");

    if (tabs2.equals("todolist")) {
        updateToDoList(preferences, actionRequest, actionResponse);
    } else if (tabs2.equals("justfinishedlist")) {
        updateJustFinishedList(preferences, actionRequest, actionResponse);
    } else if (tabs2.equals("processorder")) {
        updateProcessOrder(preferences, actionRequest, actionResponse);
    } else if (tabs2.equals("digital-signature")) {
        updateDigitalSignature(preferences, actionRequest, actionResponse);
    }

    preferences.store();

    SessionMessages.add(actionRequest, "potlet-config-saved");

}

From source file:org.opencps.processmgt.portlet.ProcessMgtAdminPortlet.java

License:Open Source License

/**
 * Update action//  ww w . j  a va  2  s.  c  o  m
 * 
 * @param actionRequest
 * @param actionResponse
 * @throws IOException
 */
public void updateAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");

    String returnURL = ParamUtil.getString(actionRequest, "returnURL");

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

    long processWorkflowId = ParamUtil.getLong(actionRequest, "processWorkflowId");

    long serviceProcessId = ParamUtil.getLong(actionRequest, "serviceProcessId");

    long preProcessStepId = ParamUtil.getLong(actionRequest, "preProcessStepId");

    long postProcessStepId = ParamUtil.getLong(actionRequest, "postProcessStepId");

    String autoEvent = ParamUtil.getString(actionRequest, "autoEvent");

    String actionName = ParamUtil.getString(actionRequest, "actionName");

    boolean assignUser = ParamUtil.getBoolean(actionRequest, "assignUser");

    long actionUserId = ParamUtil.getLong(actionRequest, "actionUserId");

    boolean requestPayment = ParamUtil.getBoolean(actionRequest, "requestPaymentCheckbox");

    String paymentFee = ParamUtil.getString(actionRequest, "paymentFee");

    boolean generateReceptionNo = ParamUtil.getBoolean(actionRequest, "generateReceptionNoCheckbox");

    String receptionNoPattern = ParamUtil.getString(actionRequest, "receptionNoPattern");

    boolean generateDeadline = ParamUtil.getBoolean(actionRequest, "generateDeadlineCheckbox");

    String deadlinePattern = ParamUtil.getString(actionRequest, "deadlinePattern");

    boolean isFinishStep = ParamUtil.getBoolean(actionRequest, "isFinishStepCheckbox");

    String preCondition = ParamUtil.getString(actionRequest, "preCondition");

    boolean isMultipled = ParamUtil.getBoolean(actionRequest, "isMultipledCheckbox");

    try {
        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        if (processWorkflowId <= 0) {

            // Add Workflow

            ProcessWorkflow workflow = ProcessWorkflowLocalServiceUtil.addWorkflow(serviceProcessId,
                    preProcessStepId, postProcessStepId, autoEvent, actionName, assignUser, actionUserId,
                    requestPayment, paymentFee, generateReceptionNo, receptionNoPattern, generateDeadline,
                    deadlinePattern, isFinishStep, preCondition, isMultipled, serviceContext);

            // Add WorkflowOutput

            List<WorkflowOutput> workflowOutputs = ProcessUtils.getWorkflowOutput(actionRequest,
                    workflow.getProcessWorkflowId());

            for (WorkflowOutput output : workflowOutputs) {
                WorkflowOutputLocalServiceUtil.addWorkflowOutput(output.getDossierPartId(),
                        output.getProcessWorkflowId(), output.getRequired(), output.getEsign(),
                        output.getPostback());
            }

        } else {
            // Update Workflow

            ProcessWorkflow workflow = ProcessWorkflowLocalServiceUtil.updateWorkflow(processWorkflowId,
                    preProcessStepId, postProcessStepId, autoEvent, actionName, assignUser, actionUserId,
                    requestPayment, paymentFee, generateReceptionNo, receptionNoPattern, generateDeadline,
                    deadlinePattern, isFinishStep, preCondition, isMultipled, serviceContext);

            // Add WorkflowOutput

            List<WorkflowOutput> workflowOutputs = ProcessUtils.getWorkflowOutput(actionRequest,
                    workflow.getProcessWorkflowId());

            List<WorkflowOutput> beforeList = WorkflowOutputLocalServiceUtil
                    .getByProcessWF(workflow.getProcessWorkflowId());

            List<WorkflowOutput> removeWorkflow = ProcessUtils.getWorkflowOutputRemove(beforeList,
                    workflowOutputs);

            for (WorkflowOutput output : removeWorkflow) {
                WorkflowOutputLocalServiceUtil.deleteWorkflowOutput(output);
            }

            for (WorkflowOutput output : workflowOutputs) {
                if (output.getWorkflowOutputId() > 0) {
                    WorkflowOutputLocalServiceUtil.updateWorkflowOutput(output.getWorkflowOutputId(),
                            output.getDossierPartId(), output.getProcessWorkflowId(), output.getRequired(),
                            output.getEsign(), output.getPostback());
                } else {
                    WorkflowOutputLocalServiceUtil.addWorkflowOutput(output.getDossierPartId(),
                            output.getProcessWorkflowId(), output.getRequired(), output.getEsign(),
                            output.getPostback());
                }
            }

        }

        if (Validator.isNotNull(redirectURL)) {
            actionResponse
                    .sendRedirect(redirectURL + "#_15_WAR_opencpsportlet_tab=_15_WAR_opencpsportlet_action");
        }
    } catch (Exception e) {
        if (Validator.isNotNull(returnURL)) {
            actionResponse.sendRedirect(returnURL);
        }
    }
}

From source file:org.opencps.processmgt.portlet.ProcessMgtAdminPortlet.java

License:Open Source License

/**
 * @param actionRequest//from   w  w  w  .  ja v  a2  s .c o  m
 * @param actionResponse
 * @throws IOException
 */
public void updateProcessStep(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");

    String returnURL = ParamUtil.getString(actionRequest, "returnURL");

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

    long processStepId = ParamUtil.getLong(actionRequest, "processStepId");

    String stepName = ParamUtil.getString(actionRequest, "stepName");

    int sequenceNo = ParamUtil.getInteger(actionRequest, "sequenceNo");

    String dossierStatus = ParamUtil.getString(actionRequest, "dossierStatus");

    int daysDuration = ParamUtil.getInteger(actionRequest, "daysDuration");

    long referenceDossierPartId = ParamUtil.getLong(actionRequest, "referenceDossierPartId");

    String externalAppUrl = ParamUtil.getString(actionRequest, "externalAppUrl");

    long serviceProcessId = ParamUtil.getLong(actionRequest, "serviceProcessId");

    try {
        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
        if (processStepId <= 0) {
            // TODO: Update validator here

            // Add ProcessStep

            ProcessStep step = ProcessStepLocalServiceUtil.addStep(serviceProcessId, stepName, sequenceNo,
                    dossierStatus, daysDuration, referenceDossierPartId, externalAppUrl, serviceContext);

            if (Validator.isNotNull(step)) {
                List<StepAllowance> stepAllowances = ProcessUtils.getStepAllowance(actionRequest,
                        step.getProcessStepId());

                List<ProcessStepDossierPart> stepDossiers = ProcessUtils.getStepDossiers(actionRequest,
                        step.getProcessStepId());

                // Add StepAllowane
                for (StepAllowance stepAllowance : stepAllowances) {

                    if (stepAllowance.getRoleId() == 0) {
                        continue;
                    }

                    if (stepAllowance.getStepAllowanceId() == 0) {
                        StepAllowanceLocalServiceUtil.addAllowance(step.getProcessStepId(),
                                stepAllowance.getRoleId(), stepAllowance.getReadOnly());
                    } else {
                        StepAllowanceLocalServiceUtil.updateAllowance(stepAllowance.getStepAllowanceId(),
                                stepAllowance.getRoleId(), stepAllowance.getReadOnly());
                    }
                }

                // Add ProcessStepDossiserPart
                /*
                 * for (long dossierPartId : dossiserParts) {
                 * ProcessStepDossierPartLocalServiceUtil.addPSDP(
                 * step.getProcessStepId(), dossierPartId); }
                 */
                for (ProcessStepDossierPart stepDossierPart : stepDossiers) {
                    ProcessStepDossierPartLocalServiceUtil.addPSDP(stepDossierPart.getProcessStepId(),
                            stepDossierPart.getDossierPartId());
                }
            }

            // Redirect page
            if (Validator.isNotNull(redirectURL)) {
                actionResponse
                        .sendRedirect(redirectURL + "#_15_WAR_opencpsportlet_tab=_15_WAR_opencpsportlet_step");
            }
        } else {
            // TODO: Update validator here

            // Update ProcessStep
            ProcessStep step = ProcessStepLocalServiceUtil.updateStep(processStepId, serviceProcessId, stepName,
                    sequenceNo, dossierStatus, daysDuration, referenceDossierPartId, externalAppUrl,
                    serviceContext);

            //StepAllowanceLocalServiceUtil.removeProcessStepByProcessId(step.getProcessStepId());

            List<StepAllowance> stepAllowances = ProcessUtils.getStepAllowance(actionRequest,
                    step.getProcessStepId());

            List<ProcessStepDossierPart> stepDossiers = ProcessUtils.getStepDossiers(actionRequest,
                    step.getProcessStepId());

            List<StepAllowance> before = StepAllowanceLocalServiceUtil
                    .getByProcessStep(step.getProcessStepId());

            List<ProcessStepDossierPart> beforeStepDossier = ProcessStepDossierPartLocalServiceUtil
                    .getByStep(step.getProcessStepId());

            //Remove ProcessStepDossier

            List<ProcessStepDossierPart> removeDossier = ProcessUtils.getStepDossierRemove(beforeStepDossier,
                    stepDossiers);

            ProcessStepDossierPartLocalServiceUtil.removeStepDossier(removeDossier);

            // Remove StepAllowance
            List<StepAllowance> removeStep = ProcessUtils.getStepAllowanceRemove(before, stepAllowances);

            StepAllowanceLocalServiceUtil.removeProcessStepByProcessId(removeStep);

            for (StepAllowance stepAllowance : stepAllowances) {

                if (stepAllowance.getRoleId() == 0) {
                    continue;
                }

                if (stepAllowance.getStepAllowanceId() == 0) {
                    StepAllowanceLocalServiceUtil.addAllowance(step.getProcessStepId(),
                            stepAllowance.getRoleId(), stepAllowance.getReadOnly());
                } else {
                    StepAllowanceLocalServiceUtil.updateAllowance(stepAllowance.getStepAllowanceId(),
                            stepAllowance.getRoleId(), stepAllowance.getReadOnly());
                }
            }

            //Add dossierPart
            for (ProcessStepDossierPart stepDossierPart : stepDossiers) {
                ProcessStepDossierPartLocalServiceUtil.addPSDP(stepDossierPart.getProcessStepId(),
                        stepDossierPart.getDossierPartId());
            }

            // Redirect page
            if (Validator.isNotNull(redirectURL)) {
                actionResponse
                        .sendRedirect(redirectURL + "#_15_WAR_opencpsportlet_tab=_15_WAR_opencpsportlet_step");
            }

        }
    } catch (Exception e) {
        if (Validator.isNotNull(returnURL)) {
            actionResponse.sendRedirect(returnURL);
        }
    }

}

From source file:org.opencps.processmgt.portlet.ProcessMgtAdminPortlet.java

License:Open Source License

/**
 * @param actionRequest/*from w  ww .ja  va  2  s . c  om*/
 * @param actionResponse
 * @throws IOException
 */
public void updateProcess(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    long serviceProcessId = ParamUtil.getLong(actionRequest, "serviceProcessId");

    String processNo = ParamUtil.getString(actionRequest, "processNo");

    String processName = ParamUtil.getString(actionRequest, "processName");

    String description = ParamUtil.getString(actionRequest, "description");

    String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");

    String returnURL = ParamUtil.getString(actionRequest, "returnURL");

    long dossierTemplateId = ParamUtil.getLong(actionRequest, "dossierTemplateId");

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

    try {
        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        if (serviceProcessId <= 0) {
            // TODO: Update validator

            // Add ServiceProcess
            ServiceProcessLocalServiceUtil.addProcess(processNo, processName, description, dossierTemplateId,
                    serviceContext);
            // Redirect page

            if (Validator.isNotNull(redirectURL)) {
                actionResponse.sendRedirect(redirectURL);
            }

        } else {
            // TODO: Update validator here

            // Update ServiceProcess

            ServiceProcessLocalServiceUtil.updateProcess(serviceProcessId, processNo, processName,
                    dossierTemplateId, description);

            // Redirect page
            if (Validator.isNotNull(redirectURL)) {
                actionResponse.sendRedirect(redirectURL);
            }
        }

    } catch (Exception e) {
        if (Validator.isNotNull(returnURL)) {
            actionResponse.sendRedirect(returnURL);
        }
    }

}

From source file:org.opencps.processmgt.portlet.ProcessMgtAdminPortlet.java

License:Open Source License

/**
 * @param actionRequest//from   w  w w . j a v  a  2  s .  c  om
 * @param actionResponse
 * @throws NoSuchServiceProcessException
 * @throws SystemException
 * @throws IOException
 */
public void deleteProcess(ActionRequest actionRequest, ActionResponse actionResponse)
        throws NoSuchServiceProcessException, SystemException, IOException {
    long serviceProcessId = ParamUtil.getLong(actionRequest, "serviceProcessId");
    String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");

    List<ProcessStep> processSteps = new ArrayList<ProcessStep>();
    List<ServiceInfoProcess> infoProcesses = new ArrayList<ServiceInfoProcess>();
    List<ProcessWorkflow> processWorkflows = new ArrayList<ProcessWorkflow>();

    try {
        processSteps = ProcessStepLocalServiceUtil.getStepByProcess(serviceProcessId);
    } catch (Exception e) {
    }

    try {
        infoProcesses = ServiceInfoProcessLocalServiceUtil.getServiceInfoProcessByProcessId(serviceProcessId);
    } catch (Exception e) {
    }

    try {
        processWorkflows = ProcessWorkflowLocalServiceUtil.getWorkFlowByProcess(serviceProcessId);
    } catch (Exception e) {
    }

    if (processSteps.isEmpty() && infoProcesses.isEmpty() && processWorkflows.isEmpty()) {
        ServiceProcessLocalServiceUtil.deleteProcess(serviceProcessId);

        SessionMessages.add(actionRequest, ProcessMgtUtil.DEL_PROCESS_SUCC);
    }

    else if (!processSteps.isEmpty()) {
        SessionErrors.add(actionRequest, ProcessMgtUtil.DELERR_EXIST_STEP);
    }

    else if (!infoProcesses.isEmpty()) {
        SessionErrors.add(actionRequest, ProcessMgtUtil.DELERR_EXIST_SERVICE_CONFIG);
    }

    else if (!processWorkflows.isEmpty()) {
        SessionErrors.add(actionRequest, ProcessMgtUtil.DELERR_EXIST_WORKFLOW);
    }

    if (Validator.isNotNull(redirectURL)) {
        actionResponse.sendRedirect(redirectURL);
    }
}