Example usage for org.apache.commons.lang StringUtils remove

List of usage examples for org.apache.commons.lang StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils remove.

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:org.mule.modules.quickbooks.online.api.DefaultQuickBooksOnlineClient.java

/**
* Parse the HTML information for BlueDotMenu
* @param credentials OAuth credentials/*from   w ww  . ja  va  2s.  co m*/
* @param regex Regex for extracting the information
*              <p>The regex has to extract the information in this way:</p>
*              <p>match[0]: appId,appName,contextArea</p>
*              <p>match[1]: logoImageUrl</p>
*              <p>The method will split the application information to generate the @link{AppMenuInformation} object</p>
* @return List with connected apps information
*/
public BlueDotMenu getBlueDotInformation(OAuthCredentials credentials, String regex) {
    String blueDotInformation = (String) getBlueDotMenu(credentials);
    List<AppMenuInformation> menuInformationList = new ArrayList<AppMenuInformation>();
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(blueDotInformation);
    while (matcher.find()) {
        AppMenuInformation info = new AppMenuInformation();
        String[] parameters = StringUtils.split(matcher.group(1), ",");
        info.setAppId(StringUtils.trim(StringUtils.remove(parameters[0], "'")));
        info.setName(StringUtils.trim(StringUtils.remove(parameters[1], "'")));
        info.setContentArea(StringUtils.trim(StringUtils.remove(parameters[2], "'")));
        info.setImageUrl(StringUtils.trim(matcher.group(2)));

        menuInformationList.add(info);
    }

    return new BlueDotMenu(menuInformationList, blueDotInformation);
}

From source file:org.mule.modules.quickbooks.windows.api.DefaultQuickBooksWindowsClient.java

/**
 * Parse the HTML information for BlueDotMenu
 * @param credentials OAuth credentials/* w  w  w .j  a v  a  2s.c  o m*/
 * @param regex Regex for extracting the information
 *              <p>The regex has to extract the information in this way:</p>
 *              <p>match[0]: appId,appName,contextArea</p>
 *              <p>match[1]: logoImageUrl</p>
 *              <p>The method will split the application information to generate the @link{AppMenuInformation} object</p>
 * @return List with connected apps information
 */
@Override
public BlueDotMenu getBlueDotInformation(OAuthCredentials credentials, String regex) {
    String blueDotInformation = (String) getBlueDotMenu(credentials);
    List<AppMenuInformation> menuInformationList = new ArrayList<AppMenuInformation>();
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(blueDotInformation);
    while (matcher.find()) {
        AppMenuInformation info = new AppMenuInformation();
        String[] parameters = StringUtils.split(matcher.group(1), ",");
        info.setAppId(StringUtils.trim(StringUtils.remove(parameters[0], "'")));
        info.setName(StringUtils.trim(StringUtils.remove(parameters[1], "'")));
        info.setContentArea(StringUtils.trim(StringUtils.remove(parameters[2], "'")));
        info.setImageUrl(StringUtils.trim(matcher.group(2)));

        menuInformationList.add(info);
    }

    return new BlueDotMenu(menuInformationList, blueDotInformation);
}

From source file:org.nekorp.workflow.desktop.view.binding.MonedaBindableJTextField.java

@Override
public Object getModelValue() {
    try {//from  w w  w. j  a  v a  2 s  .c  om
        return MonedaVB.valueOf(this.getText());
    } catch (IllegalArgumentException e) {
        String value = this.getText();
        int indexPoint = StringUtils.indexOf(value, ".");
        if (indexPoint == -1) {
            throw e;
        } else {
            if (indexPoint + 1 == value.length()) {
                value = StringUtils.remove(value, '.');
            } else {
                value = StringUtils.substring(value, 0, indexPoint + 3);
            }
        }
        return MonedaVB.valueOf(value);
    }
}

From source file:org.nuxeo.ecm.ui.web.auth.digest.DigestAuthenticator.java

public static Map<String, String> splitParameters(String auth) {
    Map<String, String> map = new HashMap<>();
    try (CSVParser reader = new CSVParser(new StringReader(auth), CSVFormat.DEFAULT)) {
        Iterator<CSVRecord> iterator = reader.iterator();
        if (iterator.hasNext()) {
            CSVRecord record = iterator.next();
            for (String itemPairStr : record) {
                itemPairStr = StringUtils.remove(itemPairStr, QUOTE);
                String[] parts = itemPairStr.split(EQUAL_SEPARATOR, 2);
                if (parts == null) {
                    continue;
                } else {
                    map.put(parts[0].trim(), parts[1].trim());
                }//from  w w w .java 2s  .  c  om
            }
        }
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
    return map;
}

From source file:org.objectstyle.wolips.ruleeditor.model.RightHandSide.java

private Object parseValueString(String value) {
    value = StringUtils.remove(value, "\"");

    // When its an Array
    if (value.startsWith("(")) {
        value = StringUtils.substring(value, 1, value.length() - 1);

        String[] arrayComponents = Pattern.compile(",").split(value);

        ArrayList<Object> array = new ArrayList<Object>();

        for (String expression : arrayComponents) {
            expression = expression.trim();

            if ("".equals(expression)) {
                continue;
            }//from  ww  w. ja  v a 2 s  .c o m

            array.add(parseValueString(expression));
        }

        return array;
    }
    // When its a Dictionary
    else if (value.startsWith("{")) {
        Map<String, Object> dictionary = new HashMap<String, Object>();

        value = StringUtils.substring(value, 1, value.lastIndexOf(";"));

        String[] dictionaryComponents = Pattern.compile(";").split(value);

        for (String expression : dictionaryComponents) {
            String key = expression.substring(0, expression.indexOf("=")).trim();

            Object dictionaryValue = parseValueString(
                    expression.substring(expression.indexOf("=") + 1, expression.length()).trim());

            dictionary.put(key, dictionaryValue);
        }
        return dictionary;
    }

    // So its a String
    return value;
}

From source file:org.ojbc.processor.person.query.IncidentReportRequestProcessor.java

public String invokeRequest(DetailsRequest incidentReportRequest, String federatedQueryID, Element samlToken)
        throws Exception {
    if (allowQueriesWithoutSAMLToken) {
        if (samlToken == null) {
            //Add SAML token to request call
            samlToken = SAMLTokenUtils.createStaticAssertionAsElement(
                    "https://idp.ojbc-local.org:9443/idp/shibboleth",
                    SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS,
                    SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1, true, true, null);

        }/*from   ww  w .j av a  2  s  .  c  om*/
    }

    if (samlToken == null) {
        throw new Exception("No SAML token provided. Unable to perform query.");
    }

    //The details request object does not accommodate an incident category code required by the Spillman system
    //The XSLT will create an Incident ID like this: {IncidentCategoryCode}IncidentID
    //Thus for non-spillman entities, we remove the incident category code and enclosing curly braces prior to calling
    //those systems.  
    String incidentCategoryCode = "";

    log.debug("Incident ID from web portal: " + incidentReportRequest.getIdentificationID());
    log.debug("Incident Source Text from web portal: " + incidentReportRequest.getIdentificationSourceText());

    if (incidentReportRequest.getIdentificationSourceText().equals(
            "{http://ojbc.org/Services/WSDL/IncidentReportRequestService/1.0}SubmitIncidentIdentiferIncidentReportRequest-DPS")) {
        if (incidentReportRequest.getIdentificationID().startsWith("{Citation}")) {
            incidentCategoryCode = "Citation";
        } else if (incidentReportRequest.getIdentificationID().startsWith("{Law}")) {
            incidentCategoryCode = "Law";
        } else if (incidentReportRequest.getIdentificationID().startsWith("{Warning}")) {
            incidentCategoryCode = "Warning";
        } else {
            throw new IllegalStateException("Incident Category Code not specified.  It is set to: "
                    + incidentReportRequest.getIdentificationID());
        }
    }

    String incidentIDCategoryCode = StringUtils.substringBetween(incidentReportRequest.getIdentificationID(),
            "{", "}");
    String incidentIDwithCategoryCodeRemoved = StringUtils.remove(incidentReportRequest.getIdentificationID(),
            "{" + incidentIDCategoryCode + "}");

    //POJO to XML Request
    String personToIncidentRequestPayload = RequestMessageBuilderUtilities.createIncidentReportRequest(
            incidentIDwithCategoryCodeRemoved, incidentReportRequest.getIdentificationSourceText(),
            incidentCategoryCode);

    //Create exchange
    Exchange senderExchange = new DefaultExchange(camelContext, ExchangePattern.InOnly);

    //Set exchange body to XML Request message
    senderExchange.getIn().setBody(personToIncidentRequestPayload);

    //Set reply to and WS-Addressing message ID
    senderExchange.getIn().setHeader("federatedQueryRequestGUID", federatedQueryID);
    senderExchange.getIn().setHeader("WSAddressingReplyTo", this.getReplyToAddress());

    //Set the token header so that CXF can retrieve this on the outbound call
    String tokenID = senderExchange.getExchangeId();
    senderExchange.getIn().setHeader("tokenID", tokenID);
    OJBSamlMap.putToken(tokenID, samlToken);

    incidentReportRequestMessageProcessor.sendResponseMessage(camelContext, senderExchange);

    //Put message ID and "noResponse" place holder.  
    putRequestInMap(federatedQueryID);

    String response = pollMap(federatedQueryID);

    if (response.length() > 500) {
        log.debug("Here is the response (truncated): " + response.substring(0, 500));
    } else {
        log.debug("Here is the response: " + response);
    }

    //return response here
    return response;
}

From source file:org.ojbc.util.statemanager.LastUpdateFileManager.java

/**
 * This constructure receives the properties file location from Spring and will set the 
 * value of the lastUpdateDate/* w  w  w. j a  v  a  2s .c om*/
 * 
 * @param configurationFileLocationArgument
 */
public LastUpdateFileManager(String configurationFileLocationArgument, String lastUpdateDatePattern)
        throws Exception {
    LAST_UPDATE_DATE_PATTERN_QUERY = lastUpdateDatePattern;
    //Set the location of the properties file
    configurationFileLocation = configurationFileLocationArgument;

    //Create both the query and record set data format
    queryFormat = new SimpleDateFormat(LAST_UPDATE_DATE_PATTERN_QUERY);

    //If last update date is not set, read from file      
    if (lastUpdateDate == null) {
        // Read properties file.
        Properties properties = new Properties();
        properties.load(new FileInputStream(configurationFileLocation));

        //This file has only one property: lastDatabaseRecordProcessedDateTime    
        String lastUpdateString = properties.getProperty("lastDatabaseRecordProcessedDateTime");

        //The property write escapes the colons with a backslash, remove it here for the queries
        StringUtils.remove(lastUpdateString, "\\");

        //Set the last update date
        lastUpdateDate = queryFormat.parse(lastUpdateString);
    }
}

From source file:org.openbravo.dal.service.OBDao.java

/**
 * Parses the string of comma separated id's to return a List with the BaseOBObjects of the given
 * class. If there is an invalid id a null value is added to the List.
 * /*from   w ww  . ja  v  a 2s.co m*/
 * @param t
 *          class of the BaseOBObject the id's belong to
 * @param _IDs
 *          String containing the comma separated list of id's
 * @return a List object containing the parsed OBObjects
 */
public static <T extends BaseOBObject> List<T> getOBObjectListFromString(Class<T> t, String _IDs) {
    String strBaseOBOBjectIDs = _IDs;
    final List<T> baseOBObjectList = new ArrayList<T>();
    if (strBaseOBOBjectIDs.startsWith("(")) {
        strBaseOBOBjectIDs = strBaseOBOBjectIDs.substring(1, strBaseOBOBjectIDs.length() - 1);
    }
    if (!strBaseOBOBjectIDs.equals("")) {
        strBaseOBOBjectIDs = StringUtils.remove(strBaseOBOBjectIDs, "'");
        StringTokenizer st = new StringTokenizer(strBaseOBOBjectIDs, ",", false);
        while (st.hasMoreTokens()) {
            String strBaseOBObjectID = st.nextToken().trim();
            baseOBObjectList.add(OBDal.getInstance().get(t, strBaseOBObjectID));
        }
    }
    return baseOBObjectList;
}

From source file:org.opencastproject.adminui.endpoint.AbstractEventEndpoint.java

@GET
@Path("{eventId}/workflows/{workflowId}")
@Produces(MediaType.APPLICATION_JSON)//from w  w w . jav  a  2  s .co  m
@RestQuery(name = "geteventworkflow", description = "Returns all the data related to the single workflow tab in the event details modal as JSON", returnDescription = "All the data related to the event singe workflow tab as JSON", pathParameters = {
        @RestParameter(name = "eventId", description = "The event id", isRequired = true, type = RestParameter.Type.STRING),
        @RestParameter(name = "workflowId", description = "The workflow id", isRequired = true, type = RestParameter.Type.STRING) }, reponses = {
                @RestResponse(description = "Returns all the data related to the event single workflow tab as JSON", responseCode = HttpServletResponse.SC_OK),
                @RestResponse(description = "Unable to parse workflowId", responseCode = HttpServletResponse.SC_BAD_REQUEST),
                @RestResponse(description = "No event with this identifier was found.", responseCode = HttpServletResponse.SC_NOT_FOUND) })
public Response getEventWorkflow(@PathParam("eventId") String eventId,
        @PathParam("workflowId") String workflowId)
        throws WorkflowDatabaseException, JobEndpointException, SearchIndexException {
    Opt<Event> optEvent = getEvent(eventId);
    if (optEvent.isNone())
        return notFound("Cannot find an event with id '%s'.", eventId);

    long workflowInstanceId;
    try {
        workflowId = StringUtils.remove(workflowId, ".json");
        workflowInstanceId = Long.parseLong(workflowId);
    } catch (Exception e) {
        logger.warn("Unable to parse workflow id {}", workflowId);
        return RestUtil.R.badRequest();
    }

    try {
        return okJson(getJobService().getTasksAsJSON(workflowInstanceId));
    } catch (NotFoundException e) {
        return notFound("Cannot find workflow  %s", workflowId);
    }
}

From source file:org.opencommercesearch.Utils.java

private static Date parseDate(String value, DateMathParser dmp) throws ParseException {
    if (SolrDatePattern.matcher(value).find()) {
        return dmp.parseMath(StringUtils.remove(value, NOW));
    } else {/*w  w w  . j  a  v  a  2  s .c  om*/
        return iso8601Formatter.parse(value);
    }
}