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

The following examples show how to use org.apache.commons.lang.StringUtils#substringAfter() . 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: PerformLookupComponent.java    From rice with Educational Community License v2.0 6 votes vote down vote up
protected String getBusinessObjectClassName(Document dom, Element configElement, EDLContext edlContext) {
	String userAction = edlContext.getUserAction().getAction();
	String lookupField = StringUtils.substringAfter(userAction, ".");
	if (StringUtils.isBlank(lookupField)) {
		LOG.error("Cannot find lookup field parameters definition for field " + lookupField);
		return null;
	}

       XPath xPath = edlContext.getXpath();
       try {
		String businessObjectClassName = xPath.evaluate("//fieldDef[@name='" + lookupField + "']/lookup/businessObjectClassName", dom);
		return businessObjectClassName;
	} catch (XPathExpressionException e) {
		throw new WorkflowRuntimeException(e);
	}
}
 
Example 2
Source File: IRtransGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Parses the and add binding config.
 *
 * @param item the item
 * @param bindingConfigs the binding configs
 * @throws BindingConfigParseException the binding config parse exception
 */
private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException {

    String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
    String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");

    IRtransBindingConfig newConfig = new IRtransBindingConfig();
    parseBindingConfig(newConfig, item, bindingConfig);
    addBindingConfig(item, newConfig);

    while (StringUtils.isNotBlank(bindingConfigTail)) {
        bindingConfig = StringUtils.substringBefore(bindingConfigTail, ",");
        bindingConfig = StringUtils.strip(bindingConfig);
        bindingConfigTail = StringUtils.substringAfter(bindingConfig, ",");
        parseBindingConfig(newConfig, item, bindingConfig);
        addBindingConfig(item, newConfig);
    }
}
 
Example 3
Source File: ResourceUtils.java    From elasticsearch-pool with Apache License 2.0 6 votes vote down vote up
private static URL[] load3(String locationPattern) throws MalformedURLException {
    if (StringUtils.contains(locationPattern, PunctuationConstants.STAR.getValue())
            || StringUtils.contains(locationPattern, PunctuationConstants.QUESTION_MARK.getValue())) {
        String directoryPath = StringUtils.substringBeforeLast(locationPattern,
                ResourceConstants.FOLDER_SEPARATOR.getValue());
        directoryPath = StringUtils.substringAfter(directoryPath, ResourceConstants.FILE_URL_PREFIX.getValue());
        File directory = new File(directoryPath);
        String filePattern = StringUtils.substringAfter(locationPattern,
                ResourceConstants.FOLDER_SEPARATOR.getValue());
        while (filePattern.contains(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
            filePattern = StringUtils.substringAfter(filePattern, ResourceConstants.FOLDER_SEPARATOR.getValue());
        }

        Set<URL> result = new LinkedHashSet<URL>(16);
        Iterator<File> iterator = FileUtils.iterateFiles(directory, new WildcardFileFilter(filePattern), null);
        while (iterator.hasNext()) {
            result.add(iterator.next().toURI().toURL());
        }

        return result.toArray(new URL[result.size()]);
    } else {
        // a single resource with the given name
        URL url = new URL(locationPattern);
        return new File(url.getFile()).exists() ? new URL[] { url } : null;
    }
}
 
Example 4
Source File: AccountingLineViewField.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the value from the accounting line to display as the field value
 *
 * @param accountingLine the accounting line to get the value from
 * @return the value to display for the dynamic name label
 */
protected String getDynamicNameLabelDisplayedValue(AccountingLine accountingLine) {
    String dynamicLabelProperty = definition.getDynamicLabelProperty();
    Object value = accountingLine;
    while (!ObjectUtils.isNull(value) && dynamicLabelProperty.indexOf('.') > -1) {
        String currentProperty = StringUtils.substringBefore(dynamicLabelProperty, ".");
        dynamicLabelProperty = StringUtils.substringAfter(dynamicLabelProperty, ".");
        if (value instanceof PersistableBusinessObject) {
            if (!nonRefreshedPropertyList.contains(currentProperty)){
                ((PersistableBusinessObject) value).refreshReferenceObject(currentProperty);
            }
        }
        value = ObjectUtils.getPropertyValue(value, currentProperty);
    }
    if (!ObjectUtils.isNull(value)) {
        value = ObjectUtils.getPropertyValue(value, dynamicLabelProperty);
        if (value != null) {
            return value.toString();
        }
    }
    return null;
}
 
Example 5
Source File: ConfigDispatcherOSGiTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private String getLastModifiedValueForPoperty(String path, String property) {
    // This method will return null, if there are no files in the directory.
    String value = null;

    File file = getLastModifiedFileFromDir(path);
    if (file == null) {
        return null;
    }
    try (FileInputStream fileInputStream = new FileInputStream(file)) {
        List<String> lines = IOUtils.readLines(fileInputStream);
        for (String line : lines) {
            if (line.contains(property + "=")) {
                value = StringUtils.substringAfter(line, property + "=");
            }
        }
    } catch (IOException e) {
        throw new IllegalArgumentException(
                "An exception " + e + " was thrown, while reading from file " + file.getPath(), e);
    }

    return value;
}
 
Example 6
Source File: FileDescriptor.java    From APM with Apache License 2.0 5 votes vote down vote up
private static String getPathFromOriginalFileName(String savePath, String originalFileName) {
  if (originalFileName.contains("/")) {
    String subPath = StringUtils.substringBeforeLast(originalFileName, "/");
    if (subPath.startsWith(savePath)) {
      subPath = StringUtils.substringAfter(subPath, savePath);
    }
    return savePath + (subPath.startsWith("/") ? subPath : "/" + subPath);
  }
  return savePath;
}
 
Example 7
Source File: DataTools.java    From util4j with Apache License 2.0 5 votes vote down vote up
/**
 * 截取以什么开头的数据
 * @param data
 * @param startHexStr
 * @return
 * @throws UnsupportedEncodingException
 */
public String[] SubHexArraysByStr(byte[] data,String startStr) throws UnsupportedEncodingException
{
	if(data==null||data.length<=0)
	{
		System.out.println("data数据无效!");
		return null;
	}
	String[] result=null;
	//转换原数据
	String[] hexarray=byteArrayToHexArray(data);
	String hexstr=Arrays.toString(hexarray);
	hexstr=StringUtils.substringBetween(hexstr, "[", "]").replaceAll("\\s", "");//原数据字符串去括号空格
	////转换匹配参数数据
	byte[] startArray=startStr.getBytes("utf-8");//转换为字节
	String[] startHex=byteArrayToHexArray(startArray);//转换为hex字符数组
	String startHexStr=Arrays.toString(startHex);//转换为hex字符串
	startHexStr=StringUtils.substringBetween(startHexStr, "[", "]").replaceAll("\\s", "");//去括号空格
	String resultHex=StringUtils.substringAfter(hexstr, startHexStr);
	if(resultHex==null)
	{
		//System.out.println("注意:截取内容为空,无数据!");
		return null;
	}
	result=StringUtils.split(resultHex, ',');//重组为hexstr数组
	return result;
}
 
Example 8
Source File: MapSafeConfigReader.java    From ymate-platform-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> getMap(String keyHead) {
    Map<String, String> _returnValue = new HashMap<String, String>();
    if (StringUtils.isNotBlank(keyHead)) {
        for (Map.Entry<String, ?> _entry : __innerMap.entrySet()) {
            if (StringUtils.startsWith(_entry.getKey(), keyHead)) {
                String _key = StringUtils.substringAfter(_entry.getKey(), keyHead);
                _returnValue.put(_key, StringUtils.trimToEmpty(BlurObject.bind(_entry.getValue()).toStringValue()));
            }
        }
    }
    return _returnValue;
}
 
Example 9
Source File: ButtonVirtualDatapointHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
    HmDatapoint vdp = getVirtualDatapoint(dp.getChannel());
    if (MiscUtils.isTrueValue(dp.getValue())) {
        String pressType = StringUtils.substringAfter(dp.getName(), "_");
        switch (pressType) {
            case "SHORT":
                if (dp.getValue() == null || !dp.getValue().equals(dp.getPreviousValue())) {
                    vdp.setValue(CommonTriggerEvents.SHORT_PRESSED);
                } else {
                    // two (or more) PRESS_SHORT events were received
                    // within AbstractHomematicGateway#DEFAULT_DISABLE_DELAY seconds
                    vdp.setValue(CommonTriggerEvents.DOUBLE_PRESSED);
                }
                break;
            case "LONG":
                vdp.setValue(CommonTriggerEvents.LONG_PRESSED);
                break;
            case "LONG_RELEASE":
            case "CONT":
                vdp.setValue(null);
                break;
            default:
                vdp.setValue(null);
                logger.warn("Unexpected vaule '{}' for PRESS virtual datapoint", pressType);
        }
    } else {
        vdp.setValue(null);
    }
}
 
Example 10
Source File: StaticResourcesProductionFilter.java    From ServiceCutter with Apache License 2.0 5 votes vote down vote up
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String contextPath = ((HttpServletRequest) request).getContextPath();
    String requestURI = httpRequest.getRequestURI();
    requestURI = StringUtils.substringAfter(requestURI, contextPath);
    if (StringUtils.equals("/", requestURI)) {
        requestURI = "/index.html";
    }
    String newURI = "/dist" + requestURI;
    request.getRequestDispatcher(newURI).forward(request, response);
}
 
Example 11
Source File: AccessProtectedResourceFlowHttpTest.java    From oxAuth with MIT License 5 votes vote down vote up
@Test(dependsOnMethods = {"requestRptAndGetNeedsInfo"})
@Parameters({"umaPatClientId"})
public void claimsGathering(String umaPatClientId) throws Exception {
    String gatheringUrl = needInfo.buildClaimsGatheringUrl(umaPatClientId, this.metadata.getClaimsInteractionEndpoint());

    System.out.println(gatheringUrl);
    System.out.println();
    try {
        startSelenium();
        navigateToAuhorizationUrl(driver, gatheringUrl);
        System.out.println(driver.getCurrentUrl());

        driver.findElement(By.id("loginForm:country")).sendKeys("US");
        driver.findElement(By.id("loginForm:gather")).click();

        Thread.sleep(1000);
        System.out.println(driver.getCurrentUrl());

        driver.findElement(By.id("loginForm:city")).sendKeys("NY");
        driver.findElement(By.id("loginForm:gather")).click();
        Thread.sleep(1200);
        // Finally after claims-redirect flow user gets redirect with new ticket
        // Sample: https://client.example.com/cb?ticket=e8e7bc0b-75de-4939-a9b1-2425dab3d5ec
        System.out.println(driver.getCurrentUrl());
        claimsGatheringTicket = StringUtils.substringAfter(driver.getCurrentUrl(), "ticket=");
    } finally {
        stopSelenium();
    }
}
 
Example 12
Source File: DefaultRequestMappingParser.java    From ymate-platform-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * @param partStr 参数段
 * @return 返回去掉首尾'/'字符的串
 */
private String __doFixMappingPart(String partStr) {
    partStr = StringUtils.trimToEmpty(partStr);
    if (StringUtils.startsWith(partStr, "/")) {
        partStr = StringUtils.substringAfter(partStr, "/");
    }
    if (StringUtils.endsWith(partStr, "/")) {
        partStr = StringUtils.substringBeforeLast(partStr, "/");
    }
    return partStr;
}
 
Example 13
Source File: MaintainableXMLConversionServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public String transformMaintainableXML(String xml) {
    String beginning = StringUtils.substringBefore(xml, "<" + OLD_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">");
       String oldMaintainableObjectXML = StringUtils.substringBetween(xml, "<" + OLD_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">", "</" + OLD_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">");
       String newMaintainableObjectXML = StringUtils.substringBetween(xml, "<" + NEW_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">", "</" + NEW_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">");
       String ending = StringUtils.substringAfter(xml, "</" + NEW_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">");

       String convertedOldMaintainableObjectXML = transformSection(oldMaintainableObjectXML);
       String convertedNewMaintainableObjectXML = transformSection(newMaintainableObjectXML);

       String convertedXML =  beginning +
           "<" + OLD_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">" + convertedOldMaintainableObjectXML +  "</" + OLD_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">" +
           "<" + NEW_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">" + convertedNewMaintainableObjectXML +  "</" + NEW_MAINTAINABLE_OBJECT_ELEMENT_NAME + ">" +
           ending;
       return convertedXML;
}
 
Example 14
Source File: EditExecutionCourseDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected String separateLabel(ActionForm form, HttpServletRequest request, String property, String id, String name) {

        DynaActionForm executionCourseForm = (DynaActionForm) form;

        // the value returned to action is a string name~externalId
        String object = (String) executionCourseForm.get(property);
        if (object == null || object.length() <= 0) {
            object = (String) request.getAttribute(property);
            if (object == null) {
                object = request.getParameter(property);
            }
        }

        String objectId = null;
        String objectName = null;
        if (object != null && object.length() > 0 && object.indexOf("~") > 0) {
            executionCourseForm.set(property, object);
            request.setAttribute(property, object);

            objectId = StringUtils.substringAfter(object, "~");
            objectName = object.substring(0, object.indexOf("~"));

            request.setAttribute(name, objectName);
            request.setAttribute(id, objectId);
        }

        return objectId;
    }
 
Example 15
Source File: SchoolClass.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Object getEditablePartOfName() {
    final DegreeCurricularPlan degreeCurricularPlan = getExecutionDegree().getDegreeCurricularPlan();
    final Degree degree = degreeCurricularPlan.getDegree();
    return StringUtils.substringAfter(getNome(), degree.constructSchoolClassPrefix(getAnoCurricular()));
}
 
Example 16
Source File: FileUploadServlet.java    From symphonyx with Apache License 2.0 4 votes vote down vote up
@Override
public void doGet(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {
    if (QN_ENABLED) {
        return;
    }

    final LatkeBeanManager beanManager = Lifecycle.getBeanManager();
    final UserQueryService userQueryService = beanManager.getReference(UserQueryService.class);
    final UserMgmtService userMgmtService = beanManager.getReference(UserMgmtService.class);
    final OptionQueryService optionQueryService = beanManager.getReference(OptionQueryService.class);

    try {
        final JSONObject option = optionQueryService.getOption(Option.ID_C_MISC_ALLOW_ANONYMOUS_VIEW);
        if (!"0".equals(option.optString(Option.OPTION_VALUE))) {
            if (null == userQueryService.getCurrentUser(req) && !userMgmtService.tryLogInWithCookie(req, resp)) {
                final String referer = req.getHeader("Referer");
                if (!StringUtils.contains(referer, "fangstar.net")) {
                    final String authorization = req.getHeader("Authorization");

                    LOGGER.debug("Referer [" + referer + "], Authorization [" + authorization + "]");

                    if (!StringUtils.contains(authorization, "Basic ")) {
                        resp.sendError(HttpServletResponse.SC_FORBIDDEN);

                        return;
                    } else {
                        String usernamePwd = StringUtils.substringAfter(authorization, "Basic ");
                        usernamePwd = Base64.decodeToString(usernamePwd);

                        final String username = usernamePwd.split(":")[0];
                        final String password = usernamePwd.split(":")[1];

                        if (!StringUtils.equals(username, Symphonys.get("http.basic.auth.username"))
                                || !StringUtils.equals(password, Symphonys.get("http.basic.auth.password"))) {
                            resp.sendError(HttpServletResponse.SC_FORBIDDEN);

                            return;
                        }
                    }
                }
            }
        }
    } catch (final Exception e) {
        LOGGER.log(Level.ERROR, "Gets file failed", e);

        resp.sendError(HttpServletResponse.SC_FORBIDDEN);

        return;
    }

    final String uri = req.getRequestURI();
    String key = uri.substring("/upload/".length());
    key = StringUtils.substringBeforeLast(key, "-64.jpg"); // Erase Qiniu template
    key = StringUtils.substringBeforeLast(key, "-260.jpg"); // Erase Qiniu template

    String path = UPLOAD_DIR + key;

    if (!FileUtil.isExistingFile(new File(path))) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);

        return;
    }

    final byte[] data = IOUtils.toByteArray(new FileInputStream(path));

    final String ifNoneMatch = req.getHeader("If-None-Match");
    final String etag = "\"" + MD5.hash(new String(data)) + "\"";

    resp.addHeader("Cache-Control", "public, max-age=31536000");
    resp.addHeader("ETag", etag);
    resp.setHeader("Server", "Latke Static Server (v" + SymphonyServletListener.VERSION + ")");

    if (etag.equals(ifNoneMatch)) {
        resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);

        return;
    }

    final OutputStream output = resp.getOutputStream();
    IOUtils.write(data, output);
    output.flush();

    IOUtils.closeQuietly(output);
}
 
Example 17
Source File: HiveAvroToOrcConverterTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
/***
 * Test nested DDL and DML generation
 * @throws IOException
 */
@Test
public void testNestedSchemaDDLandDML() throws Exception {
  String dbName = "testdb";
  String tableName = "testtable";
  String tableSdLoc = "/tmp/testtable";

  this.hiveMetastoreTestUtils.getLocalMetastoreClient().dropDatabase(dbName, false, true, true);

  Table table = this.hiveMetastoreTestUtils.createTestAvroTable(dbName, tableName, tableSdLoc, Optional.<String> absent());
  Schema schema = ConversionHiveTestUtils.readSchemaFromJsonFile(resourceDir, "recordWithinRecordWithinRecord_nested.json");
  WorkUnitState wus = ConversionHiveTestUtils.createWus(dbName, tableName, 0);
  wus.getJobState().setProp("orc.table.flatten.schema", "false");

  try (HiveAvroToNestedOrcConverter converter = new HiveAvroToNestedOrcConverter();) {

    Config config = ConfigFactory.parseMap(ImmutableMap.<String, String> builder()
        .put("destinationFormats", "nestedOrc")
        .put("nestedOrc.destination.tableName","testtable_orc_nested")
        .put("nestedOrc.destination.dbName",dbName)
        .put("nestedOrc.destination.dataPath","file:/tmp/testtable_orc_nested")
        .build());

    ConvertibleHiveDataset cd = ConvertibleHiveDatasetTest.createTestConvertibleDataset(config);

    List<QueryBasedHiveConversionEntity> conversionEntities =
        Lists.newArrayList(converter.convertRecord(converter.convertSchema(schema, wus), new QueryBasedHiveConversionEntity(cd , new SchemaAwareHiveTable(table, schema)), wus));

    Assert.assertEquals(conversionEntities.size(), 1, "Only one query entity should be returned");

    QueryBasedHiveConversionEntity queryBasedHiveConversionEntity = conversionEntities.get(0);
    List<String> queries = queryBasedHiveConversionEntity.getQueries();

    Assert.assertEquals(queries.size(), 4, "4 DDL and one DML query should be returned");

    // Ignoring part before first bracket in DDL and 'select' clause in DML because staging table has
    // .. a random name component
    String actualDDLQuery = StringUtils.substringAfter("(", queries.get(0).trim());
    String actualDMLQuery = StringUtils.substringAfter("SELECT", queries.get(0).trim());
    String expectedDDLQuery = StringUtils.substringAfter("(",
        ConversionHiveTestUtils.readQueryFromFile(resourceDir, "recordWithinRecordWithinRecord_nested.ddl"));
    String expectedDMLQuery = StringUtils.substringAfter("SELECT",
        ConversionHiveTestUtils.readQueryFromFile(resourceDir, "recordWithinRecordWithinRecord_nested.dml"));

    Assert.assertEquals(actualDDLQuery, expectedDDLQuery);
    Assert.assertEquals(actualDMLQuery, expectedDMLQuery);
  }
}
 
Example 18
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private String getXaXid(String queryString, String type) {
    return StringUtils.substringAfter(queryString, type);
}
 
Example 19
Source File: PriorYearAccountServiceImpl.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @see org.kuali.kfs.coa.service.PriorYearAccountService#addPriorYearAccountsFromParameter()
 */
public void addPriorYearAccountsFromParameter() {        
    /*
    Collection<String> accountsColl = new ArrayList<String>();
    accountsColl.add("BL-9923234");
    accountsColl.add("BL-1024600");
    accountsColl.add("0000000");
    accountsColl.add("BL-0000000");
    accountsColl.add("UA-2131401");      
    accountsColl.add("BA-6044909");
    accountsColl.add("BA-6044901");
    accountsColl.add("UA-7014960");
    */
    
    // clear cache so that batch job will be reading most up-to-date data from Account and PriorYearAccount tables
    persistenceServiceOjb.clearCache();

    String param = ChartApcParms.PRIOR_YEAR_ACCOUNTS_TO_BE_ADDED;
    Collection<String> accountsColl = parameterService.getParameterValuesAsString(AddPriorYearAccountsStep.class, param);
    Iterator<String> accountsIter = accountsColl.iterator();
    List<PriorYearAccount> priorAccounts = new ArrayList<PriorYearAccount>();
    int countError = 0;
    String errmsg = "";
    String failmsg = "Failed to add account ";
    
    LOG.info("Adding Accounts to Prior Year Account table from parameter " + param);
    reportWriterService.writeSubTitle("Accounts failed to be added to Prior Year Account table from parameter " + param);

    while (accountsIter.hasNext()) {
        // retrieve chart code and account number from parameter
        String accountStr = accountsIter.next();
        String chartCode = StringUtils.substringBefore(accountStr, "-");
        String accountNumber = StringUtils.substringAfter(accountStr, "-");       
        
        // if account format is invalid, report error      
        if (StringUtils.isEmpty(chartCode) || StringUtils.isEmpty(accountNumber)) {
            countError++;                
            errmsg = accountStr + " : invalid format. Correct account format: coaCode-accountNumber."; 
            reportWriterService.writeFormattedMessageLine("%s", errmsg);
            LOG.error(failmsg + errmsg);
            continue;
        }

        // check whether account exists, report error if not   
        // TODO switch back to accountService.getByPrimaryId when cache issue is fixed
        // not using accountService.getByPrimaryId here because there is an issue with Account cache
        // using businessObjectService instead will skip cache issue
        // Account account = accountService.getByPrimaryId(chartCode, accountNumber);
        Map<String, Object> keys = new HashMap<String, Object>(2);
        keys.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
        keys.put(KFSPropertyConstants.ACCOUNT_NUMBER, accountNumber);
        Account account = businessObjectService.findByPrimaryKey(Account.class, keys);
        
        if (ObjectUtils.isNull(account)) {
            countError++;
            errmsg = accountStr + " : doesn't exist in Account table."; 
            reportWriterService.writeFormattedMessageLine("%s", errmsg);
            LOG.error(failmsg + errmsg);
        }            
        // check whether account already exists in prior year, report error if yes 
        else if (ObjectUtils.isNotNull(getByPrimaryKey(chartCode, accountNumber))) {
            countError++;
            errmsg = accountStr + " : already exists in Prior Year Account table."; 
            reportWriterService.writeFormattedMessageLine("%s", errmsg);
            LOG.error(failmsg + errmsg);
        }
        // otherwise, add account to prior year table 
        else {
            PriorYearAccount priorAccount = new PriorYearAccount(account);
            businessObjectService.save(priorAccount);                
            priorAccounts.add(priorAccount);
            LOG.info("Successfully added account " + accountStr);
        }
    }
    
    String totalSuccessMsg = "Total number of accounts successfully added to prior year: " + priorAccounts.size();
    String totalFailureMsg = "Total number of accounts failed to be added to prior year: " + countError;
    reportWriterService.writeSubTitle("Accounts successfully added to Prior Year Account table:");
    reportWriterService.writeTable(priorAccounts, true, false);
    reportWriterService.writeStatisticLine("%s", totalSuccessMsg);
    reportWriterService.writeStatisticLine("%s", totalFailureMsg);
    LOG.info(totalSuccessMsg);
    LOG.info(totalFailureMsg);
}
 
Example 20
Source File: AnchorNameManager.java    From javadoc.chm with Apache License 2.0 4 votes vote down vote up
public static String replaceAnchor(String url) {
    String anchor = StringUtils.substringAfter(url, "#");
    if ("".equals(anchor)) return url;
    return StringUtils.substringBefore(url, "#") + "#" + getNewAnchorName(anchor);
}