Example usage for org.apache.commons.lang ArrayUtils isEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isEmpty.

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public Violation[] getAuthorizedViolations() {
    if (!ArrayUtils.isEmpty(violations)) {
        ArrayList list = new ArrayList();
        for (int i = 0; i < violations.length; i++) {
            if (violations[i].isAuthorized()) {
                list.add(violations[i]);
            }/*ww w  .  j av a2s  .c  o m*/
        }
        if (!list.isEmpty()) {
            return (Violation[]) list.toArray(new Violation[0]);
        }
    }
    return null;
}

From source file:com.etcc.csc.dao.OraclePaymentDAO.java

public OLC_PAYMENT_INFO_RECBean getPaymentInfo(BigDecimal docId, String docType, String dbSessionId,
        String ipAddress, String loginId) throws EtccErrorMessageException, Exception {
    OLC_PAYMENT_INFO_RECBean olcPaymentInfoRecBean = null;
    try {//ww w. ja va2s . c o  m

        setConnection(Util.getDbConnection());
        OLC_PAYMENT_INFO_REC[] O_PAYMENT_INFO_REC = new OLC_PAYMENT_INFO_REC[] { new OLC_PAYMENT_INFO_REC() };
        OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() };

        OLCSC_ACCT_MGMT plsql = new OLCSC_ACCT_MGMT(conn);

        int result = plsql.GET_PAYMENT_INFO(docId.toPlainString(), docType, dbSessionId, ipAddress, loginId,
                O_PAYMENT_INFO_REC, O_ERROR_MSG_ARR).intValue();

        if (result == 1) {
            if (!ArrayUtils.isEmpty(O_PAYMENT_INFO_REC)) {
                olcPaymentInfoRecBean = new OLC_PAYMENT_INFO_RECBean(O_PAYMENT_INFO_REC[0]);
            }
        } else {
            if (O_ERROR_MSG_ARR[0] != null && O_ERROR_MSG_ARR[0].getArray() != null
                    && O_ERROR_MSG_ARR[0].getArray().length > 0) {
                OLC_ERROR_MSG_REC[] errorMsgRecs = O_ERROR_MSG_ARR[0].getArray();
                EtccErrorMessageException em = new EtccErrorMessageException(
                        "PaymentWS::getPaymentInfo error message");
                for (int i = 0; i < errorMsgRecs.length; i++) {
                    em.addRecoverable(errorMsgRecs[i].getERROR_MSG());
                }
                throw em;
            } else {
                throw new EtccException("PaymentWS::getPaymentInfo fatal error");
            }
        }
    } finally {
        closeConnection();
    }
    return olcPaymentInfoRecBean;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getTotalMSPmtAdj() {
    BigDecimal result = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(this.msPmtAdjArr)) {
        for (int i = 0; i < this.msPmtAdjArr.length; i++) {
            result = result.add(this.msPmtAdjArr[i].getPmtAdjAmount());
        }//w  w  w  . j  ava  2  s .  co  m
    }
    return result;
}

From source file:com.etcc.csc.datatype.PaymentDetailUtil.java

public static Violation[] convertToStatementUnInvoiceViolations(OLC_ST_VIOLATION_REC[] olcUninvRecs)
        throws SQLException {
    if (ArrayUtils.isEmpty(olcUninvRecs)) {
        return null;
    }/* w  ww. j  ava 2  s .c  o  m*/
    Violation[] violations = new Violation[olcUninvRecs.length];

    for (int i = 0; i < olcUninvRecs.length; i++) {
        violations[i] = convertToStatementUnInvoiceViolation(olcUninvRecs[i]);
    }
    return violations;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getTotalRecentPmtAdjAmt() {
    BigDecimal result = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(this.msRecentPmtAdjArr)) {
        for (int i = 0; i < this.msRecentPmtAdjArr.length; i++) {
            result = result.add(this.msRecentPmtAdjArr[i].getPmtAdjAmount());
        }/*w w w . j a  v  a  2s  .c  o  m*/
    }
    return result;
}

From source file:fr.paris.lutece.plugins.document.service.DocumentService.java

/**
 * Update the specify attribute with the mRequest parameters
 *
 * @param attribute The {@link DocumentAttribute} to update
 * @param document The {@link Document}//w  w w . ja  v  a2 s .c o  m
 * @param mRequest The multipart http request
 * @param locale The locale
 * @return an admin message if error or null else
 */
private String setAttribute(DocumentAttribute attribute, Document document,
        MultipartHttpServletRequest mRequest, Locale locale) {
    String strParameterStringValue = mRequest.getParameter(attribute.getCode());
    FileItem fileParameterBinaryValue = mRequest.getFile(attribute.getCode());
    String strIsUpdatable = mRequest.getParameter(PARAMETER_ATTRIBUTE_UPDATE + attribute.getCode());
    String strToResize = mRequest.getParameter(attribute.getCode() + PARAMETER_CROPPABLE);
    boolean bIsUpdatable = ((strIsUpdatable == null) || strIsUpdatable.equals("")) ? false : true;
    boolean bToResize = ((strToResize == null) || strToResize.equals("")) ? false : true;

    if (strParameterStringValue != null) // If the field is a string
    {
        // Check for mandatory value
        if (attribute.isRequired() && strParameterStringValue.trim().equals("")) {
            return AdminMessageService.getMessageUrl(mRequest, Messages.MANDATORY_FIELDS,
                    AdminMessage.TYPE_STOP);
        }

        // Check for specific attribute validation
        AttributeManager manager = AttributeService.getInstance().getManager(attribute.getCodeAttributeType());
        String strValidationErrorMessage = manager.validateValue(attribute.getId(), strParameterStringValue,
                locale);

        if (strValidationErrorMessage != null) {
            String[] listArguments = { attribute.getName(), strValidationErrorMessage };

            return AdminMessageService.getMessageUrl(mRequest, MESSAGE_ATTRIBUTE_VALIDATION_ERROR,
                    listArguments, AdminMessage.TYPE_STOP);
        }

        attribute.setTextValue(strParameterStringValue);
    } else if (fileParameterBinaryValue != null) // If the field is a file
    {
        attribute.setBinary(true);

        String strContentType = fileParameterBinaryValue.getContentType();
        byte[] bytes = fileParameterBinaryValue.get();
        String strFileName = fileParameterBinaryValue.getName();
        String strExtension = FilenameUtils.getExtension(strFileName);

        AttributeManager manager = AttributeService.getInstance().getManager(attribute.getCodeAttributeType());

        if (!bIsUpdatable) {
            // there is no new value then take the old file value
            DocumentAttribute oldAttribute = document.getAttribute(attribute.getCode());

            if ((oldAttribute != null) && (oldAttribute.getBinaryValue() != null)
                    && (oldAttribute.getBinaryValue().length > 0)) {
                bytes = oldAttribute.getBinaryValue();
                strContentType = oldAttribute.getValueContentType();
                strFileName = oldAttribute.getTextValue();
                strExtension = FilenameUtils.getExtension(strFileName);
            }
        }

        List<AttributeTypeParameter> parameters = manager.getExtraParametersValues(locale, attribute.getId());

        String extensionList = StringUtils.EMPTY;

        if (CollectionUtils.isNotEmpty(parameters)
                && CollectionUtils.isNotEmpty(parameters.get(0).getValueList())) {
            extensionList = parameters.get(0).getValueList().get(0);
        }

        // Check for mandatory value
        if (attribute.isRequired() && ((bytes == null) || (bytes.length == 0))) {
            return AdminMessageService.getMessageUrl(mRequest, Messages.MANDATORY_FIELDS,
                    AdminMessage.TYPE_STOP);
        } else if (StringUtils.isNotBlank(extensionList) && !extensionList.contains(strExtension)) {
            Object[] params = new Object[2];
            params[0] = attribute.getName();
            params[1] = extensionList;

            return AdminMessageService.getMessageUrl(mRequest, MESSAGE_EXTENSION_ERROR, params,
                    AdminMessage.TYPE_STOP);
        }

        // Check for specific attribute validation
        String strValidationErrorMessage = manager.validateValue(attribute.getId(), strFileName, locale);

        if (strValidationErrorMessage != null) {
            String[] listArguments = { attribute.getName(), strValidationErrorMessage };

            return AdminMessageService.getMessageUrl(mRequest, MESSAGE_ATTRIBUTE_VALIDATION_ERROR,
                    listArguments, AdminMessage.TYPE_STOP);
        }

        if (bToResize && !ArrayUtils.isEmpty(bytes)) {
            // Resize image
            String strWidth = mRequest.getParameter(attribute.getCode() + PARAMETER_WIDTH);

            if (StringUtils.isBlank(strWidth) || !StringUtils.isNumeric(strWidth)) {
                String[] listArguments = { attribute.getName(),
                        I18nService.getLocalizedString(MESSAGE_ATTRIBUTE_WIDTH_ERROR, mRequest.getLocale()) };

                return AdminMessageService.getMessageUrl(mRequest, MESSAGE_ATTRIBUTE_VALIDATION_ERROR,
                        listArguments, AdminMessage.TYPE_STOP);
            }

            try {
                bytes = ImageUtils.resizeImage(bytes, Integer.valueOf(strWidth));
            } catch (IOException e) {
                return AdminMessageService.getMessageUrl(mRequest, MESSAGE_ATTRIBUTE_RESIZE_ERROR,
                        AdminMessage.TYPE_STOP);
            }
        }

        attribute.setBinaryValue(bytes);
        attribute.setValueContentType(strContentType);
        attribute.setTextValue(strFileName);
    }

    return null;
}

From source file:com.mindcognition.mindraider.application.model.note.NoteCustodian.java

/**
 * Get attachments of a concept.//  www  .  j  av a 2 s  .co  m
 * 
 * @param noteResource
 *            concept resource
 * @return concept's attachments.
 */
public AttachmentResource[] getAttachments(ConceptResource conceptResource) {
    if (conceptResource != null) {
        AttachmentProperty[] properties = conceptResource.getAttachments();
        if (!ArrayUtils.isEmpty(properties)) {
            ArrayList<AttachmentResource> result = new ArrayList<AttachmentResource>();
            for (AttachmentProperty attachmentProperty : properties) {
                result.add(new AttachmentResource(attachmentProperty.getDescription(),
                        attachmentProperty.getUrl()));
            }
            return result.toArray(new AttachmentResource[result.size()]);
        }
    }
    return null;
}

From source file:com.etcc.csc.dao.OraclePaymentDAO.java

public String getPaymentReceipt(BigDecimal docId, String docType, String dbSessionId, String ipAddress,
        String loginId, BigDecimal paymentId, String reportFormat) throws EtccErrorMessageException, Exception {
    String reportUrl = null;//www  .  j  av a  2 s  .c o  m

    try {

        setConnection(Util.getDbConnection());
        String[] O_REPORT_URL = new String[] { "" };
        OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() };

        int result = new OLCSC_REP(conn).ONLINE_RECEIPT_RPT(reportFormat, docId, docType, paymentId,
                dbSessionId, ipAddress, loginId, O_REPORT_URL, O_ERROR_MSG_ARR).intValue();
        if (result == 1) {
            if (!ArrayUtils.isEmpty(O_REPORT_URL)) {
                reportUrl = O_REPORT_URL[0].trim();
            }
        } else {
            if (O_ERROR_MSG_ARR[0] != null && O_ERROR_MSG_ARR[0].getArray() != null
                    && O_ERROR_MSG_ARR[0].getArray().length > 0) {
                OLC_ERROR_MSG_REC[] errorMsgRecs = O_ERROR_MSG_ARR[0].getArray();
                EtccErrorMessageException em = new EtccErrorMessageException("postViolations error message");
                for (int i = 0; i < errorMsgRecs.length; i++) {
                    em.addRecoverable(errorMsgRecs[i].getERROR_MSG());
                }
                throw em;
            } else {
                throw new EtccException("postViolations fatal error");
            }
        }
    } finally {
        closeConnection();
    }
    return reportUrl;
}

From source file:gnete.card.web.merch.MerchAction.java

public String checkList() throws Exception {
    // ??ID//from  ww  w .  j a v a2s.com
    String ids[] = workflowService.getMyJob(WorkflowConstants.WORKFLOW_ADD_MERCH, getSessionUser());
    if (ArrayUtils.isEmpty(ids)) {
        this.page = new Paginater(this.getPageSize(), this.getPageNumber());
        return CHECK_LIST;
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("ids", ids);
    this.page = this.merchInfoRegDAO.find(params, this.getPageNumber(), this.getPageSize());

    return CHECK_LIST;
}

From source file:com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.java

/**
 * Makes sure that all the exclusions are valid. They are called "Exception" for historical reasons.
 *//*  www .ja v a2  s .c o m*/
private void checkExceptions() throws MojoExecutionException {
    if (!ArrayUtils.isEmpty(exceptions)) {
        for (int idx = 0; idx < exceptions.length; idx++) {
            if (exceptions[idx].check()) {
                LOG.info("Adding exclusion '{}'", exceptions[idx]);
            } else {
                throw new MojoExecutionException(
                        "Illegal exclusion specification " + exceptions[idx].toString());
            }
        }
    }
}