Java Code Examples for org.apache.commons.lang.StringUtils#equalsIgnoreCase()

The following examples show how to use org.apache.commons.lang.StringUtils#equalsIgnoreCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KualiDocumentFormBase.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * This overridden method ...
 * IMPORTANT: any overrides of this method must ensure that nothing in the HTTP request will be used to determine whether document is in session 
 * 
 * @see org.kuali.rice.krad.web.struts.pojo.PojoFormBase#shouldPropertyBePopulatedInForm(java.lang.String, javax.servlet.http.HttpServletRequest)
 */
@Override
public boolean shouldPropertyBePopulatedInForm(String requestParameterName, HttpServletRequest request) {
	for ( String prefix : KRADConstants.ALWAYS_VALID_PARAMETER_PREFIXES ) {
		if (requestParameterName.startsWith(prefix)) {
			return true;
		}
	}

	if (StringUtils.equalsIgnoreCase(getMethodToCall(), KRADConstants.DOC_HANDLER_METHOD)) {
		return true;
	}
	if (WebUtils.isDocumentSession(getDocument(), this)) {
		return isPropertyEditable(requestParameterName) || isPropertyNonEditableButRequired(requestParameterName);
	}
	return true;
}
 
Example 2
Source File: RangerPathResourceMatcher.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
boolean isMatch(String resourceValue, Map<String, Object> evalContext) {

	final String noSeparator;
	if (getNeedsDynamicEval()) {
		String expandedPolicyValue = getExpandedValue(evalContext);
		noSeparator = expandedPolicyValue != null ? getStringToCompare(expandedPolicyValue) : null;
	} else {
		if (valueWithoutSeparator == null && value != null) {
			valueWithoutSeparator = getStringToCompare(value);
			valueWithSeparator = valueWithoutSeparator + Character.toString(levelSeparatorChar);
		}
		noSeparator = valueWithoutSeparator;
	}

	boolean ret = StringUtils.equalsIgnoreCase(resourceValue, noSeparator);

	if (!ret && noSeparator != null) {
		final String withSeparator = getNeedsDynamicEval() ? noSeparator + Character.toString(levelSeparatorChar) : valueWithSeparator;
		ret = StringUtils.startsWithIgnoreCase(resourceValue, withSeparator);
	}

	return ret;
}
 
Example 3
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Update the plug-in's minSdkVersion and targetSdkVersion
 *
 * @param androidManifestFile
 * @throws IOException
 * @throws DocumentException
 */
public static String getVersionName(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionName = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionName")) {
                    versionName = attr.getValue();
                }
            }
        }
    }
    return versionName;
}
 
Example 4
Source File: SecondaryUserStoreConfigurationUtil.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static Map<String, String> getSecondaryUserStorePropertiesFromTenantUserRealm(String userStoreDomain)
        throws IdentityUserStoreMgtException {

    Map<String, String> secondaryUserStoreProperties = null;
    try {
        RealmConfiguration realmConfiguration = UserStoreConfigComponent.getRealmService().getTenantUserRealm(
                getTenantIdInTheCurrentContext()).getRealmConfiguration();
        while (realmConfiguration != null) {
            String domainName = realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig
                    .PROPERTY_DOMAIN_NAME);
            if (StringUtils.equalsIgnoreCase(domainName, userStoreDomain)) {
                secondaryUserStoreProperties = realmConfiguration.getUserStoreProperties();
                break;
            } else {
                realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
            }
        }
    } catch (UserStoreException e) {
        String errorMessage = "Error while retrieving user store configurations for user store domain: "
                + userStoreDomain;
        throw new IdentityUserStoreMgtException(errorMessage, e);
    }
    return secondaryUserStoreProperties;
}
 
Example 5
Source File: DateTypeGenerator.java    From sofa-acts with Apache License 2.0 6 votes vote down vote up
@Override
public String generateObjectValue(Object obj, String csvPath, boolean isSimple) {
    String str = "null";
    if (obj != null) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        try {
            str = sdf.format(obj);
        } catch (Exception e) {
            ActsLogUtil.error(LOG, "Failed to parse [" + obj + "] !", e);
        }
    }

    if (StringUtils.equalsIgnoreCase(str, DateUtil.formatDateString(new Date(), dateFormat))) {
        return today;
    } else {
        return str;
    }
}
 
Example 6
Source File: HiveHook.java    From atlas with Apache License 2.0 5 votes vote down vote up
public void addToKnownEntities(Collection<AtlasEntity> entities) {
    for (AtlasEntity entity : entities) {
        if (StringUtils.equalsIgnoreCase(entity.getTypeName(), HIVE_TYPE_DB)) {
            addToKnownDatabase((String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
        } else if (StringUtils.equalsIgnoreCase(entity.getTypeName(), HIVE_TYPE_TABLE)) {
            addToKnownTable((String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
        }
    }
}
 
Example 7
Source File: CaseResultCollectUtil.java    From sofa-acts with Apache License 2.0 5 votes vote down vote up
/**
 * Whether the component result switch is on
 * 
 * @return
 */
public static boolean isCollectComponentResultOpen() {

    String isCollectComponentResult = ConfigrationFactory.getConfigration().getPropertyValue(
        "collect_case_component_result");

    if (StringUtils.isBlank(isCollectComponentResult)) {
        return true;
    }

    return StringUtils.equalsIgnoreCase(isCollectComponentResult.trim(),
        Boolean.TRUE.toString());
}
 
Example 8
Source File: GenerateDunningLettersLookupableHelperServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Determines if the given invoice matches the criteria given associated with the aging bucket specified in the lookup
 * @param invoice the contracts & grants invoice to check
 * @param agingBucket the type of the specified aging bucket
 * @param agingBucketStartValue the start age in days of the given aging bucket
 * @param agingBucketEndValue the end age in days of the given aging bucket
 * @param stateAgencyFinalCutOffDate value, from a parameter, for a different cutoff date which applies only to state agencies
 * @return true if the invoice matches, false otherwise
 */
protected boolean doesInvoiceFitWithinAgingBucket(ContractsGrantsInvoiceDocument invoice, String agingBucket, Integer agingBucketStartValue, Integer agingBucketEndValue, String stateAgencyFinalCutOffDate) {
    if (agingBucketStartValue == null || agingBucketEndValue == null) {
        return true; // just skip
    }
    int agingBucketStart = agingBucketStartValue.intValue();
    int agingBucketEnd = agingBucketEndValue.intValue();
    if (invoice.getInvoiceGeneralDetail().getAward().getAgency().isStateAgencyIndicator()) {
        if (agingBucket.equalsIgnoreCase(ArConstants.DunningLetters.DYS_PST_DUE_STATE_AGENCY_FINAL)) {
            agingBucketStart = new Integer(stateAgencyFinalCutOffDate) + 1;
            agingBucketEnd = 0;
        }
        else if (agingBucket.equalsIgnoreCase(ArConstants.DunningLetters.DYS_PST_DUE_121)) {
            agingBucketStart = 121;
            agingBucketEnd = new Integer(stateAgencyFinalCutOffDate);
        }
    }

    if (StringUtils.equalsIgnoreCase(agingBucket, ArConstants.DunningLetters.DYS_PST_DUE_FINAL)) {
        if (invoice.getInvoiceGeneralDetail().getAward().getAgency().isStateAgencyIndicator() || invoice.getAge().intValue() < agingBucketStart) {
            return false;
        }
    }
    else if (StringUtils.equalsIgnoreCase(agingBucket, ArConstants.DunningLetters.DYS_PST_DUE_STATE_AGENCY_FINAL)) {
        if (!invoice.getInvoiceGeneralDetail().getAward().getAgency().isStateAgencyIndicator() || invoice.getAge().intValue() < agingBucketStart) {
            return false;
        }
    }
    else if (invoice.getAge().intValue() < agingBucketStart || invoice.getAge().intValue() > agingBucketEnd) {
        return false;
    }

    return true;
}
 
Example 9
Source File: UrlHelper.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public static String getHttpsUrlFromHttpUrl(final String httpUrl) {
    final URI uri = createUri(httpUrl);
    String httpsUrl = httpUrl;
    if (uri != null && StringUtils.equalsIgnoreCase(uri.getScheme(), "http")) {
        final URI httpsUri = createUri("https://" + uri.getAuthority() + uri.getPath());
        httpsUrl = httpsUri.toString();
    }

    if (StringUtils.startsWithIgnoreCase(httpsUrl, "https://")) {
        return httpsUrl;
    } else {
        return null;
    }
}
 
Example 10
Source File: ProcurementCardDocumentPresentationController.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.kuali.rice.krad.document.authorization.DocumentPresentationControllerBase#canEdit(org.kuali.rice.krad.document.Document)
 */
@Override
public boolean canEdit(Document document) {
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    //DocumentType
    boolean canRouteReviewFullEdit = false;
    Set<String> currentNodeNames = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentNodeNames)) {
        for (String routeNode : currentNodeNames ) {
            if ( StringUtils.equalsIgnoreCase(routeNode, KFSConstants.RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT ) ) {
                canRouteReviewFullEdit = true;
                break;
            }
        }
    }

    // FULL_ENTRY only if: a) person has an approval request, b) we are at the correct level, c) it's not a correction document,
    // d) it is not an ADHOC request (important so that ADHOC don't get full entry).
    if (canRouteReviewFullEdit
            && (((FinancialSystemDocumentHeader) document.getDocumentHeader()).getFinancialDocumentInErrorNumber() == null)
            && workflowDocument.isApprovalRequested()
            && !workflowDocument.isAcknowledgeRequested()) {
        return true;
    }

    return super.canEdit(document);
}
 
Example 11
Source File: ExecutionSummary.java    From score with Apache License 2.0 5 votes vote down vote up
public void setBranchId(String branchId) {
    // In the DB and ExecutionSummaryEntity we use "EMPTY" (EMPTY_BRANCH) for empty branchId.
    // But all the usages still use null. So, here we convert it from "EMPTY" to null, for the outside world.
    if (StringUtils.equalsIgnoreCase(branchId, EMPTY_BRANCH)) {
        this.branchId = null;
    } else {
        this.branchId = branchId;
    }
}
 
Example 12
Source File: ContractsGrantsInvoiceCreateDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
protected KualiDecimal calculateTotalExpenditureAmount(ContractsGrantsInvoiceDocument document, List<ContractsGrantsLetterOfCreditReviewDetail> locReviewDetails) {
    Map<String, KualiDecimal> totalBilledByAccountNumberMap = new HashMap<String, KualiDecimal>();
    for (InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode : document.getInvoiceDetailAccountObjectCodes()) {
        String key = invoiceDetailAccountObjectCode.getChartOfAccountsCode()+"-"+invoiceDetailAccountObjectCode.getAccountNumber();
        KualiDecimal totalBilled = cleanAmount(totalBilledByAccountNumberMap.get(key));
        totalBilled = totalBilled.add(invoiceDetailAccountObjectCode.getTotalBilled());
        totalBilledByAccountNumberMap.put(key, totalBilled);
    }

    KualiDecimal totalExpendituredAmount = KualiDecimal.ZERO;
    for (InvoiceAccountDetail invAcctD : document.getAccountDetails()) {
        KualiDecimal currentExpenditureAmount = KualiDecimal.ZERO;
        if (!ObjectUtils.isNull(totalBilledByAccountNumberMap.get(invAcctD.getChartOfAccountsCode()+"-"+invAcctD.getAccountNumber()))) {
            invAcctD.setTotalPreviouslyBilled(totalBilledByAccountNumberMap.get(invAcctD.getChartOfAccountsCode()+"-"+invAcctD.getAccountNumber()));
        } else {
            invAcctD.setTotalPreviouslyBilled(KualiDecimal.ZERO);
        }

        currentExpenditureAmount = invAcctD.getCumulativeExpenditures().subtract(invAcctD.getTotalPreviouslyBilled());
        invAcctD.setInvoiceAmount(currentExpenditureAmount);
        // overwriting account detail expenditure amount if locReview Indicator is true - and award belongs to LOC Billing
        if (!ObjectUtils.isNull(document.getInvoiceGeneralDetail())) {
            ContractsAndGrantsBillingAward award = document.getInvoiceGeneralDetail().getAward();
            if (ObjectUtils.isNotNull(award) && StringUtils.equalsIgnoreCase(award.getBillingFrequencyCode(), ArConstants.LOC_BILLING_SCHEDULE_CODE) && !CollectionUtils.isEmpty(locReviewDetails)) {
                for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
                    final ContractsGrantsLetterOfCreditReviewDetail locReviewDetail = retrieveMatchingLetterOfCreditReviewDetail(awardAccount, locReviewDetails);
                    if (!ObjectUtils.isNull(locReviewDetail) && StringUtils.equals(awardAccount.getChartOfAccountsCode(), invAcctD.getChartOfAccountsCode()) && StringUtils.equals(awardAccount.getAccountNumber(), invAcctD.getAccountNumber())) {
                        currentExpenditureAmount = locReviewDetail.getAmountToDraw();
                        invAcctD.setInvoiceAmount(currentExpenditureAmount);
                    }
                }
            }
        }
        totalExpendituredAmount = totalExpendituredAmount.add(currentExpenditureAmount);
    }
    totalExpendituredAmount = totalExpendituredAmount.add(document.getInvoiceGeneralDetail().getTotalPreviouslyBilled());
    return totalExpendituredAmount;
}
 
Example 13
Source File: PaymentRequestTaxAreaValidation.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Validates federal and state tax rates based on each other and the income class.
 * Validation will be bypassed if income class is empty or N, or tax rates are null.
 * @param paymentRequest - payment request document
 * @return true if this validation passes; false otherwise.
 */
protected boolean validateTaxRates(PaymentRequestDocument preq) {
    boolean valid = true;
    String code = preq.getTaxClassificationCode();
    BigDecimal fedrate = preq.getTaxFederalPercent();
    BigDecimal strate = preq.getTaxStatePercent();
    MessageMap errorMap = GlobalVariables.getMessageMap();

    // only test the cases when income class and tax rates aren't empty/N
    if (StringUtils.isEmpty(code) || StringUtils.equalsIgnoreCase(code, "N") || fedrate == null || strate == null) {
        return true;
    }

    // validate that the federal and state tax rates are among the allowed set
    ArrayList<BigDecimal> fedrates = retrieveTaxRates(code, "F"); //(ArrayList<BigDecimal>) federalTaxRates.get(code);
    if (!listContainsValue(fedrates, fedrate)) {
        valid = false;
        errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
    }
    ArrayList<BigDecimal> strates = retrieveTaxRates(code, "S"); //(ArrayList<BigDecimal>) stateTaxRates.get(code);
    if (!listContainsValue(strates, strate)) {
        valid = false;
        errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_STATE_PERCENT);
    }

    // validate that the federal and state tax rate abide to certain relationship
    if (fedrate.compareTo(new BigDecimal(0)) == 0 && strate.compareTo(new BigDecimal(0)) != 0) {
        valid = false;
        errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapPropertyConstants.TAX_STATE_PERCENT);
    }
    boolean hasstrate = code.equalsIgnoreCase("F") || code.equalsIgnoreCase("A") || code.equalsIgnoreCase("O");
    if (fedrate.compareTo(new BigDecimal(0)) > 0 && strate.compareTo(new BigDecimal(0)) <= 0 && hasstrate) {
        valid = false;
        errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_NOT_ZERO_IF, PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapPropertyConstants.TAX_STATE_PERCENT);
    }

    return valid;
}
 
Example 14
Source File: PassiveEventHotSwappableAdvice.java    From cobarclient with Apache License 2.0 5 votes vote down vote up
public Object invoke(MethodInvocation invocation) throws Throwable {
    if (!StringUtils.equalsIgnoreCase(invocation.getMethod().getName(), "getConnection")) {
        return invocation.proceed();
    }

    try {
        return invocation.proceed();
        // need to check with detecting sql?

    } catch (Throwable t) {
        if (t instanceof SQLException) {
            // we use SQLStateSQLExceptionTranslator to translate SQLExceptions , but it doesn't mean it will work as we expected, 
            // so maybe more scope should be covered. we will check out later with runtime data statistics.
            DataAccessException dae = sqlExTranslator.translate(
                    "translate to check whether it's a resource failure exception", null,
                    (SQLException) t);
            if (dae instanceof DataAccessResourceFailureException) {
                logger.warn("failed to get Connection from data source with exception:\n{}", t);
                doSwap();
                return invocation.getMethod().invoke(targetSource.getTarget(),
                        invocation.getArguments());
            }
        }
        // other exception conditions should be handled by application, 
        // 'cause we don't have enough context information to decide what to do here.
        throw t;
    }
}
 
Example 15
Source File: PurApLineServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get the target account lines which will be used for allocate.
 *
 * @param sourceAccount
 * @param lineItems
 * @param addtionalCharge
 * @return
 */
protected List<PurchasingAccountsPayableLineAssetAccount> getAllocateTargetAccounts(PurchasingAccountsPayableLineAssetAccount sourceAccount, List<PurchasingAccountsPayableItemAsset> allocateTargetLines, boolean addtionalCharge) {
    GeneralLedgerEntry candidateEntry = null;
    GeneralLedgerEntry sourceEntry = sourceAccount.getGeneralLedgerEntry();
    List<PurchasingAccountsPayableLineAssetAccount> matchingAccounts = new ArrayList<PurchasingAccountsPayableLineAssetAccount>();
    List<PurchasingAccountsPayableLineAssetAccount> allAccounts = new ArrayList<PurchasingAccountsPayableLineAssetAccount>();

    // For additional charge allocation, target account selection is based on account lines with the same account number and
    // object code. If no matching, select all account lines. For line item to line items, select all account lines as target.
    for (PurchasingAccountsPayableItemAsset item : allocateTargetLines) {
        for (PurchasingAccountsPayableLineAssetAccount account : item.getPurchasingAccountsPayableLineAssetAccounts()) {
            //KFSMI-5122: We need to refresh account general ledger entry so that the gl entries become visible as candidateEntry
            account.refreshReferenceObject("generalLedgerEntry");
            candidateEntry = account.getGeneralLedgerEntry();

            if (ObjectUtils.isNotNull(candidateEntry)) {
                // For additional charge, select matching account when account number and object code both match.
                if (addtionalCharge && StringUtils.equalsIgnoreCase(sourceEntry.getChartOfAccountsCode(), candidateEntry.getChartOfAccountsCode()) && StringUtils.equalsIgnoreCase(sourceEntry.getAccountNumber(), candidateEntry.getAccountNumber()) && StringUtils.equalsIgnoreCase(sourceEntry.getFinancialObjectCode(), candidateEntry.getFinancialObjectCode())) {
                    matchingAccounts.add(account);
                }
            }

            allAccounts.add(account);
        }
    }

    return matchingAccounts.isEmpty() ? allAccounts : matchingAccounts;
}
 
Example 16
Source File: TDataSource.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
/**
 * 当前为非中心站点,并且当前dataSource配置为主站点,则忽略本次启动
 */
private boolean isIgnoreInit() {
    return StringUtils.equalsIgnoreCase(writeMode, "center") && !RouterUnitsHelper.isCenterUnit();
}
 
Example 17
Source File: BuildStatusLookupOperation.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
private BuildStatusResults getTfvcResults(final ServerContext context) {
    final List<BuildStatusRecord> buildStatusRecords = new ArrayList<BuildStatusRecord>(2);
    Build matchingBuild = null;
    BuildStatusResults results;

    // Check the context object to make sure it is valid
    if (context.getTeamProjectReference() == null || context.getTeamProjectReference().getId() == null) {
        logger.warn("getTfvcResults: The server context object is not correct. So, builds cannot be retrieved.");
        return new BuildStatusResults(context, null);
    }

    // Using the build REST client we will get the last 100 builds for this team project.
    // TODO: We will go through those builds and try to find one that matches our repo and common root.
    // If we can't find a perfect match, we will keep the first one that matches our repo type.
    final BuildHttpClient buildClient = context.getBuildHttpClient();
    final List<Build> builds = buildClient.getBuilds(context.getTeamProjectReference().getId(), null, null, null, null, null, null, null, BuildStatus.COMPLETED, null, null, null, null, 100, null, null, null, BuildQueryOrder.FINISH_TIME_DESCENDING);
    if (builds.size() > 0) {
        for (final Build b : builds) {
            if (b.getResult() == BuildResult.CANCELED) {
                // Ignore canceled builds (it would be better to not query for them above, but that isn't working in the SDK)
                continue;
            }

            // Get the repo and branch for the build and compare them to ours
            final BuildRepository repo = b.getRepository();
            if (repo != null && StringUtils.equalsIgnoreCase(repo.getType(), TFVC_REPO_TYPE)) {
                matchingBuild = b;
                break;
            }
        }

        // Create the results
        if (matchingBuild != null) {
            // Add the matching build to the status records list last
            buildStatusRecords.add(new BuildStatusRecord(matchingBuild));
        }
        results = new BuildStatusResults(context, buildStatusRecords);
    } else {
        // No builds were found for this project
        results = new BuildStatusResults(context, null);
    }
    return results;
}
 
Example 18
Source File: ConfigBuilder.java    From ymate-platform-v2 with Apache License 2.0 4 votes vote down vote up
public static ConfigBuilder system() {
    final Properties __props = new Properties();
    boolean _devFlag = false;
    boolean _testFlag = false;
    InputStream _in = null;
    try {
        String _env = System.getProperty("ymp.run_env");
        if (StringUtils.isNotBlank(_env)) {
            if (StringUtils.equalsIgnoreCase(_env, "dev")) {
                _in = __doLoadResourceStream("_DEV");
                _devFlag = _in != null;
            } else if (StringUtils.equalsIgnoreCase(_env, "test")) {
                _in = __doLoadResourceStream("_TEST");
                _testFlag = _in != null;
            }
        }
        if (_in == null) {
            _in = __doLoadResourceStream("_DEV");
            _devFlag = _in != null;
            if (_in == null) {
                _in = __doLoadResourceStream(null);
            }
        }
        if (_in != null) {
            __props.load(_in);
            if (_devFlag) {
                __props.setProperty("ymp.dev_mode", "true");
                __props.setProperty("ymp.run_env", "dev");
            } else if (_testFlag) {
                __props.setProperty("ymp.run_env", "test");
            } else {
                __props.setProperty("ymp.run_env", "product");
            }
        }
        return create(__props);
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(_in);
    }
}
 
Example 19
Source File: TravelAuthorizationDocumentPresentationController.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Determines if a reimbursement can be initiated for this document. This is done for {@link TravelAuthorizationDocument} instances
 * that have a workflow document status of FINAL or PROCESSED and on documents that do not have a workflow
 * App Doc Status of REIMB_HELD, CANCELLED, PEND_AMENDMENT, CLOSED, or RETIRED_VERSION. Also checks if the person has permission to
 * initiate the target documents. Will not show the new Reimbursement link if a TA already has a TR enroute.
 *
 * If the document is a TAC, the workflow document status must be FINAL and the App Doc Status must be CLOSED.
 *
 * check status of document and don't create if the status is not final or processed
 *
 * @param document
 * @return
 */
public boolean canNewReimbursement(TravelAuthorizationDocument document) {
    final String documentType = document.getDocumentTypeName();

    boolean documentStatusCheck = isFinalOrProcessed(document);

    final String appDocStatus = document.getApplicationDocumentStatus();
    boolean appDocStatusCheck = (!appDocStatus.equals(TravelAuthorizationStatusCodeKeys.REIMB_HELD)
            && !appDocStatus.equals(TravelAuthorizationStatusCodeKeys.CANCELLED)
            && !appDocStatus.equals(TravelAuthorizationStatusCodeKeys.PEND_AMENDMENT)
            && !appDocStatus.equals(TravelAuthorizationStatusCodeKeys.RETIRED_VERSION)
            && !appDocStatus.equals(TravelAuthorizationStatusCodeKeys.CLOSED));

    boolean statusCheck = documentStatusCheck && appDocStatusCheck;

    Person user = GlobalVariables.getUserSession().getPerson();
    boolean hasInitAccess = false;
    if (getTemRoleService().canAccessTravelDocument(document, user) && !ObjectUtils.isNull(document.getTraveler()) && document.getTemProfileId() != null && !ObjectUtils.isNull(document.getTemProfile())){
        //check if user also can init other docs
        hasInitAccess = user.getPrincipalId().equals(document.getTraveler().getPrincipalId()) || getTemRoleService().isTravelDocumentArrangerForProfile(documentType, user.getPrincipalId(), document.getTemProfileId()) || getTemRoleService().isTravelArranger(user, document.getTemProfile().getHomeDepartment() , document.getTemProfileId().toString(), documentType);
    }

    boolean checkRelatedDocs = true;

    //check whether there is already an ENROUTE TR
    List<Document> docs = getTravelDocumentService().getDocumentsRelatedTo(document, TemConstants.TravelDocTypes.TRAVEL_REIMBURSEMENT_DOCUMENT);
    for (Document doc : docs) {
        TravelReimbursementDocument trDoc = (TravelReimbursementDocument)doc;
        if (trDoc.getDocumentHeader().getWorkflowDocument().isEnroute()) {
            checkRelatedDocs &= false;
        }
    }

    //a TR document can be processed against a closed TA. If the TAC is Final/Closed display the TR link.
    if (StringUtils.equalsIgnoreCase(documentType, TemConstants.TravelDocTypes.TRAVEL_AUTHORIZATION_CLOSE_DOCUMENT)) {
        documentStatusCheck = document.getDocumentHeader().getWorkflowDocument().isFinal();
        appDocStatusCheck = appDocStatus.equals(TravelAuthorizationStatusCodeKeys.CLOSED);
        statusCheck = documentStatusCheck && appDocStatusCheck;
    }

    return statusCheck && hasInitAccess && checkRelatedDocs;
}
 
Example 20
Source File: TemProfileInquirableImpl.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @see org.kuali.rice.kns.inquiry.KualiInquirableImpl#getSections(org.kuali.rice.kns.bo.BusinessObject)
 */
@Override
public List<Section> getSections(BusinessObject bo) {

	List<Section> sections = super.getSections(bo);
	Person currUser = GlobalVariables.getUserSession().getPerson();
       InquiryRestrictions inquiryRestrictions = KNSServiceLocator.getBusinessObjectAuthorizationService().getInquiryRestrictions(bo, currUser);

       // This is to allow users to view their own profile. If the principalId from the profile
       // matches, the current user then fields are unmasked. Otherwise the other roles will handle the appropriate
       // masking/unmasking of fields (see TemProfileOrganizationHierarchyRoleTypeServiceImpl).
       TemProfile profile = (TemProfile) bo;
       String principalId = profile.getPrincipalId();
       FieldRestriction restriction;

       if (StringUtils.isNotBlank(principalId) && StringUtils.equalsIgnoreCase(currUser.getPrincipalId().trim(), principalId)) {
           for(Section section : sections) {
           	List<Row> rows = section.getRows();
           	for (Row row : rows) {
           		List<Field> rowFields = row.getFields();
           		for (Field field : rowFields) {
           			if(field.getFieldType().equalsIgnoreCase(Field.CONTAINER)) {
           				List<Row> containerRows = field.getContainerRows();
           				for(Row containerRow : containerRows) {
           					List<Field> containerRowFields = containerRow.getFields();
           					for (Field containerRowField : containerRowFields) {
           						restriction = inquiryRestrictions.getFieldRestriction(containerRowField.getPropertyName());
       	            			if(restriction.isMasked() || restriction.isPartiallyMasked()) {
       	            				containerRowField.setSecure(false);
       	            			}
           					}
           				}
           			}
           			restriction = inquiryRestrictions.getFieldRestriction(field.getPropertyName());
            		if(restriction.isMasked() || restriction.isPartiallyMasked()) {
            			field.setSecure(false);
            		}
           		}
           	}
           }
       }

       return sections;
}