下面列出了怎么用org.hibernate.validator.constraints.URL的API类实例代码及写法,或者点击链接到github查看源代码。
private static boolean isValidSimpleConstraint(String cName, String field, Object actual, LinkedList<String> err) {
if ("required".equals(cName) && !required().isValid(actual)) {
err.add(Utils.formatMessage("{0} is required.", field));
return false;
} else if (matches(AssertFalse.class, cName) && !falsy().isValid(actual)) {
err.add(Utils.formatMessage("{0} must be false.", field));
return false;
} else if (matches(AssertTrue.class, cName) && !truthy().isValid(actual)) {
err.add(Utils.formatMessage("{0} must be true.", field));
return false;
} else if (matches(Future.class, cName) && !future().isValid(actual)) {
err.add(Utils.formatMessage("{0} must be in the future.", field));
return false;
} else if (matches(Past.class, cName) && !past().isValid(actual)) {
err.add(Utils.formatMessage("{0} must be in the past.", field));
return false;
} else if (matches(URL.class, cName) && !url().isValid(actual)) {
err.add(Utils.formatMessage("{0} is not a valid URL.", field));
return false;
} else if (matches(Email.class, cName) && !email().isValid(actual)) {
err.add(Utils.formatMessage("{0} is not a valid email.", field));
return false;
}
return true;
}
@PostMapping("/alliance/manage/logo/save")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String manageLogoSave(@RequestParam(name = "body") long bodyId,
@RequestParam(name = "alliance") long allianceId,
@RequestParam @URL @Size(max = 128) String url) {
allianceService.saveLogo(bodyId, allianceId, url);
return "redirect:/alliance/manage?body=" + bodyId + "&alliance=" + allianceId;
}
@URL
public String getApiBaseUrl() {
return sandboxed
? "http://sandboxapi.ihealthlabs.com/OpenApiV2"
: "https://api.ihealthlabs.com:8443/OpenApiV2";
}
/**
* {@inheritDoc}
*
* @see org.apache.catalina.servlets.DefaultServlet
*/
@Override
public String toHtml(
@NotNull final File directory,
@URL final String requestURL,
final boolean includeParent
) throws IOException {
final Directory dir = this.getDirectory(directory, requestURL, includeParent);
return directoryToHTML(directory.getName(), dir);
}
/**
* {@inheritDoc}
*/
@Override
public String toJson(
@NotNull final File directory,
@URL final String requestURL,
final boolean includeParent
) throws Exception {
final Directory dir = this.getDirectory(directory, requestURL, includeParent);
return GenieObjectMapper.getMapper().writeValueAsString(dir);
}
@URL
String getEndpoint();
@URL
String getStsEndpoint();
@Size(max = 100)
@URL
@Column(name = "URL", length = 100)
public String getUrl() {
return url;
}
/**
* THe user can add a parcel repo URL. If one is specified,
* it will be added to the remote repository urls so that the
* associated parcel can show up in CM.
*/
@URL
String getRepoUrl();
/**
* Convert a given directory to an String containing a full valid HTML page.
*
* @param directory The directory to convert. Not null. Is directory.
* @param requestURL The URL of the request that kicked off this process
* @param includeParent Whether the conversion should include reference to the parent directory.
* @return String HTML representation of the directory
* @throws Exception for any conversion problem
*/
String toHtml(
@NotNull File directory,
@URL String requestURL,
boolean includeParent
) throws Exception;
/**
* Convert a given directory to an String of JSON.
*
* @param directory The directory to convert. Not null. Is directory.
* @param requestURL The URL of the request that kicked off this process
* @param includeParent Whether the conversion should include reference to the parent directory.
* @return String HTML representation of the directory
* @throws Exception for any conversion problem
*/
String toJson(
@NotNull File directory,
@URL String requestURL,
boolean includeParent
) throws Exception;