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

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

Introduction

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

Prototype

public static String removeStart(String str, String remove) 

Source Link

Document

Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:info.archinnov.achilles.entity.manager.PersistenceManagerFactory.java

private String getGenericParameter(Type type) {
    ;
    return StringUtils.removeStart(((ParameterizedType) type).getActualTypeArguments()[0].toString(), "class ");
}

From source file:hudson.plugins.clearcase.ucm.model.ActivitiesDelta.java

private static Activity parseRightLine(String line) {
    String activityLine = StringUtils.removeStart(line, RIGHT_PREFIX);
    return buildActivity(activityLine);
}

From source file:com.wordnik.swagger.codegen.util.FileUtil.java

public static boolean copyJarResourcesRecursively(final File destDir, final JarURLConnection jarConnection)
        throws IOException {

    final JarFile jarFile = jarConnection.getJarFile();

    for (final Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) {
        final JarEntry entry = e.nextElement();
        if (entry.getName().startsWith(jarConnection.getEntryName())) {
            final String filename = StringUtils.removeStart(entry.getName(), //
                    jarConnection.getEntryName());

            final File f = new File(destDir, filename);
            if (!entry.isDirectory()) {
                final InputStream entryInputStream = jarFile.getInputStream(entry);
                if (!FileUtil.copyStream(entryInputStream, f)) {
                    return false;
                }//from  w  w  w  . j a  v a  2 s  .c  om
                entryInputStream.close();
            } else {
                if (!FileUtil.ensureDirectoryExists(f)) {
                    throw new IOException("Could not create directory: " + f.getAbsolutePath());
                }
            }
        }
    }
    return true;
}

From source file:it.TestCustomFields.java

@Test
public void importMulticheckboxesCustomFields() {
    final String customFieldName = "Multi";
    final String cid = StringUtils.removeStart(
            administration.customFields().addCustomField(MULTICHECKBOXES_CF_TYPE, customFieldName),
            FieldManager.CUSTOM_FIELD_PREFIX);
    administration.customFields().addOptions(cid, "Core", "Subsystem", "API", "UX");

    assertMultiCustomFields(customFieldName);
}

From source file:com.github.ipaas.ideploy.agent.handler.DownloadCodeHandlerTest.java

/**
 * ??,???,//  ww  w .  j  a va2  s .  co  m
 * 
 * @throws Exception
 */
@Test
public void downloadCodeTest() throws Exception {
    String usingRoot = "/www/apptemp/" + USING_VERSION;
    String doingRoot = "/www/apptemp/" + DOING_VERSION;
    DownloadCodeHandler downLoadHandler = new DownloadCodeHandler();
    File usingfile = new File(usingRoot);
    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }
    File doingFile = new File(doingRoot);
    if (doingFile.exists()) {
        FileUtils.forceDelete(doingFile);
    }

    String flowId = "flowIdNotNeed";
    String cmd = "cmdNotNeed";
    Integer hostStatus4New = 1;
    Integer updateAll = 1;
    Map<String, Object> firstDownLoadParams = new HashMap<String, Object>();
    firstDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    firstDownLoadParams.put("hostStatus", hostStatus4New);
    firstDownLoadParams.put("savePath", usingRoot);// ??
    firstDownLoadParams.put("updateAll", updateAll);
    downLoadHandler.execute(flowId, cmd, firstDownLoadParams, null);

    Assert.assertTrue(new File(usingRoot + "/update.txt").exists());

    Integer notUpdateAll = 2;
    Integer hostStatus4Old = 2;
    Map<String, Object> secondDownLoadParams = new HashMap<String, Object>();
    secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + DOING_VERSION);
    secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    secondDownLoadParams.put("hostStatus", hostStatus4Old);
    secondDownLoadParams.put("savePath", doingRoot);// ??
    secondDownLoadParams.put("updateAll", notUpdateAll);
    downLoadHandler.execute(flowId, cmd, secondDownLoadParams, null);
    File updateFile = new File(doingRoot + "/update.txt");

    Assert.assertTrue(updateFile.exists());

    // ?
    //String do
    List<String> updateList = FileUtils.readLines(updateFile);
    for (String str : updateList) {
        if (str.startsWith("+")) {
            Assert.assertTrue(
                    new File(doingRoot + "/code" + StringUtils.removeStart(str, "+").trim()).exists());
        } else if (str.startsWith("-")) {
            String f = usingRoot + "/code" + StringUtils.removeStart(str, "-").trim();
            Assert.assertTrue(new File(f).exists());
        }
    }

    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }
    if (doingFile.exists()) {
        FileUtils.forceDelete(doingFile);
    }
}

From source file:info.archinnov.achilles.entity.manager.PersistenceManagerFactory.java

private boolean isEventInterceptorInterface(Type type) {
    return (type instanceof ParameterizedType) && EventInterceptor.class.getName()
            .equals(StringUtils.removeStart(((ParameterizedType) type).getRawType().toString(), "interface "));
}

From source file:hudson.plugins.clearcase.history.HistoryEntry.java

public HistoryEntry normalize(String viewPath) {
    element = StringUtils.removeStart(element, viewPath);
    return this;
}

From source file:com.salesmanager.central.payment.PaymentModuleAction.java

public void prepare() throws Exception {

    Context ctx = (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
    Integer merchantid = ctx.getMerchantid();

    // Get everything related to payment
    ConfigurationRequest requestvo = new ConfigurationRequest(merchantid.intValue(), true, "MD_PAY_");
    MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
    ConfigurationResponse responsevo = mservice.getConfiguration(requestvo);
    List config = responsevo.getMerchantConfigurationList();

    if (config != null) {
        this.setConfigurationVo(responsevo);
        Iterator it = config.iterator();
        while (it.hasNext()) {

            MerchantConfiguration m = (MerchantConfiguration) it.next();

            String key = m.getConfigurationKey();
            if (key.equals(PaymentConstants.MODULE_PAYMENT_INDICATOR_NAME)) {// module
                // configured
                if (configurationModuleNames == null)
                    configurationModuleNames = new HashMap();
                configurationModuleNames.put(m.getConfigurationValue1(), m);
            }//from  w  w w  .j av a  2  s  .  co m

            if (key.contains(PaymentConstants.MODULE_PAYMENT_GATEWAY)) {// gateway
                // module configured
                if (configurationModuleGatewayNames == null)
                    configurationModuleGatewayNames = new HashMap();
                configurationModuleGatewayNames.put(m.getConfigurationModule(), m);
            }

        }
    }

    // get module name
    String pathnocontext = StringUtils.removeStart(super.getServletRequest().getRequestURI(),
            super.getServletRequest().getContextPath() + "/payment/");
    // pathnocontext is moduleid/dsiplay.action
    // retreive moduleid
    String moduleid = pathnocontext.substring(0, pathnocontext.indexOf("_"));
    this.setModuleName(moduleid);
    super.getServletRequest().setAttribute("paymentModule", moduleid);

    super.setPageTitle("module." + moduleid);

    if (this.getConfigurationModuleNames() != null
            && this.getConfigurationModuleNames().containsKey(moduleid)) {
        MerchantConfiguration conf = (MerchantConfiguration) this.getConfigurationModuleNames().get(moduleid);
        if (conf.getConfigurationValue1() != null && !conf.getConfigurationValue1().equals("")) {
            this.setCurrentModuleName(moduleid);
        }
        if (!StringUtils.isBlank(conf.getConfigurationValue()) && conf.getConfigurationValue().equals("true")) {
            this.setCurrentModuleEnabled("true");
        } else {
            this.setCurrentModuleEnabled("false");
        }
    }

    this.prepareModule();

}

From source file:info.magnolia.rendering.template.registry.ConfiguredTemplateDefinitionManager.java

protected String createId(Node templateDefinitionNode) throws RepositoryException {
    final String path = templateDefinitionNode.getPath();
    final String[] pathElements = path.split("/");
    final String moduleName = pathElements[2];
    return moduleName + ":" + StringUtils.removeStart(path, "/modules/" + moduleName + "/templates/");
}

From source file:com.neatresults.mgnltweaks.ui.field.FieldTypeSelectFieldFactory.java

@Override
public List<SelectFieldOptionDefinition> getSelectFieldOptionDefinition() {

    List<SelectFieldOptionDefinition> fields = new ArrayList<SelectFieldOptionDefinition>();
    try {//from   w  w w  .  j a va2  s.  c om
        if (registry.getClass().getDeclaredFields().length == 0) {
            // 5.4
            Collection<FieldTypeDefinition> defs = (Collection<FieldTypeDefinition>) registry.getClass()
                    .getMethod("getAllDefinitions").invoke(registry, null);
            for (FieldTypeDefinition fieldDef : defs) {
                if (fieldDef == null || fieldDef.getDefinitionClass() == null
                        || fieldDef.getDefinitionClass().getName() == null) {
                    System.out.println("field def is not valid: " + fieldDef);
                    continue;
                }
                SelectFieldOptionDefinition field = new SelectFieldOptionDefinition();
                String label = fieldDef.getDefinitionClass().getName();
                if (label.startsWith("com.neatresults.mgnltweaks")) {
                    label = StringUtils.replace(label, "com.neatresults.mgnltweaks.ui.field.", " NeatTweaks ");
                    label = StringUtils.removeEnd(label, "FieldFactory$Definition");
                }
                if (label.startsWith("info.magnolia")) {
                    label = StringUtils.replace(label, "info.magnolia.ui.form.field.definition.", " Default ");
                    label = StringUtils.removeStart(label, "info.magnolia.module.");
                    label = StringUtils.removeStart(label, "info.magnolia.");
                }
                field.setLabel(label);
                field.setName(definition.getName());
                field.setValue(fieldDef.getDefinitionClass().getName());
                fields.add(field);
            }
        } else {
            // 5.3
            Field registryField = registry.getClass().getDeclaredField("registry");
            registryField.setAccessible(true);
            RegistryMap<String, FieldTypeDefinitionProvider> providers = (RegistryMap<String, FieldTypeDefinitionProvider>) registryField
                    .get(registry);

            for (String id : providers.keySet()) {

                SelectFieldOptionDefinition field = new SelectFieldOptionDefinition();
                Class<? extends FieldDefinition> fieldDef = registry.get(id).getDefinitionClass();
                // directly defined label
                String label = id + " ("
                        + StringUtils.replaceOnce(fieldDef.getName(), "info.magnolia.module.", "i.m.m.") + ")";

                field.setLabel(label);
                field.setName(definition.getName());
                field.setValue(fieldDef.getName());
                fields.add(field);
            }
        }

    } catch (SecurityException | IllegalArgumentException | IllegalAccessException | RegistrationException
            | NoSuchFieldException | InvocationTargetException | NoSuchMethodException e) {
        log.error(e.getMessage(), e);
        SelectFieldOptionDefinition field = new SelectFieldOptionDefinition();
        field.setName(definition.getName());
        field.setLabel("It looks like an error has occured. Please contact admin or developers about it: "
                + e.getMessage());
        field.setValue(e.getMessage());
        fields.add(field);

    }
    return fields;
}