Java Code Examples for org.springframework.util.StringUtils#unqualify()

The following examples show how to use org.springframework.util.StringUtils#unqualify() . These examples are extracted from open source projects. 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 Project: agent   File: MobileService.java    License: MIT License 6 votes vote down vote up
public Response installApp(MultipartFile app, String mobileId) {
    Device device = DeviceHolder.getConnectedDevice(mobileId);
    if (device == null) {
        return Response.fail(mobileId + "未连接");
    }

    String fileName = app.getOriginalFilename();
    if (fileName.contains(".")) {
        fileName = UUIDUtil.getUUID() + "." + StringUtils.unqualify(fileName);
    } else {
        fileName = UUIDUtil.getUUID();
    }

    File appFile = new File(fileName);
    try {
        FileUtils.copyInputStreamToFile(app.getInputStream(), appFile);
        ((MobileDevice) device).installApp(appFile);
        return Response.success("安装成功");
    } catch (Exception e) {
        log.error("[{}]安装app失败", mobileId, e);
        return Response.fail(e.getMessage());
    } finally {
        FileUtils.deleteQuietly(appFile);
    }
}
 
Example 2
Source Project: herd   File: BaseJpaDaoImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public <T> List<T> findByNamedProperties(Class<T> entityClass, Map<String, ?> params)
{
    Validate.notNull(entityClass);
    Validate.notEmpty(params);
    StringBuilder queryStringBuilder = new StringBuilder("select type from " + StringUtils.unqualify(entityClass.getName()) + " type where ");

    Iterator<String> iterator = params.keySet().iterator();
    int index = 0;
    while (iterator.hasNext())
    {
        String propertyName = iterator.next();
        if (index > 0)
        {
            queryStringBuilder.append(" and ");
        }
        queryStringBuilder.append("(type.").append(propertyName).append(" = :").append(propertyName).append(')');
        index++;
    }

    return queryByNamedParams(queryStringBuilder.toString(), params);
}
 
Example 3
Source Project: agent   File: HttpUtil.java    License: MIT License 5 votes vote down vote up
public static File downloadFile(String url, boolean renameFile) throws IOException {
    String fileName = url.substring(url.lastIndexOf("/") + 1);
    if (renameFile) {
        if (fileName.contains(".")) {
            fileName = UUIDUtil.getUUID() + "." + StringUtils.unqualify(fileName);
        } else {
            fileName = UUIDUtil.getUUID();
        }
    }

    File file = new File(fileName);
    downloadFile(url, file);

    return file;
}
 
Example 4
public ClassFieldDeclarationRule(String restTemplateFieldName, Class<?> fieldClazz) {
	if (fieldClazz != null) {
		this.fieldClazz = fieldClazz;
	} else {
		throw new IllegalStateException("Class not specified");
	}
	if (StringUtils.hasText(restTemplateFieldName)) {
		this.fieldName = restTemplateFieldName;
	} else {
		this.fieldName = StringUtils.unqualify(fieldClazz.getSimpleName());
	}

}