本文整理汇总了Java中javax.validation.ValidationException.getLocalizedMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationException.getLocalizedMessage方法的具体用法?Java ValidationException.getLocalizedMessage怎么用?Java ValidationException.getLocalizedMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.validation.ValidationException
的用法示例。
在下文中一共展示了ValidationException.getLocalizedMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildPoint
import javax.validation.ValidationException; //导入方法依赖的package包/类
protected Waypoint buildPoint(final Instant time, final double lon,
final double lat, final BigDecimal ele, final String name,
final String desc, final Set<Link> links) {
final CoordinatesBuilder cbld = new CoordinatesBuilder(lon, lat);
if (null != ele) {
cbld.elevation(ele.doubleValue());
}
try {
return new WaypointBuilder(time, cbld.build()).name(name).
description(desc).links(links).build();
} catch (final ValidationException e) {
final String msg = "Bean validation failed. Waypoint will be "
+ "ignored. Problem was: " + e.getLocalizedMessage();
LOGGER.warn(Markers.IO.getMarker(), "{} | {} | {}",
Actions.CREATE, StatusCodes.SYNTAX_ERROR.getCode(), msg);
return null;
}
}
示例2: getTrail
import javax.validation.ValidationException; //导入方法依赖的package包/类
protected Trail getTrail(final String trailName, final Set<Waypoint> points,
final String description, final Set<Link> links) {
Trail trail;
if (points.isEmpty()) {
LOGGER.warn(Markers.IO.getMarker(), "{} | {} | {}.",
Actions.PARSE, StatusCodes.NOT_FOUND.getCode(),
logMessages.getString("Error.NoPoint"));
trail = null;
} else {
try {
trail = new TrailBuilder(trailName, points).description(
description).links(links).build();
LOGGER.info(Markers.IO.getMarker(), "{} | {} | {}.",
Actions.PARSE, StatusCodes.OK.getCode(),
"Mapped one trail," + " containing " + points.size()
+ " point(s)");
} catch (final ValidationException e) {
final String msg = "Bean validation failed. Trail will be "
+ "ignored. Problem was: " + e.getLocalizedMessage();
LOGGER.warn(Markers.IO.getMarker(), "{} | {} | {}",
Actions.CREATE, StatusCodes.SYNTAX_ERROR.getCode(),
msg);
trail = null;
}
}
return trail;
}
示例3: createSubDirectory
import javax.validation.ValidationException; //导入方法依赖的package包/类
/**
* Create a directory under an existing DataSet. With the same permission as
* the parent.
* The directory is created using the user dfso
*
* @param project The project under which the directory is being created.
* Cannot be null.
*
* @param dirPath The full path of the folder to be created.
* /Projects/projectA/datasetB/folder1/folder2/folder3, folder1/folder2
* has to exist and folder3 needs to be a valid name.
* @param templateId The id of the template to be associated with the newly
* created directory.
* @param description The description of the directory
* @param searchable Defines if the directory can be searched upon
* @param udfso
* @throws java.io.IOException If something goes wrong upon the creation of
* the directory.
* @throws io.hops.hopsworks.common.exception.AppException
* @throws IllegalArgumentException If:
* <ul>
* <li>Any of the folder names on the given path does not have a valid name or
* </li>
* <li>Such a folder already exists. </li>
* <li>The parent folder does not exists. </li>
* </ul>
* @see FolderNameValidator
* @throws NullPointerException If any of the non-null-allowed parameters is
* null.
*/
public void createSubDirectory(Project project, Path dirPath,
int templateId, String description, boolean searchable,
DistributedFileSystemOps udfso) throws IOException, AppException {
if (project == null) {
throw new NullPointerException(
"Cannot create a directory under a null project.");
} else if (dirPath == null) {
throw new NullPointerException(
"Cannot create a directory for an empty path.");
}
String folderName = dirPath.getName();
String parentPath = dirPath.getParent().toString();
try {
FolderNameValidator.isValidName(folderName, true);
} catch (ValidationException e) {
throw new AppException(Response.Status.BAD_REQUEST.getStatusCode(), e.getLocalizedMessage());
}
//Check if the given folder already exists
if (inodes.existsPath(dirPath.toString())) {
throw new IllegalArgumentException("The given path already exists.");
}
// Check if the parent directory exists
Inode parent = inodes.getInodeAtPath(parentPath);
if (parent == null) {
throw new IllegalArgumentException(
"Path for parent folder does not exist: "
+ parentPath + " under " + project.getName());
}
//Now actually create the folder
boolean success = this.createFolder(dirPath.toString(), templateId,
null, udfso);
//if the folder was created successfully, persist basic metadata to it -
//description and searchable attribute
if (success) {
//find the corresponding inode
int partitionId = HopsUtils.calculatePartitionId(parent.getId(),
folderName, dirPath.depth());
Inode folder = this.inodes.findByInodePK(parent, folderName, partitionId);
InodeBasicMetadata basicMeta = new InodeBasicMetadata(folder, description,
searchable);
this.inodeBasicMetaFacade.addBasicMetadata(basicMeta);
}
}