Example usage for org.apache.commons.lang3 StringUtils trim

List of usage examples for org.apache.commons.lang3 StringUtils trim

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trim.

Prototype

public static String trim(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null .

The String is trimmed using String#trim() .

Usage

From source file:com.ottogroup.bi.spqr.node.server.SPQRNodeServer.java

/**
 * Reads contents from {@link ApplicationRepositoryConfiguration referenced repository} and deploys them to given
 * {@link ActorRef deployment receiver}.
 * @param cfg/*from   w  w  w . java  2  s .  c om*/
 * @param jarDeploymentReceiverRef
 * @throws RequiredInputMissingException
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
protected ComponentRepository loadAndDeployApplicationRepository(final String repositoryPath)
        throws RequiredInputMissingException, JsonParseException, JsonMappingException, IOException {

    ////////////////////////////////////////////////////////////////////////////
    // validate provided input and ensure that folder exists
    if (StringUtils.isBlank(repositoryPath))
        throw new RequiredInputMissingException("Missing required input for parameter 'repositoryPath'");

    File repositoryFolder = new File(StringUtils.trim(repositoryPath));
    if (repositoryFolder == null || !repositoryFolder.isDirectory())
        throw new RequiredInputMissingException(
                "No repository found at provided folder '" + repositoryPath + "'");
    //
    ////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////

    final ComponentRepository library = new ComponentRepository();

    ////////////////////////////////////////////////////////////////////////////
    // find component repositories below repository folder 
    File[] repoFolders = repositoryFolder.listFiles();
    if (repoFolders == null || repoFolders.length < 1)
        return library;
    //
    ////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////
    // for each entry check if it is a folder and pass it on the library
    int folderCount = 0;
    int componentsCount = 0;
    for (File folder : repoFolders) {
        if (folder.isDirectory()) {
            try {
                logger.info("Processing folder '" + folder.getAbsolutePath() + "'");
                Map<String, ComponentDescriptor> descriptors = library
                        .addComponentFolder(folder.getAbsolutePath());
                componentsCount = componentsCount + descriptors.size();
                folderCount++;
            } catch (Exception e) {
                logger.error("Failed to add folder '" + folder.getAbsolutePath()
                        + "' to component repository. Error: " + e.getMessage());
            }
        }
    }
    //
    ////////////////////////////////////////////////////////////////////////////

    logger.info("Components deployment finished [repo=" + repositoryPath + ", componentFolders=" + folderCount
            + ", componets=" + componentsCount + "]");
    return library;
}

From source file:com.jeans.iservlet.action.admin.DataImportAction.java

/**
 * ?//  w w w.  j a  va2  s .  co  m
 * 
 * @return
 * @throws Exception
 */
@Action(value = "ci-import", results = { @Result(name = SUCCESS, type = "json", params = { "root", "results",
        "contentType", "text/plain", "encoding", "UTF-8" }) })
public String uploadCIData() throws Exception {
    if (!checkDataFile()) {
        return SUCCESS;
    }
    int hardCount = 0, softCount = 0;
    try (Workbook workBook = WorkbookFactory.create(data)) {
        Sheet hardSheet = workBook.getSheet("");
        Sheet softSheet = workBook.getSheet("");
        if (null == hardSheet || null == softSheet) {
            results.put("code", 4);
            results.put("tip", "????Sheet");
            return SUCCESS;
        }
        Company comp = getCurrentCompany();
        ExcelUtils.setNumberFormat("#");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyymm");
        // hardSheet: 1?015?160?
        int last = hardSheet.getLastRowNum();
        for (int rn = 1; rn <= last; rn++) {
            Row r = hardSheet.getRow(rn);
            // ??""???
            String flag = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(0, Row.RETURN_BLANK_AS_NULL)));
            // ???name?
            String name = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(3, Row.RETURN_BLANK_AS_NULL)));
            if (!"".equals(flag) || StringUtils.isBlank(name)) {
                continue;
            }
            Map<String, Object> hardware = new HashMap<String, Object>();
            hardware.put("company", comp);
            hardware.put("type", AssetConstants.HARDWARE_ASSET);
            hardware.put("name", name);
            hardware.put("code",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(1, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("catalog",
                    parseAssetCatalog(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(2, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.HARDWARE_ASSET));
            hardware.put("vendor",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(4, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("modelOrVersion",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(5, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("assetUsage",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(6, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("purchaseTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(7, Row.RETURN_BLANK_AS_NULL), sdf));
            try {
                double q = (double) ExcelUtils.getCellValue(r.getCell(8, Row.RETURN_BLANK_AS_NULL));
                if (q < 1) {
                    hardware.put("quantity", 1);
                } else {
                    hardware.put("quantity", (int) Math.round(q));
                }
            } catch (Exception e) {
                hardware.put("quantity", 1);
            }
            try {
                hardware.put("cost", BigDecimal
                        .valueOf((double) ExcelUtils.getCellValue(r.getCell(9, Row.RETURN_BLANK_AS_NULL))));
            } catch (Exception e) {
                hardware.put("cost", new BigDecimal(0));
            }
            hardware.put("state", AssetConstants.IDLE);
            hardware.put("sn",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(10, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("configuration",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(11, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("warranty", AssetConstants.IMPLIED_WARRANTY);
            hardware.put("location",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(12, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("ip",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(13, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("importance", AssetConstants.GENERAL_DEGREE);
            hardware.put("owner", null);
            hardware.put("comment",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(14, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("financialCode",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(15, Row.RETURN_BLANK_AS_NULL))));

            assetService.newAsset(hardware);
            hardCount++;
        }
        // softSheet: 1?012?130?
        last = softSheet.getLastRowNum();
        for (int rn = 1; rn <= last; rn++) {
            Row r = softSheet.getRow(rn);
            // ??""???
            String flag = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(0, Row.RETURN_BLANK_AS_NULL)));
            // ???name?
            String name = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(2, Row.RETURN_BLANK_AS_NULL)));
            if (!"".equals(flag) || StringUtils.isBlank(name)) {
                continue;
            }
            if (StringUtils.isBlank(name))
                continue;
            Map<String, Object> software = new HashMap<String, Object>();
            software.put("company", comp);
            software.put("type", AssetConstants.SOFTWARE_ASSET);
            software.put("name", name);
            software.put("catalog",
                    parseAssetCatalog(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(1, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.SOFTWARE_ASSET));
            software.put("vendor",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(3, Row.RETURN_BLANK_AS_NULL))));
            software.put("modelOrVersion",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(4, Row.RETURN_BLANK_AS_NULL))));
            try {
                double q = (double) ExcelUtils.getCellValue(r.getCell(5, Row.RETURN_BLANK_AS_NULL));
                if (q < 1) {
                    software.put("quantity", 1);
                } else {
                    software.put("quantity", (int) Math.round(q));
                }
            } catch (Exception e) {
                software.put("quantity", 1);
            }
            try {
                software.put("cost", BigDecimal
                        .valueOf((double) ExcelUtils.getCellValue(r.getCell(6, Row.RETURN_BLANK_AS_NULL))));
            } catch (Exception e) {
                software.put("cost", new BigDecimal(0));
            }
            software.put("purchaseTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(7, Row.RETURN_BLANK_AS_NULL), sdf));
            software.put("assetUsage",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(8, Row.RETURN_BLANK_AS_NULL))));
            software.put("state", AssetConstants.IN_USE);
            software.put("softwareType", parseSoftwareType(
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(9, Row.RETURN_BLANK_AS_NULL)))));
            software.put("license",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(10, Row.RETURN_BLANK_AS_NULL))));
            software.put("expiredTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(11, Row.RETURN_BLANK_AS_NULL), sdf));
            software.put("comment",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(12, Row.RETURN_BLANK_AS_NULL))));

            assetService.newAsset(software);
            softCount++;
        }
        results.put("code", 0);
        results.put("tip", "???" + hardCount + ""
                + softCount + "");
        log("?CI??" + hardCount + "" + softCount
                + "");
        return SUCCESS;
    } catch (Exception e) {
        log(e);
        results.put("code", 4);
        results.put("tip", "???" + hardCount
                + "" + softCount + "");
        log("?CI??" + hardCount + "" + softCount
                + "");
        return SUCCESS;
    }
}

From source file:net.lmxm.ute.configuration.ConfigurationReader.java

/**
 * Parses the http query params./*from  ww  w. j  a  va 2s .co m*/
 * 
 * @param sourceType the source type
 * @param source the source
 */
private void parseHttpQueryParams(final HttpSourceType sourceType, final HttpSource source) {
    final String prefix = "parseHttpQueryParams() :";

    LOGGER.debug("{} entered", prefix);

    final Map<String, String> queryParams = new HashMap<String, String>();

    if (sourceType.isSetQueryParams()) {
        for (final QueryParam queryParam : sourceType.getQueryParams().getQueryParamArray()) {
            queryParams.put(StringUtils.trim(queryParam.getName()), StringUtils.trim(queryParam.getValue()));
        }
    }

    source.setQueryParams(queryParams);

    LOGGER.debug("{} leaving", prefix);
}

From source file:com.neophob.sematrix.glue.Collector.java

/**
 * load a saved preset./*from w w  w.  j a  v  a  2  s .  c o m*/
 *
 * @param preset the new current status
 */
public void setCurrentStatus(List<String> preset) {
    setLoadingPresent(true);
    for (String s : preset) {
        s = StringUtils.trim(s);
        s = StringUtils.removeEnd(s, ";");
        MessageProcessor.processMsg(StringUtils.split(s, ' '), false);
    }
    setLoadingPresent(false);
}

From source file:com.ebay.cloud.cms.service.resources.impl.QueryResource.java

private static String extractCursorValue(String paramVal) {
    List<String> cursorList = null;
    final String cursorValue = paramVal.trim();
    if (cursorValue.startsWith("{")) {
        // single node cursor MUST start with {
        return cursorValue;
    } else {/*w w w. ja  va  2s  .  c o  m*/
        cursorList = new ArrayList<String>(10);
        if (!cursorValue.startsWith("[")) {
            // better user experience: when user copy the oid's with quotation, make sure parameter are handled correctly 
            String[] joinOids = cursorValue.split(",");
            for (String oid : joinOids) {
                // assumption : the oid doesn't contain the character of "
                cursorList.add(StringUtils.trim(oid.replace('"', ' ')));
            }
        } else {
            // expect to be an valid json string array
            try {
                JsonNode node = ObjectConverter.mapper.readTree(cursorValue);
                cursorList = new ArrayList<String>(10);
                for (JsonNode cursorNode : node) {
                    if (cursorNode.isObject()) {
                        // when find the object node, expected to be single cursor
                        return cursorNode.toString();
                    } else {
                        cursorList.add(cursorNode.getTextValue());
                    }
                }
            } catch (Exception e) {
                logger.info("read cursor value as json node failed, will try to split by , !", e);
            }
        }
    }
    return org.apache.commons.lang3.StringUtils.join(cursorList, ",");
}

From source file:com.evolveum.midpoint.security.api.SecurityUtil.java

private static String getAddressFromHeader(String name, String value) {
    String[] split = StringUtils.split(value, ",");
    return StringUtils.trim(split[0]);
}

From source file:com.jeans.iservlet.controller.impl.ImportController.java

@RequestMapping(method = RequestMethod.POST, value = "/ci")
@ResponseBody/*w w w . ja va  2s  .c  o m*/
public void importCI(@RequestParam("data") CommonsMultipartFile data, HttpServletResponse response)
        throws IOException {
    PrintWriter out = response.getWriter();
    if (null == data) {
        showError(out, "??");
        out.close();
        return;
    }
    int hardCount = 0, softCount = 0;
    String info = null;
    try (Workbook workBook = WorkbookFactory.create(data.getInputStream())) {
        Sheet hardSheet = workBook.getSheet("");
        Sheet softSheet = workBook.getSheet("");
        if (null == hardSheet || null == softSheet) {
            data.getInputStream().close();
            showError(out, "????Sheet");
            out.close();
            return;
        }
        Company comp = getCurrentCompany();
        ExcelUtils.setNumberFormat("#");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyymm");
        int total = hardSheet.getLastRowNum() + softSheet.getLastRowNum();
        double progress = 0.0;
        double step = 100.0 / (double) total;
        showProgressDialog(out, getCurrentCompany().getAlias() + "?");
        // hardSheet: 1?019?200?
        int last = hardSheet.getLastRowNum();
        for (int rn = 1; rn <= last; rn++) {
            Row r = hardSheet.getRow(rn);
            // ??""???
            String flag = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(0, Row.RETURN_BLANK_AS_NULL)));
            // ???name?
            String name = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(4, Row.RETURN_BLANK_AS_NULL)));
            progress += step;
            if (!"".equals(flag) || StringUtils.isBlank(name)) {
                continue;
            }
            showProgress(out, "" + name, progress); // 
            Map<String, Object> hardware = new HashMap<String, Object>();
            hardware.put("company", comp);
            hardware.put("type", AssetConstants.HARDWARE_ASSET);
            hardware.put("name", name);
            hardware.put("code",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(1, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("financialCode",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(2, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("catalog",
                    parseAssetCatalog(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(3, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.HARDWARE_ASSET));
            hardware.put("vendor",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(5, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("modelOrVersion",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(6, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("assetUsage",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(7, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("sn",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(8, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("configuration",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(9, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("purchaseTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(10, Row.RETURN_BLANK_AS_NULL), sdf));
            try {
                double q = (double) ExcelUtils.getCellValue(r.getCell(11, Row.RETURN_BLANK_AS_NULL));
                if (q < 1) {
                    hardware.put("quantity", 1);
                } else {
                    hardware.put("quantity", (int) Math.round(q));
                }
            } catch (Exception e) {
                hardware.put("quantity", 1);
            }
            try {
                hardware.put("cost", BigDecimal
                        .valueOf((double) ExcelUtils.getCellValue(r.getCell(12, Row.RETURN_BLANK_AS_NULL))));
            } catch (Exception e) {
                hardware.put("cost", new BigDecimal(0));
            }
            hardware.put("state",
                    parseAssetState(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(13, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.HARDWARE_ASSET));
            hardware.put("warranty", parseHardwareWarranty(StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(14, Row.RETURN_BLANK_AS_NULL)))));
            hardware.put("location",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(15, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("ip",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(16, Row.RETURN_BLANK_AS_NULL))));
            hardware.put("importance", parseHardwareImportance(StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(17, Row.RETURN_BLANK_AS_NULL)))));
            hardware.put("owner", hrService.findEmployeeByName(getCurrentCompany(), StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(18, Row.RETURN_BLANK_AS_NULL)))));
            hardware.put("comment",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(19, Row.RETURN_BLANK_AS_NULL))));

            if (null != assetService.create(hardware)) {
                hardCount++;
            }
        }
        // softSheet: 1?013?140?
        last = softSheet.getLastRowNum();
        for (int rn = 1; rn <= last; rn++) {
            Row r = softSheet.getRow(rn);
            // ??""???
            String flag = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(0, Row.RETURN_BLANK_AS_NULL)));
            // ???name?
            String name = StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(2, Row.RETURN_BLANK_AS_NULL)));
            progress += step;
            if (!"".equals(flag) || StringUtils.isBlank(name)) {
                continue;
            }
            showProgress(out, "" + name, progress); // 
            Map<String, Object> software = new HashMap<String, Object>();
            software.put("company", comp);
            software.put("type", AssetConstants.SOFTWARE_ASSET);
            software.put("name", name);
            software.put("catalog",
                    parseAssetCatalog(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(1, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.SOFTWARE_ASSET));
            software.put("vendor",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(3, Row.RETURN_BLANK_AS_NULL))));
            software.put("modelOrVersion",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(4, Row.RETURN_BLANK_AS_NULL))));
            software.put("assetUsage",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(5, Row.RETURN_BLANK_AS_NULL))));
            software.put("purchaseTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(6, Row.RETURN_BLANK_AS_NULL), sdf));
            try {
                double q = (double) ExcelUtils.getCellValue(r.getCell(7, Row.RETURN_BLANK_AS_NULL));
                if (q < 1) {
                    software.put("quantity", 1);
                } else {
                    software.put("quantity", (int) Math.round(q));
                }
            } catch (Exception e) {
                software.put("quantity", 1);
            }
            try {
                software.put("cost", BigDecimal
                        .valueOf((double) ExcelUtils.getCellValue(r.getCell(8, Row.RETURN_BLANK_AS_NULL))));
            } catch (Exception e) {
                software.put("cost", new BigDecimal(0));
            }
            software.put("state",
                    parseAssetState(
                            StringUtils.trim(
                                    ExcelUtils.getCellValueAsString(r.getCell(9, Row.RETURN_BLANK_AS_NULL))),
                            AssetConstants.SOFTWARE_ASSET));
            software.put("softwareType", parseSoftwareType(StringUtils
                    .trim(ExcelUtils.getCellValueAsString(r.getCell(10, Row.RETURN_BLANK_AS_NULL)))));
            software.put("license",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(11, Row.RETURN_BLANK_AS_NULL))));
            software.put("expiredTime",
                    ExcelUtils.getCellValueAsDate(r.getCell(12, Row.RETURN_BLANK_AS_NULL), sdf));
            software.put("comment",
                    StringUtils.trim(ExcelUtils.getCellValueAsString(r.getCell(13, Row.RETURN_BLANK_AS_NULL))));

            if (null != assetService.create(software)) {
                softCount++;
            }
        }
        info = "??" + hardCount + "" + softCount
                + "";
    } catch (Exception e) {
        log(e);
        info = "?????"
                + hardCount + "" + softCount + "";
    } finally {
        data.getInputStream().close();
        closeProgressDialog(out);
        showInfo(out, info);
        out.close();
        log(info);
    }
}

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineManagerTest.java

/**
 * Test case for {@link MicroPipelineManager#shutdownPipeline(String)} being provided
 * valid id as input which must reduce the number of registered pipelines as well as 
 * {@link MicroPipeline#shutdown()} must be called
 *//*from   ww w . j  av a 2s .c o m*/
@Test
public void testShutdownPipeline_withValidInput() throws Exception {
    MicroPipelineConfiguration cfg = new MicroPipelineConfiguration();
    cfg.setId("testExecutePipeline_withValidConfiguration");

    MicroPipeline pipeline = Mockito.mock(MicroPipeline.class);
    Mockito.when(pipeline.getId()).thenReturn(cfg.getId());

    MicroPipelineFactory factory = Mockito.mock(MicroPipelineFactory.class);
    Mockito.when(factory.instantiatePipeline(cfg, executorService)).thenReturn(pipeline);

    MicroPipelineManager manager = new MicroPipelineManager("id", factory, executorService);

    Assert.assertEquals("Values must be equal", StringUtils.lowerCase(StringUtils.trim(cfg.getId())),
            manager.executePipeline(cfg));
    Assert.assertEquals("Values must be equal", 1, manager.getNumOfRegisteredPipelines());

    Mockito.verify(factory).instantiatePipeline(cfg, executorService);

    manager.shutdownPipeline(cfg.getId());
    Assert.assertEquals("Values must be equal", 0, manager.getNumOfRegisteredPipelines());
    Mockito.verify(pipeline).shutdown();
}

From source file:com.devicehive.service.UserService.java

@Transactional(propagation = Propagation.REQUIRED)
public UserVO createUser(@NotNull UserVO user, String password) {
    if (user.getId() != null) {
        throw new IllegalParametersException(Messages.ID_NOT_ALLOWED);
    }/*from ww  w  .  j  av  a2 s . c  o m*/
    final String userLogin = StringUtils.trim(user.getLogin());
    user.setLogin(userLogin);
    Optional<UserVO> existing = userDao.findByName(user.getLogin());
    if (existing.isPresent()) {
        throw new ActionNotAllowedException(Messages.DUPLICATE_LOGIN);
    }
    if (StringUtils.isNoneEmpty(password)) {
        String salt = passwordService.generateSalt();
        String hash = passwordService.hashPassword(password, salt);
        user.setPasswordSalt(salt);
        user.setPasswordHash(hash);
    }
    final String googleLogin = StringUtils.isNotBlank(user.getGoogleLogin()) ? user.getGoogleLogin() : null;
    final String facebookLogin = StringUtils.isNotBlank(user.getFacebookLogin()) ? user.getFacebookLogin()
            : null;
    final String githubLogin = StringUtils.isNotBlank(user.getGithubLogin()) ? user.getGithubLogin() : null;
    if (googleLogin != null || facebookLogin != null || githubLogin != null) {
        Optional<UserVO> userWithSameIdentity = userDao.findByIdentityName(userLogin, googleLogin,
                facebookLogin, githubLogin);
        if (userWithSameIdentity.isPresent()) {
            throw new ActionNotAllowedException(Messages.DUPLICATE_IDENTITY_LOGIN);
        }
        user.setGoogleLogin(googleLogin);
        user.setFacebookLogin(facebookLogin);
        user.setGithubLogin(githubLogin);
    }
    user.setLoginAttempts(Constants.INITIAL_LOGIN_ATTEMPTS);
    hiveValidator.validate(user);
    userDao.persist(user);
    return user;
}

From source file:net.lmxm.ute.configuration.ConfigurationReader.java

/**
 * Parses the job.//from w w  w .  j a va  2 s . com
 * 
 * @param jobType the job type
 * @param configuration the configuration
 * 
 * @return the job
 */
private SequentialJob parseJob(final JobType jobType, final Configuration configuration) {
    final String prefix = "parseJob() :";

    LOGGER.debug("{} entered", prefix);

    final SequentialJob job = new SequentialJob();

    job.setDescription(StringUtils.trim(jobType.getDescription()));
    job.setId(StringUtils.trim(jobType.getId()));

    final List<Task> tasks = job.getTasks();

    LOGGER.debug("{} parsing {} tasks", prefix, tasks.size());

    if (jobType.getTasks() != null) {
        for (final TaskType taskType : jobType.getTasks().getTaskArray()) {
            tasks.add(parseTask(taskType, job, configuration));
        }
    }

    LOGGER.debug("{} returning {}", prefix, job);

    return job;
}