Java Code Examples for org.apache.commons.lang3.StringUtils.isNoneEmpty()

The following are Jave code examples for showing how to use isNoneEmpty() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: spring-rest-commons-options   File: CollectionResources.java   View Source Code Vote up 6 votes
public void addEndpoint(Endpoint e) {
	LOGGER.debug("Añadiendo endpoint: {}", e);
	String[] relatives = e.getUrl().trim().split("/");
	int i = 0;
	String path = "";
	boolean isPathVariable = false;
	while (i < relatives.length && !isPathVariable) {
		String relative = relatives[i++];
		isPathVariable = relative.contains("{");
		if (StringUtils.isNoneEmpty(relative) && !isPathVariable) {
			path = path + "/" + relative;
			if (!path.matches("/public|/private|/private/v1|/public/v1")) {
				Resource resource = this.resources.get(path);
				if (resource == null) {
					resource = new Resource();
				}
				resource.addEndpoint(e);
				this.resources.put(path, resource);
			}
		}

	}
}
 
Example 2
Project: soundwave   File: Ec2InstanceStore.java   View Source Code Vote up 6 votes
@Override
public Map<String, String> getUserData(String instanceId) throws Exception {
  Preconditions.checkNotNull(instanceId);

  awsRateLimiter.acquire();
  OperationStats op = new OperationStats("ec2InstanceStore", "getUserData");
  try {
    InstanceAttribute
        attribute =
        this.getInstanceAttribute(instanceId, "userData");
    if (attribute != null) {
      String base64EncodedString = attribute.getUserData();
      if (StringUtils.isNoneEmpty(base64EncodedString)) {
        Map<String, String> userData = Ec2InstanceStore.parseEc2UserData(base64EncodedString);
        op.succeed();
        return userData;
      }
    }
  } catch (Exception ex) {
    op.failed();
    throw ex;
  }
  op.succeed();
  return new HashMap<>();
}
 
Example 3
Project: SECP   File: GroupController.java   View Source Code Vote up 6 votes
public Response modifyGroup(GroupDTO request) {

        Set<Long> permissions = request.getPermissions().stream().
            map(permission -> permission.getId()).collect(Collectors.toSet());
        Set<Long> roles = request.getRoles().stream().
            map(role -> role.getId()).collect(Collectors.toSet());

        String error = validateRolesAndPermissions(permissions, roles);
        if (StringUtils.isNoneEmpty(error)) {
            throw new WebApplicationException(
                error,
                Response.Status.BAD_REQUEST);
        }

        Group group = getGroup(request.getGroupID());
        if(group.getGroupType() == GroupType.PRIVATE)
        {
            throw new WebApplicationException(
                GroupErrorMessages.MODIFY_PRIVATE_GROUP,
                Response.Status.BAD_REQUEST);
        }

        group.setIsActive(request.isActive());
        return updateOrCreateGroup(group, permissions, roles);
    }
 
Example 4
Project: dooo   File: RedisSessionDao.java   View Source Code Vote up 6 votes
@Override
public String getSeesion(final String sessionId) {
    try {
        String session = (String) this.redisConfig.execute(new RedisCallback<String>() {
            @Override
            public String call(Jedis jedis) {
                return jedis.get(sessionId);
            }
        });
        if (StringUtils.isNoneEmpty(new CharSequence[]{session})) {
            this.updateExpiredTime(sessionId);
        }

        return session;
    } catch (Exception var3) {
        LOGGER.error("getSeesion failed, sessionId[" + sessionId + "]", var3);
        return null;
    }
}
 
Example 5
Project: SECP   File: FilterController.java   View Source Code Vote up 6 votes
public Response updateOrCreateFilter(FilterCreateRequest request)
{
    Set<Long> permissions = request.permissions.stream().
        map(permission -> permission.getId()).collect(Collectors.toSet());
    Set<Long> roles = request.roles.stream().
        map(role -> role.getId()).collect(Collectors.toSet());
    String error = validateCreateRequest(request.name,permissions,roles);
    if(StringUtils.isNoneEmpty(error))
    {
            throw new WebApplicationException(
                error,
                Response.Status.BAD_REQUEST);
    }

    Filter filter = new Filter(request.name);
    return updateOrCreateFilter(filter,permissions,roles);
}
 
Example 6
Project: dooo   File: HttpServiceRequest.java   View Source Code Vote up 6 votes
public HttpUriRequest toHttpUriRequest() {
    LOGGER.debug("in createRequestBuilder");
    RequestBuilder requestBuilder = createRequestBuilder();
    int timeout = httpServiceInfo.getTimeout();
    RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
            .setConnectionRequestTimeout(timeout)
            .setSocketTimeout(timeout)
            .setConnectTimeout(timeout)
            .setCookieSpec(CookieSpecs.IGNORE_COOKIES);

    requestBuilder.setConfig(requestConfigBuilder.build());
    if (StringUtils.isNoneEmpty(httpServiceInfo.getContentType())) {
        requestBuilder.addHeader("Content-Type", httpServiceInfo.getContentType());
    } else {
        requestBuilder.addHeader("Content-Type", httpServletRequest.getContentType());
    }
    return requestBuilder.build();
}
 
Example 7
Project: hivemq-consul-cluster-discovery   File: ConsulDiscoveryCallback.java   View Source Code Vote up 5 votes
private String getNodeAddress(ClusterNodeAddress ownAddress) {
    if (StringUtils.isNoneEmpty(configuration.getNodeAddress())) {
        return configuration.getNodeAddress();
    } else {
        return ownAddress.getHost();
    }
}
 
Example 8
Project: SECP   File: GroupController.java   View Source Code Vote up 5 votes
public Response createPublicGroup(GroupCreateRequest request) {
    Set<Long> permissions = request.permissions.stream().
        map(permission -> permission.getId()).collect(Collectors.toSet());
    Set<Long> roles = request.roles.stream().
        map(role -> role.getId()).collect(Collectors.toSet());
    String error = validateCreateRequest(request.name, permissions, roles);
    if (StringUtils.isNoneEmpty(error)) {
        throw new WebApplicationException(
            error,
            Response.Status.BAD_REQUEST);
    }

    Group group = new Group(request.name);
    return updateOrCreateGroup(group, permissions, roles);
}
 
Example 9
Project: SECP   File: GroupController.java   View Source Code Vote up 5 votes
private String validateRolesAndPermissions(Set<Long> permissions, Set<Long> roles) {

        String roleError = validateRoles(roles);
        if (StringUtils.isNoneEmpty(roleError))
            return roleError;

        String permissionError = validatePermissions(permissions);
        if (StringUtils.isNoneEmpty(permissionError))
            return permissionError;

        return StringUtils.EMPTY;
    }
 
Example 10
Project: SECP   File: AdminController.java   View Source Code Vote up 5 votes
public Response registerRoles(AppCreateDTO request) {
    String error = validateCreateRolesRequest(request);
    if(StringUtils.isNoneEmpty(error))
    {
        throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
    }

    Set<RolesOrPermissionDTO> response = new HashSet<>();
    for (String name : request.getRoles()) {
        Role role = rolesDAO.save(new Role(name, request.getColor()));
        response.add(new RolesOrPermissionDTO(role.getId(), role.getRole(), role.getColor()));
    }

    return Response.status(Response.Status.CREATED).entity(response).build();
}
 
Example 11
Project: SECP   File: AdminController.java   View Source Code Vote up 5 votes
public Response registerPermissions(AppCreateDTO request) {
    String error = validateCreatePermissionsRequest(request);
    if(StringUtils.isNoneEmpty(error))
    {
        throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
    }

    Set<RolesOrPermissionDTO> response = new HashSet<>();
    for (String name : request.getPermissions()) {
        Permission permission = permissionDAO.save(new Permission(name, request.getColor()));
        response.add(new RolesOrPermissionDTO(permission.getId(), permission.getLevel(), permission.getColor()));
    }

    return Response.status(Response.Status.CREATED).entity(response).build();
}
 
Example 12
Project: SECP   File: FilterController.java   View Source Code Vote up 5 votes
private String validateRolesAndPermissions(Set<Long> permissions, Set<Long> roles) {

        String roleError = validateRoles(roles);
        if (StringUtils.isNoneEmpty(roleError))
            return roleError;

        String permissionError = validatePermissions(permissions);
        if (StringUtils.isNoneEmpty(permissionError))
            return permissionError;

        return StringUtils.EMPTY;
    }
 
Example 13
Project: smn-sdk-java   File: CreateTopicRequest.java   View Source Code Vote up 5 votes
/**
 * set displayName
 * <p>
 * validate display length before set the value
 *
 * @param displayName the displayName to set
 */
public void setDisplayName(String displayName) {

    if (StringUtils.isNoneEmpty(displayName)) {
        if (ValidationUtil.validateDisplayName(displayName)) {
            this.displayName = displayName;
        } else {
            throw new RuntimeException("Display name is oversized.");
        }
    } else {
        this.displayName = displayName;
    }
}
 
Example 14
Project: jwala   File: ResourceServiceImpl.java   View Source Code Vote up 5 votes
@Override
public Map<String, String> checkFileExists(final String groupName, final String jvmName, final String webappName, final String webserverName, final String fileName) {
    boolean resultBoolean = false;
    if (StringUtils.isNotEmpty(groupName) && StringUtils.isNoneEmpty(fileName)) {
        if (jvmName != null && !jvmName.isEmpty()) {
            // Search for file in jvms
            LOGGER.debug("Searching for resource {} in group {} and jvm {}", fileName, groupName, jvmName);
            resultBoolean = groupPersistenceService.checkGroupJvmResourceFileName(groupName, fileName) ||
                    jvmPersistenceService.checkJvmResourceFileName(groupName, jvmName, fileName);
        } else if (webappName != null && !webappName.isEmpty()) {
            // Search for file in webapps
            LOGGER.debug("Searching for resource {} in group {} and webapp {}", fileName, groupName, webappName);
            resultBoolean = groupPersistenceService.checkGroupAppResourceFileName(groupName, fileName) ||
                    applicationPersistenceService.checkAppResourceFileName(groupName, webappName, fileName);
        } else if (webserverName != null && !webserverName.isEmpty()) {
            // Search for file in webservers
            LOGGER.debug("Searching for resource {} in group {} and webserver {}", fileName, groupName, webserverName);
            resultBoolean = groupPersistenceService.checkGroupWebServerResourceFileName(groupName, fileName) ||
                    webServerPersistenceService.checkWebServerResourceFileName(groupName, webserverName, fileName);
        }
    }
    Map<String, String> result = new HashMap<>();
    result.put("fileName", fileName);
    result.put("exists", Boolean.toString(resultBoolean));
    LOGGER.debug("result: {}", result.toString());
    return result;
}
 
Example 15
Project: sql-on-json   File: Plain.java   View Source Code Vote up 5 votes
@SuppressWarnings("WeakerAccess")
public Plain(String json) {
    List<JsonTable> list = new ArrayList<>();
    if (StringUtils.isNoneEmpty(json)) {
        final JsonParser parser = new JsonParser();
        final JsonObject jsonObject = parser.parse(json).getAsJsonObject();
        for (Map.Entry<String, JsonElement> e : jsonObject.entrySet()) {
            if (e.getValue().isJsonArray()) {
                list.add(new JsonTable(e.getKey(), e.getValue().getAsJsonArray()));
            }
        }
    }
    jsonLength = json.length();
    iterator = list.iterator();
}
 
Example 16
Project: xbin-store   File: CartController.java   View Source Code Vote up 4 votes
@RequestMapping("/cart")
public String showCart( HttpServletRequest request, HttpServletResponse response,Model model) {

    String cookieUUID = CookieUtils.getCookieValue(request, Const.CART_KEY);
    String tokenLogin = CookieUtils.getCookieValue(request, Const.TOKEN_LOGIN);

    TbUser user = null;
    String userJson = null;
    if (StringUtils.isNoneEmpty(tokenLogin)) {

        try {
            userJson = jedisClient.get(USER_SESSION + tokenLogin);
        } catch (Exception e) {
            logger.error("Redis 错误", e);
        }

        if (StringUtils.isNoneEmpty(userJson)) {
            user = FastJsonConvert.convertJSONToObject(userJson, TbUser.class);
        }
        model.addAttribute("user", user);
    } else {
        model.addAttribute("user", user);
    }

    List<CartInfo> cartInfos = new ArrayList<>();
    if (StringUtils.isNoneEmpty(cookieUUID)) {
        cartInfos= cartService.getCartInfoListByCookiesId(cookieUUID);
    }

    if (cartInfos.size() == 0) {
        model.addAttribute("cartInfos", null);
        return "cart";
    }

    int totalPrice = 0;

    for (int i = 0; i < cartInfos.size(); i++) {
        CartInfo cartInfo = cartInfos.get(i);
        totalPrice += cartInfo.getSum();
    }

    model.addAttribute("cartInfos", cartInfos);
    model.addAttribute("totalPrice", totalPrice);

    return "cart";
}
 
Example 17
Project: cloud-portal   File: DirectoryService.java   View Source Code Vote up 4 votes
@PostConstruct
public void init() {
	if (StringUtils.isNoneEmpty(urlString)) {
		urls = urlString.split(",");
	}
}
 
Example 18
Project: atlas   File: BundleProguarder.java   View Source Code Vote up 4 votes
private static void cacheProguard(AppVariantContext appVariantContext, Input input, Result result)
    throws FileCacheException, IOException {

    AwbBundle awbBundle = input.getAwbBundles().get(0).getAwbBundle();
    File tmpDir = new File(appVariantContext.getScope().getGlobalScope().getIntermediatesDir(),
                           "progurad-cache/" + awbBundle.getName());
    tmpDir.mkdirs();

    for (AwbTransform awbTransform : input.getAwbBundles()) {
        for (File file : awbTransform.getInputFiles()) {
            if (file.exists()) {
                String md5 = input.proguardJarMap.get(file);
                if (StringUtils.isNoneEmpty(md5)) {
                    FileUtils.copyFile(file, new File(tmpDir, md5 + ".jar"));
                } else {
                    FileUtils.copyFileToDirectory(file, tmpDir);
                }
            } else {
                new File(tmpDir, file.getName()).createNewFile();
            }
        }
    }

    //Keep cache. Json
    File keepFile = awbBundle.getKeepProguardFile();
    if (null != keepFile && keepFile.exists()) {
        FileUtils.copyFileToDirectory(keepFile, tmpDir);
    }

    File proguardCfg = new File(null != input.proguardOutputDir ? input.proguardOutputDir
                                    : appVariantContext
                                        .getAwbProguardDir(awbBundle),
                                "proguard.cfg");
    if (!proguardCfg.exists()){
        proguardCfg = input.printConfiguration;
    }
    if ( null != proguardCfg && proguardCfg.exists()) {
        FileUtils.copyFileToDirectory(proguardCfg, tmpDir);
    }

    File usageCfg = new File(null != input.proguardOutputDir ? input.proguardOutputDir
                                 : appVariantContext
                                     .getAwbProguardDir(awbBundle),
                             "usage.cfg");
    if (!usageCfg.exists()){
        usageCfg = input.printUsage;
    }
    if ( null != usageCfg && usageCfg.exists()) {
        FileUtils.copyFileToDirectory(usageCfg, tmpDir);
    }

    FileCacheCenter.cacheFile(CACHE_TYPE, result.key, tmpDir,
                              AtlasBuildContext.sBuilderAdapter.pushCacheToNetwork && isRemoteCacheEnabled(
                                  appVariantContext));

}
 
Example 19
Project: bird-java   File: DesTicketProtector.java   View Source Code Vote up 4 votes
public String getKey() {
    if (StringUtils.isNoneEmpty(this.key)) {
        return defaultKey;
    }
    return key;
}
 
Example 20
Project: coteafs-appium   File: AppiumServer.java   View Source Code Vote up 2 votes
/**
 * @author wasiq.bhamla
 * @since Oct 27, 2017 3:15:05 PM
 * @param logLevel
 * @param level
 */
private void setArgument (final ServerArgument flag, final String value) {
	if (StringUtils.isNoneEmpty (value)) {
		this.builder = this.builder.withArgument (flag, value);
	}
}