Example usage for java.lang Boolean equals

List of usage examples for java.lang Boolean equals

Introduction

In this page you can find the example usage for java.lang Boolean equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

Usage

From source file:org.egov.wtms.web.controller.application.CloserConnectionController.java

@RequestMapping(value = "/close/{applicationCode}", method = RequestMethod.POST)
public String update(@Valid @ModelAttribute final WaterConnectionDetails waterConnectionDetails,
        final BindingResult resultBinder, final RedirectAttributes redirectAttributes,
        final HttpServletRequest request, final Model model, final BindingResult errors,
        @RequestParam("files") final MultipartFile[] files) {
    final Boolean isCSCOperator = waterTaxUtils.isCSCoperator(securityUtils.getCurrentUser());
    final Boolean loggedUserIsMeesevaUser = waterTaxUtils.isMeesevaUser(securityUtils.getCurrentUser());
    final Boolean isAnonymousUser = waterTaxUtils.isAnonymousUser(securityUtils.getCurrentUser());
    model.addAttribute("isAnonymousUser", isAnonymousUser);
    if (loggedUserIsMeesevaUser && request.getParameter(MEESEVA_APPLICATION_NUMBER) != null)
        waterConnectionDetails.setMeesevaApplicationNumber(request.getParameter(MEESEVA_APPLICATION_NUMBER));

    final Boolean citizenPortalUser = waterTaxUtils.isCitizenPortalUser(securityUtils.getCurrentUser());
    model.addAttribute("citizenPortalUser", citizenPortalUser);
    if (!isCSCOperator && !citizenPortalUser && !loggedUserIsMeesevaUser && !isAnonymousUser) {
        final Boolean isJuniorAsstOrSeniorAsst = waterTaxUtils
                .isLoggedInUserJuniorOrSeniorAssistant(securityUtils.getCurrentUser().getId());
        if (!isJuniorAsstOrSeniorAsst)
            throw new ValidationException("err.creator.application");
    }//from w  w  w . j  a  v  a  2 s . c om
    String workFlowAction = "";

    if (request.getParameter("workFlowAction") != null)
        workFlowAction = request.getParameter("workFlowAction");

    Long approvalPosition = 0l;
    String approvalComent = "";

    if (request.getParameter("approvalComent") != null)
        approvalComent = request.getParameter("approvalComent");

    final Boolean applicationByOthers = waterTaxUtils.getCurrentUserRole();
    if (applicationByOthers != null && applicationByOthers.equals(true) || citizenPortalUser
            || loggedUserIsMeesevaUser || isAnonymousUser) {
        final Position userPosition = waterTaxUtils.getZonalLevelClerkForLoggedInUser(
                waterConnectionDetails.getConnection().getPropertyIdentifier());
        if (userPosition == null) {
            model.addAttribute("noJAORSAMessage", "No JA/SA exists to forward the application.");
            return "connection-closeForm";
        } else
            approvalPosition = userPosition.getId();

    }

    waterConnectionDetails.setPreviousApplicationType(request.getParameter("previousApplicationType"));

    final Set<FileStoreMapper> fileStoreSet = addToFileStore(files);
    Iterator<FileStoreMapper> fsIterator = null;
    if (fileStoreSet != null && !fileStoreSet.isEmpty())
        fsIterator = fileStoreSet.iterator();
    if (fsIterator != null && fsIterator.hasNext())
        waterConnectionDetails.setFileStore(fsIterator.next());

    if (isNotBlank(request.getParameter(APPROVALPOSITION)))
        approvalPosition = Long.valueOf(request.getParameter(APPROVALPOSITION));
    if (request.getParameter("closeConnectionType") != null
            && request.getParameter("closeConnectionType").equals(WaterTaxConstants.PERMENENTCLOSECODE))
        waterConnectionDetails.setCloseConnectionType(ClosureType.Permanent.getName());
    else
        waterConnectionDetails.setCloseConnectionType(ClosureType.Temporary.getName());
    waterConnectionDetails.setConnectionStatus(ConnectionStatus.CLOSED);
    waterConnectionDetails
            .setApplicationType(applicationTypeService.findByCode(WaterTaxConstants.CLOSINGCONNECTION));

    if (isAnonymousUser)
        waterConnectionDetails.setSource(ONLINE);
    if (citizenPortalUser && (waterConnectionDetails.getSource() == null
            || isBlank(waterConnectionDetails.getSource().toString())))
        waterConnectionDetails.setSource(waterTaxUtils.setSourceOfConnection(securityUtils.getCurrentUser()));
    if (loggedUserIsMeesevaUser) {
        waterConnectionDetails.setApplicationNumber(waterConnectionDetails.getMeesevaApplicationNumber());
        waterConnectionDetails.setSource(MEESEVA);
    }
    closerConnectionService.updatecloserConnection(waterConnectionDetails, approvalPosition, approvalComent,
            workFlowAction);
    model.addAttribute(WATERCONNECTIONDETAILS, waterConnectionDetails);
    model.addAttribute(MODE, "ack");
    if (loggedUserIsMeesevaUser)
        return "redirect:/application/generate-meesevareceipt?transactionServiceNumber="
                + waterConnectionDetails.getApplicationNumber();
    else
        return "redirect:/application/citizeenAcknowledgement?pathVars="
                + waterConnectionDetails.getApplicationNumber();

}

From source file:org.apache.pig.impl.logicalLayer.optimizer.OpLimitOptimizer.java

public void processNode(LOLimit limit) throws OptimizerException {
    try {/*from w w  w  .j  a v a 2  s .  c  o  m*/
        List<LogicalOperator> predecessors = mPlan.getPredecessors(limit);
        if (predecessors.size() != 1) {
            int errCode = 2008;
            String msg = "Limit cannot have more than one input. Found " + predecessors.size() + " inputs.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
        LogicalOperator predecessor = predecessors.get(0);

        // Limit cannot be pushed up
        if (predecessor instanceof LOCogroup || predecessor instanceof LOFilter || predecessor instanceof LOLoad
                || predecessor instanceof LOSplit || predecessor instanceof LODistinct
                || predecessor instanceof LOJoin) {
            return;
        }
        // Limit can be pushed in front of ForEach if it does not have a flatten
        else if (predecessor instanceof LOForEach) {
            LOForEach loForEach = (LOForEach) predecessor;
            List<Boolean> mFlatten = loForEach.getFlatten();
            boolean hasFlatten = false;
            for (Boolean b : mFlatten)
                if (b.equals(true))
                    hasFlatten = true;

            // We can safely move LOLimit up
            if (!hasFlatten) {
                // Get operator before LOFilter
                LogicalOperator prepredecessor = mPlan.getPredecessors(predecessor).get(0);
                if (prepredecessor != null) {
                    try {
                        mPlan.removeAndReconnect(limit);
                        insertBetween(prepredecessor, limit, predecessor, null);

                    } catch (Exception e) {
                        int errCode = 2009;
                        String msg = "Can not move LOLimit up";
                        throw new OptimizerException(msg, errCode, PigException.BUG, e);
                    }
                } else {
                    int errCode = 2010;
                    String msg = "LOForEach should have one input";
                    throw new OptimizerException(msg, errCode, PigException.BUG);
                }
                // we can move LOLimit even further, recursively optimize LOLimit
                processNode(limit);
            }
        }
        // Limit can be duplicated, and the new instance pushed in front of an operator for the following operators 
        // (that is, if you have X->limit, you can transform that to limit->X->limit):
        else if (predecessor instanceof LOCross || predecessor instanceof LOUnion) {
            LOLimit newLimit = null;
            List<LogicalOperator> nodesToProcess = new ArrayList<LogicalOperator>();
            for (LogicalOperator prepredecessor : mPlan.getPredecessors(predecessor))
                nodesToProcess.add(prepredecessor);
            for (LogicalOperator prepredecessor : nodesToProcess) {
                try {
                    newLimit = limit.duplicate();
                    insertBetween(prepredecessor, newLimit, predecessor, null);
                } catch (Exception e) {
                    int errCode = 2011;
                    String msg = "Can not insert LOLimit clone";
                    throw new OptimizerException(msg, errCode, PigException.BUG, e);
                }
                // we can move the new LOLimit even further, recursively optimize LOLimit
                processNode(newLimit);
            }
        }
        // Limit can be merged into LOSort, result a "limited sort"
        else if (predecessor instanceof LOSort) {
            if (mode == ExecType.LOCAL) {
                //We don't need this optimisation to happen in the local mode.
                //so we do nothing here.
            } else {
                LOSort sort = (LOSort) predecessor;
                if (sort.getLimit() == -1)
                    sort.setLimit(limit.getLimit());
                else
                    sort.setLimit(sort.getLimit() < limit.getLimit() ? sort.getLimit() : limit.getLimit());
                try {
                    mPlan.removeAndReconnect(limit);
                } catch (Exception e) {
                    int errCode = 2012;
                    String msg = "Can not remove LOLimit after LOSort";
                    throw new OptimizerException(msg, errCode, PigException.BUG, e);
                }
            }
        }
        // Limit is merged into another LOLimit
        else if (predecessor instanceof LOLimit) {
            LOLimit beforeLimit = (LOLimit) predecessor;
            beforeLimit.setLimit(
                    beforeLimit.getLimit() < limit.getLimit() ? beforeLimit.getLimit() : limit.getLimit());
            try {
                mPlan.removeAndReconnect(limit);
            } catch (Exception e) {
                int errCode = 2012;
                String msg = "Can not remove LOLimit after LOLimit";
                throw new OptimizerException(msg, errCode, PigException.BUG, e);
            }
        }
        // Limit and OrderBy (LOSort) can be separated by split
        else if (predecessor instanceof LOSplitOutput) {
            if (mode == ExecType.LOCAL) {
                //We don't need this optimisation to happen in the local mode.
                //so we do nothing here.
            } else {
                List<LogicalOperator> grandparants = mPlan.getPredecessors(predecessor);
                // After insertion of splitters, any node in the plan can 
                // have at most one predecessor
                if (grandparants != null && grandparants.size() != 0
                        && grandparants.get(0) instanceof LOSplit) {
                    List<LogicalOperator> greatGrandparants = mPlan.getPredecessors(grandparants.get(0));
                    if (greatGrandparants != null && greatGrandparants.size() != 0
                            && greatGrandparants.get(0) instanceof LOSort) {
                        LOSort sort = (LOSort) greatGrandparants.get(0);
                        LOSort newSort = new LOSort(sort.getPlan(),
                                new OperatorKey(sort.getOperatorKey().scope,
                                        NodeIdGenerator.getGenerator()
                                                .getNextNodeId(sort.getOperatorKey().scope)),
                                sort.getSortColPlans(), sort.getAscendingCols(), sort.getUserFunc());

                        newSort.setLimit(limit.getLimit());
                        try {
                            mPlan.replace(limit, newSort);
                        } catch (PlanException e) {
                            int errCode = 2012;
                            String msg = "Can not replace LOLimit with LOSort after splitter";
                            throw new OptimizerException(msg, errCode, PigException.BUG, e);
                        }
                    }
                }
            }
        } else {
            int errCode = 2013;
            String msg = "Moving LOLimit in front of " + predecessor.getClass().getSimpleName()
                    + " is not implemented";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
    } catch (OptimizerException oe) {
        throw oe;
    }
}

From source file:org.egov.wtms.web.controller.application.ReconnectionController.java

@RequestMapping(value = "/reconnection/{applicationCode}", method = RequestMethod.POST)
public String update(@Valid @ModelAttribute final WaterConnectionDetails waterConnectionDetails,
        final BindingResult resultBinder, final RedirectAttributes redirectAttributes,
        final HttpServletRequest request, final Model model,
        @RequestParam("files") final MultipartFile[] files) {
    final Boolean isCSCOperator = waterTaxUtils.isCSCoperator(securityUtils.getCurrentUser());
    final Boolean citizenPortalUser = waterTaxUtils.isCitizenPortalUser(securityUtils.getCurrentUser());
    final Boolean loggedUserIsMeesevaUser = waterTaxUtils.isMeesevaUser(securityUtils.getCurrentUser());
    final Boolean isAnonymousUser = waterTaxUtils.isAnonymousUser(securityUtils.getCurrentUser());
    if (loggedUserIsMeesevaUser && request.getParameter("meesevaApplicationNumber") != null)
        waterConnectionDetails.setMeesevaApplicationNumber(request.getParameter("meesevaApplicationNumber"));
    model.addAttribute("citizenPortalUser", citizenPortalUser);
    if (!isCSCOperator && !citizenPortalUser && !loggedUserIsMeesevaUser && !isAnonymousUser) {
        final Boolean isJuniorAsstOrSeniorAsst = waterTaxUtils
                .isLoggedInUserJuniorOrSeniorAssistant(securityUtils.getCurrentUser().getId());
        if (!isJuniorAsstOrSeniorAsst)
            throw new ValidationException("err.creator.application");
    }/*  w w w.j  av a 2  s  .c o  m*/

    if (waterConnectionDetails != null
            && CLOSINGCONNECTION.equalsIgnoreCase(waterConnectionDetails.getApplicationType().getCode()))
        waterConnectionDetails.getApplicationType().setCode(RECONNECTION);

    String sourceChannel = request.getParameter("Source");
    String workFlowAction = "";

    if (request.getParameter("mode") != null)
        request.getParameter("mode");

    if (request.getParameter("workFlowAction") != null)
        workFlowAction = request.getParameter("workFlowAction");

    Long approvalPosition = 0l;
    String approvalComent = "";

    final Boolean applicationByOthers = waterTaxUtils.getCurrentUserRole();

    if (applicationByOthers != null && applicationByOthers.equals(true) || citizenPortalUser
            || loggedUserIsMeesevaUser || isAnonymousUser) {
        final Position userPosition = waterTaxUtils.getZonalLevelClerkForLoggedInUser(
                waterConnectionDetails.getConnection().getPropertyIdentifier());
        if (userPosition == null) {
            model.addAttribute("noJAORSAMessage", "No JA/SA exists to forward the application.");
            return "reconnection-newForm";
        } else
            approvalPosition = userPosition.getId();

    }

    if (request.getParameter("approvalComent") != null)
        approvalComent = request.getParameter("approvalComent");
    final List<DocumentNames> documentListForClosed = waterConnectionDetailsService
            .getAllActiveDocumentNames(waterConnectionDetails.getApplicationType());
    final ApplicationDocuments applicationDocument = new ApplicationDocuments();
    if (!documentListForClosed.isEmpty()) {
        applicationDocument.setDocumentNames(documentListForClosed.get(0));
        applicationDocument.setWaterConnectionDetails(waterConnectionDetails);
        applicationDocument.setSupportDocs(addToFileStore(files));
        applicationDocument.setDocumentNumber("111");
        applicationDocument.setDocumentDate(new Date());
        waterConnectionDetails.getApplicationDocs().add(applicationDocument);
    }
    if (request.getParameter("approvalPosition") != null && !request.getParameter("approvalPosition").isEmpty())
        approvalPosition = Long.valueOf(request.getParameter("approvalPosition"));
    // waterConnectionDetails.setCloseConnectionType(request.getParameter("closeConnectionType").charAt(0));
    final String addrule = request.getParameter("additionalRule");
    // waterConnectionDetails.setConnectionStatus(ConnectionStatus.CLOSED);

    if (isAnonymousUser) {
        waterConnectionDetails.setSource(ONLINE);
        sourceChannel = SOURCECHANNEL_ONLINE;
    }

    if (citizenPortalUser && (waterConnectionDetails.getSource() == null
            || StringUtils.isBlank(waterConnectionDetails.getSource().toString())))
        waterConnectionDetails.setSource(waterTaxUtils.setSourceOfConnection(securityUtils.getCurrentUser()));
    WaterConnectionDetails savedWaterConnectionDetails = null;
    if (loggedUserIsMeesevaUser) {
        final HashMap<String, String> meesevaParams = new HashMap<>();
        meesevaParams.put("APPLICATIONNUMBER", waterConnectionDetails.getMeesevaApplicationNumber());
        waterConnectionDetails.setApplicationNumber(waterConnectionDetails.getMeesevaApplicationNumber());
        waterConnectionDetails.setSource(MEESEVA);
        savedWaterConnectionDetails = reconnectionService.updateReConnection(waterConnectionDetails,
                approvalPosition, approvalComent, addrule, workFlowAction, meesevaParams, sourceChannel);

    } else
        savedWaterConnectionDetails = reconnectionService.updateReConnection(waterConnectionDetails,
                approvalPosition, approvalComent, addrule, workFlowAction, sourceChannel);
    model.addAttribute("waterConnectionDetails", savedWaterConnectionDetails);

    if (loggedUserIsMeesevaUser)
        return "redirect:/application/generate-meesevareceipt?transactionServiceNumber="
                + waterConnectionDetails.getApplicationNumber();
    else
        return "redirect:/application/citizeenAcknowledgement?pathVars="
                + waterConnectionDetails.getApplicationNumber();

}

From source file:com.huawei.streaming.cql.executor.operatorviewscreater.AggResultSetMergeViewCreator.java

private void checkExcludeArguments(Boolean firstValue, Window w) throws ExecutorException {
    if (!firstValue.equals(w.isExcludeNow())) {
        LOG.error("'EXCLUDE NOW' argument must be set in all windows in one stream.");
        throw new ExecutorException(ErrorCode.UNKNOWN_SERVER_COMMON_ERROR);
    }//from  ww w. j  av  a  2s. c o  m
}

From source file:com.networknt.light.rule.menu.AbstractMenuRule.java

protected void updMenuItem(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {//  w  w  w  . j av  a2  s. c  o m
        graph.begin();
        Vertex menuItem = graph.getVertexByKey("MenuItem.menuItemId", (String) data.get("menuItemId"));
        if (menuItem != null) {
            // handle addMenuItems and delMenuItems
            Set<String> addMenuItems = (Set) data.get("addMenuItems");
            if (addMenuItems != null) {
                for (String menuItemId : addMenuItems) {
                    Vertex vertex = graph.getVertexByKey("MenuItem.menuItemId", menuItemId);
                    menuItem.addEdge("Own", vertex);
                }
            }
            Set<String> delMenuItems = (Set) data.get("delMenuItems");
            if (delMenuItems != null) {
                for (String menuItemId : delMenuItems) {
                    Vertex vertex = graph.getVertexByKey("MenuItem.menuItemId", menuItemId);
                    for (Edge edge : (Iterable<Edge>) menuItem.getEdges(Direction.OUT, "Own")) {
                        if (edge.getVertex(Direction.IN).equals(vertex))
                            graph.removeEdge(edge);
                    }
                }
            }
            String path = (String) data.get("path");
            if (path != null && !path.equals(menuItem.getProperty("path"))) {
                menuItem.setProperty("path", path);
            }
            String tpl = (String) data.get("tpl");
            if (tpl != null && !tpl.equals(menuItem.getProperty("tpl"))) {
                menuItem.setProperty("tpl", tpl);
            }
            String ctrl = (String) data.get("ctrl");
            if (ctrl != null && !ctrl.equals(menuItem.getProperty("ctrl"))) {
                menuItem.setProperty("ctrl", ctrl);
            }
            Boolean left = (Boolean) data.get("left");
            if (left != null && !left.equals(menuItem.getProperty("left"))) {
                menuItem.setProperty("left", left);
            }
            List roles = (List) data.get("roles");
            if (roles != null) {
                menuItem.setProperty("roles", roles);
            } else {
                menuItem.setProperty("roles", new ArrayList());
            }
            menuItem.setProperty("updateDate", data.get("updateDate"));
        }
        Vertex updateUser = graph.getVertexByKey("User.userId", data.get("updateUserId"));
        updateUser.addEdge("Update", menuItem);
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}

From source file:de.hybris.platform.mpintgomsbackoffice.actions.confirmreturn.ConfirmReturnAction.java

@Override
public ActionResult<TmallRefundRequestModel> perform(
        final ActionContext<TmallRefundRequestModel> actionContext) {
    final TmallRefundRequestModel refundRequest = actionContext.getData();
    final TmallOrderModel order = refundRequest.getTmallOrder();
    String result = StringUtils.EMPTY;
    String urlStr = "";

    final String refundId = refundRequest.getRefundId();
    final String returnRemark = refundRequest.getReturnRemark() == null ? "" : refundRequest.getReturnRemark();
    getModelService().save(refundRequest);

    if (StringUtils.isBlank(order.getMarketplaceStore().getIntegrationId())) {
        NotificationUtils.notifyUserVia(
                Labels.getLabel("marketplace.consignment.request.url.error",
                        new Object[] { order.getMarketplaceStore().getName() }),
                NotificationEvent.Type.WARNING, "");
        LOG.warn("authorization is expired!");
        result = ActionResult.ERROR;//from   w w  w. j  a v  a2s. co  m
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        actionResult.getStatusFlags().add(ActionResult.StatusFlag.OBJECT_PERSISTED);
        return actionResult;
    }

    final AddressModel returnAddress = refundRequest.getReturnAddress();
    if (null == returnAddress) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString(
                        "mpintgomsbackoffice.refund.button.approverereturn.requiredaddress"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    final Boolean isShippingAddress = returnAddress.getShippingAddress();
    if (isShippingAddress.equals(Boolean.FALSE)) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString(
                        "mpintgomsbackoffice.refund.button.approverereturn.noshippingaddress"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    final String lastname = returnAddress.getLastname() == null ? "" : returnAddress.getLastname();
    final String firstname = returnAddress.getFirstname() == null ? "" : returnAddress.getFirstname();

    final String name = lastname + firstname;
    if ("".equals(name)) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString("mpintgomsbackoffice.refund.button.approverereturn.nameempty"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    String country = "";
    if (returnAddress.getCountry() != null) {
        country = returnAddress.getCountry().getName() == null ? "" : returnAddress.getCountry().getName();
    }

    String region = "";
    if (returnAddress.getRegion() != null) {
        region = returnAddress.getRegion().getName() == null ? "" : returnAddress.getRegion().getName();
    }

    String city = "";
    if (returnAddress.getCity() != null) {
        city = returnAddress.getCity().getName() == null ? "" : returnAddress.getCity().getName();
    }

    final String district = returnAddress.getDistrict() == null ? "" : returnAddress.getDistrict();
    final String streetName = returnAddress.getStreetname() == null ? "" : returnAddress.getStreetname();
    final String streetNumber = returnAddress.getStreetnumber() == null ? "" : returnAddress.getStreetnumber();

    final String fullAddress = country + region + city + district + streetName + streetNumber;
    if ("".equals(fullAddress)) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString(
                        "mpintgomsbackoffice.refund.button.approverereturn.fulladdressempty"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    final String post = returnAddress.getPostalcode() == null ? "" : returnAddress.getPostalcode();
    if ("".equals(post)) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString("mpintgomsbackoffice.refund.button.approverereturn.postempty"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    final String tel = returnAddress.getPhone1() == null ? "" : returnAddress.getPhone1();
    if ("".equals(tel)) {
        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString("mpintgomsbackoffice.refund.button.approverereturn.telempty"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    final String mobile = returnAddress.getCellphone() == null ? "" : returnAddress.getCellphone();
    if ("".equals(mobile)) {
        NotificationUtils.notifyUserVia(
                Localization
                        .getLocalizedString("mpintgomsbackoffice.refund.button.approverereturn.mobileempty"),
                NotificationEvent.Type.WARNING, "");
        result = ActionResult.ERROR;
        final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
                result);
        return actionResult;
    }

    try {
        final String marketplaceLogId = marketplaceHttpUtil.getUUID();

        urlStr = requestUrl + Config.getParameter(MARKETPLACE_REFUNDREQUEST_CONFIRMRETURN_PATH);
        final JSONObject jsonObj = new JSONObject();
        jsonObj.put("integrationId", order.getMarketplaceStore().getIntegrationId());
        jsonObj.put("marketplaceLogId", marketplaceLogId);
        jsonObj.put("refundId", refundId);
        jsonObj.put("name", name);
        jsonObj.put("address", fullAddress);
        jsonObj.put("post", post);
        jsonObj.put("tel", tel);
        jsonObj.put("mobile", mobile);
        jsonObj.put("remark", returnRemark);

        result = ActionResult.SUCCESS;
        logUtil.addMarketplaceLog("PENDING", refundRequest.getRefundId(),
                Labels.getLabel("mpintgomsbackoffice.refund.approvereturn.action"), "TmallRefundRequest",
                order.getMarketplaceStore().getMarketplace(), refundRequest, marketplaceLogId);
        marketplaceHttpUtil.post(urlStr, jsonObj.toJSONString());

        refundRequest.setWaitMarketPlaceResponse(Boolean.TRUE);
        getModelService().save(refundRequest);

        NotificationUtils.notifyUserVia(
                Localization.getLocalizedString("mpintgomsbackoffice.refund.action.approvereturn.succ"),
                NotificationEvent.Type.SUCCESS, "");

        marketplaceHttpUtil.post(urlStr, jsonObj.toJSONString());
        result = ActionResult.SUCCESS;
    } catch (final Exception e) {
        LOG.error(e.toString());
        NotificationUtils.notifyUserVia(Labels.getLabel("mpintgomsbackoffice.refund.action.approvereturn.fail"),
                NotificationEvent.Type.FAILURE, "");
        result = ActionResult.ERROR;
    }
    final ActionResult<TmallRefundRequestModel> actionResult = new ActionResult<TmallRefundRequestModel>(
            result);
    actionResult.getStatusFlags().add(ActionResult.StatusFlag.OBJECT_PERSISTED);
    return actionResult;
}

From source file:org.apache.heron.scheduler.RuntimeManagerMain.java

/**
 * Before continuing to the action logic, verify:
 * - the topology is running//w  w w.  j av  a 2  s  .c  om
 * - the information in execution state matches the request
 * There is an edge case that the topology data could be only partially available,
 * which could be caused by not fully successful SUBMIT or KILL command. In this
 * case, we need to skip the validation and allow KILL command to go through.
 * In case execution state data is available, environment check will be done anyway.
 * @return true if the topology execution data is found, false otherwise.
 */
protected boolean validateRuntimeManage(SchedulerStateManagerAdaptor adaptor, String topologyName)
        throws TopologyRuntimeManagementException {
    // Check whether the topology has already been running
    Boolean isTopologyRunning = adaptor.isTopologyRunning(topologyName);
    boolean hasExecutionData = isTopologyRunning != null && isTopologyRunning.equals(Boolean.TRUE);
    if (!hasExecutionData) {
        if (command == Command.KILL) {
            LOG.warning(String.format("Topology '%s' is not found or not running", topologyName));
        } else {
            throw new TopologyRuntimeManagementException(
                    String.format("Topology '%s' does not exist", topologyName));
        }
    }

    // Check whether cluster/role/environ matched if execution state data is available.
    ExecutionEnvironment.ExecutionState executionState = adaptor.getExecutionState(topologyName);
    if (executionState == null) {
        if (command == Command.KILL) {
            LOG.warning(String.format("Topology execution state for '%s' is not found", topologyName));
        } else {
            throw new TopologyRuntimeManagementException(
                    String.format("Failed to get execution state for topology %s", topologyName));
        }
    } else {
        // Execution state is available, validate configurations.
        validateExecutionState(topologyName, executionState);
    }
    return hasExecutionData;
}

From source file:org.apache.heron.scheduler.SubmitterMain.java

protected void validateSubmit(SchedulerStateManagerAdaptor adaptor, String topologyName)
        throws TopologySubmissionException {
    // Check whether the topology has already been running
    // TODO(rli): anti-pattern is too nested on this path to be refactored
    Boolean isTopologyRunning = adaptor.isTopologyRunning(topologyName);

    if (isTopologyRunning != null && isTopologyRunning.equals(Boolean.TRUE)) {
        throw new TopologySubmissionException(String.format("Topology '%s' already exists", topologyName));
    }//  www . j  av  a 2  s.  co m
}

From source file:org.egov.wtms.web.controller.application.AdditionalConnectionController.java

@RequestMapping(value = "/addconnection/addConnection-create", method = RequestMethod.POST)
public String create(@Valid @ModelAttribute final WaterConnectionDetails addConnection,
        final BindingResult resultBinder, final RedirectAttributes redirectAttributes, final Model model,
        @RequestParam final String workFlowAction, final HttpServletRequest request,
        final BindingResult errors) {
    final Boolean isCSCOperator = waterTaxUtils.isCSCoperator(securityUtils.getCurrentUser());
    final Boolean citizenPortalUser = waterTaxUtils.isCitizenPortalUser(securityUtils.getCurrentUser());
    final Boolean loggedUserIsMeesevaUser = waterTaxUtils.isMeesevaUser(securityUtils.getCurrentUser());
    final Boolean isAnonymousUser = waterTaxUtils.isAnonymousUser(securityUtils.getCurrentUser());
    model.addAttribute("isAnonymousUser", isAnonymousUser);
    if (loggedUserIsMeesevaUser && request.getParameter(MEESEVAAPPLICATIONNUMBER) != null)
        addConnection.setMeesevaApplicationNumber(request.getParameter(MEESEVAAPPLICATIONNUMBER));
    model.addAttribute("citizenPortalUser", citizenPortalUser);
    if (!isCSCOperator && !citizenPortalUser && !loggedUserIsMeesevaUser && !isAnonymousUser) {
        final Boolean isJuniorAsstOrSeniorAsst = waterTaxUtils
                .isLoggedInUserJuniorOrSeniorAssistant(securityUtils.getCurrentUser().getId());
        if (!isJuniorAsstOrSeniorAsst)
            throw new ValidationException("err.creator.application");
    }/*from ww w .j a v  a  2  s .  co m*/

    final WaterConnectionDetails parent = waterConnectionDetailsService
            .getActiveConnectionDetailsByConnection(addConnection.getConnection().getParentConnection());
    final String message = additionalConnectionService.validateAdditionalConnection(parent);
    if (!message.isEmpty() && !"".equals(message))
        return "redirect:/application/addconnection/"
                + addConnection.getConnection().getParentConnection().getConsumerCode();

    final List<ApplicationDocuments> applicationDocs = new ArrayList<>();
    int i = 0;
    if (!addConnection.getApplicationDocs().isEmpty())
        for (final ApplicationDocuments applicationDocument : addConnection.getApplicationDocs()) {
            if (applicationDocument.getDocumentNumber() == null
                    && applicationDocument.getDocumentDate() != null) {
                final String fieldError = "applicationDocs[" + i + "].documentNumber";
                resultBinder.rejectValue(fieldError, "documentNumber.required");
            }
            if (applicationDocument.getDocumentNumber() != null
                    && applicationDocument.getDocumentDate() == null) {
                final String fieldError = "applicationDocs[" + i + "].documentDate";
                resultBinder.rejectValue(fieldError, "documentDate.required");
            } else if (connectionDetailService.validApplicationDocument(applicationDocument))
                applicationDocs.add(applicationDocument);
            i++;
        }
    if (ConnectionType.NON_METERED.equals(addConnection.getConnectionType()))
        waterConnectionDetailsService.validateWaterRateAndDonationHeader(addConnection);
    if (addConnection.getState() == null)
        addConnection.setStatus(waterTaxUtils.getStatusByCodeAndModuleType(
                WaterTaxConstants.APPLICATION_STATUS_CREATED, WaterTaxConstants.MODULETYPE));

    if (resultBinder.hasErrors()) {
        final WaterConnectionDetails parentConnectionDetails = waterConnectionDetailsService
                .getActiveConnectionDetailsByConnection(addConnection.getConnection());
        loadBasicDetails(addConnection, model, parentConnectionDetails,
                addConnection.getMeesevaApplicationNumber());
        final WorkflowContainer workflowContainer = new WorkflowContainer();
        workflowContainer.setAdditionalRule(addConnection.getApplicationType().getCode());
        prepareWorkflow(model, addConnection, workflowContainer);
        model.addAttribute("approvalPosOnValidate", request.getParameter(APPROVALPOSITION));
        model.addAttribute(ADDITIONALTULE, addConnection.getApplicationType().getCode());
        model.addAttribute(STATETYPE, addConnection.getClass().getSimpleName());
        model.addAttribute(CURRENTUSER, waterTaxUtils.getCurrentUserRole(securityUtils.getCurrentUser()));
        return ADDCONNECTION_FORM;
    }
    addConnection.setApplicationDate(new Date());
    addConnection.getApplicationDocs().clear();
    addConnection.setApplicationDocs(applicationDocs);

    processAndStoreApplicationDocuments(addConnection);

    Long approvalPosition = 0l;
    String approvalComment = "";
    String workFlowActionValue = "";

    if (request.getParameter("approvalComent") != null)
        approvalComment = request.getParameter("approvalComent");

    if (request.getParameter("workFlowAction") != null)
        workFlowActionValue = request.getParameter("workFlowAction");

    if (request.getParameter(APPROVALPOSITION) != null && !request.getParameter(APPROVALPOSITION).isEmpty())
        approvalPosition = Long.valueOf(request.getParameter(APPROVALPOSITION));

    final Boolean applicationByOthers = waterTaxUtils.getCurrentUserRole(securityUtils.getCurrentUser());

    if (applicationByOthers != null && applicationByOthers.equals(true) || citizenPortalUser
            || isAnonymousUser) {
        final Position userPosition = waterTaxUtils
                .getZonalLevelClerkForLoggedInUser(addConnection.getConnection().getPropertyIdentifier());
        if (userPosition != null)
            approvalPosition = userPosition.getId();
        else {
            final WaterConnectionDetails parentConnectionDetails = waterConnectionDetailsService
                    .getActiveConnectionDetailsByConnection(addConnection.getConnection());
            loadBasicDetails(addConnection, model, parentConnectionDetails, null);
            final WorkflowContainer workflowContainer = new WorkflowContainer();
            workflowContainer.setAdditionalRule(addConnection.getApplicationType().getCode());
            prepareWorkflow(model, addConnection, workflowContainer);
            model.addAttribute(ADDITIONALTULE, addConnection.getApplicationType().getCode());
            model.addAttribute(STATETYPE, addConnection.getClass().getSimpleName());
            model.addAttribute(CURRENTUSER, waterTaxUtils.getCurrentUserRole(securityUtils.getCurrentUser()));
            errors.rejectValue("connection.propertyIdentifier", "err.validate.connection.user.mapping",
                    "err.validate.connection.user.mapping");
            model.addAttribute("noJAORSAMessage", "No JA/SA exists to forward the application.");
            return ADDCONNECTION_FORM;

        }
    }

    if (isAnonymousUser)
        addConnection.setSource(ONLINE);
    else if (isCSCOperator)
        addConnection.setSource(CSC);
    else if (citizenPortalUser
            && (addConnection.getSource() == null || StringUtils.isBlank(addConnection.getSource().toString())))
        addConnection.setSource(waterTaxUtils.setSourceOfConnection(securityUtils.getCurrentUser()));
    else if (loggedUserIsMeesevaUser) {
        addConnection.setSource(MEESEVA);
        if (addConnection.getMeesevaApplicationNumber() != null)
            addConnection.setApplicationNumber(addConnection.getMeesevaApplicationNumber());
    } else
        addConnection.setSource(Source.SYSTEM);

    waterConnectionDetailsService.createNewWaterConnection(addConnection, approvalPosition, approvalComment,
            addConnection.getApplicationType().getCode(), workFlowActionValue);

    if (loggedUserIsMeesevaUser)
        return "redirect:/application/generate-meesevareceipt?transactionServiceNumber="
                + addConnection.getApplicationNumber();
    else
        return "redirect:/application/citizeenAcknowledgement?pathVars=" + addConnection.getApplicationNumber();
}

From source file:pt.webdetails.cpk.testUtils.PluginUtilsForTesting.java

/**
 * Calls out for resources in the plugin, on the specified path
 *
 * @param elementPath Relative to the plugin directory
 * @param recursive   Do we want to enable recursivity?
 * @param pattern     regular expression to filter the files
 * @return Files found//from w w w .j  a va 2  s  .c o  m
 */
@Override
public Collection<File> getPluginResources(String elementPath, Boolean recursive, String pattern) {

    IOFileFilter fileFilter = TrueFileFilter.TRUE;

    if (pattern != null && !pattern.equals("")) {
        fileFilter = new RegexFileFilter(pattern);

    }

    IOFileFilter dirFilter = recursive.equals(Boolean.TRUE) ? TrueFileFilter.TRUE : null;

    // Get directory name. We need to make sure we're not allowing this to fetch other resources
    String basePath = FilenameUtils.normalize(getPluginDirectory().getAbsolutePath());
    String elementFullPath = FilenameUtils.normalize(basePath + File.separator + elementPath);

    if (!elementFullPath.startsWith(basePath)) {
        logger.warn("PluginUtils.getPluginResources is trying to access a parent path - denied : "
                + elementFullPath);
        return null;
    }

    File dir = new File(elementFullPath);
    if (!dir.exists() || !dir.isDirectory()) {
        return null;
    }

    return FileUtils.listFiles(dir, fileFilter, dirFilter);

}