本文整理了Java中fathom.utils.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:fathom.utils.Util
类名称:Util
暂无
代码示例来源:origin: com.gitblit.fathom/fathom-security
protected void logCacheSettings(Logger log) {
Util.logSetting(log, "caching", accountCache != null);
Util.logSetting(log, "cacheTtl (mins)", cacheTtl);
Util.logSetting(log, "cacheMax (accounts)", cacheMax);
}
代码示例来源:origin: gitblit/fathom
public static String toString(Method method) {
return toString(method.getDeclaringClass(), method.getName());
}
代码示例来源:origin: com.gitblit.fathom/fathom-security
public DomainPermission(String actions, String targets) {
this.domain = getDomain(getClass());
this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
this.targets = Util.splitToSet(targets, SUBPART_DIVIDER_TOKEN);
encodeParts(this.domain, actions, targets);
}
代码示例来源:origin: com.gitblit.fathom/fathom-rest-security
String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';');
if (!guardedTypes.contains(contentType)) {
log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(),
代码示例来源:origin: gitblit/fathom
/**
* Returns {@code true} if the resource at the specified path exists, {@code false} otherwise. This
* method supports scheme prefixes on the path as defined in {@link #getInputStreamForPath(String)}.
*
* @param resourcePath the path of the resource to check.
* @return {@code true} if the resource at the specified path exists, {@code false} otherwise.
* @since 0.9
*/
public static boolean resourceExists(String resourcePath) {
InputStream stream = null;
boolean exists = false;
try {
stream = getInputStreamForPath(resourcePath);
exists = true;
} catch (IOException e) {
stream = null;
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ignored) {
}
}
}
return exists;
}
代码示例来源:origin: gitblit/fathom
String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';');
if (!guardedTypes.contains(contentType)) {
log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(),
代码示例来源:origin: gitblit/fathom
protected void logCacheSettings(Logger log) {
Util.logSetting(log, "caching", accountCache != null);
Util.logSetting(log, "cacheTtl (mins)", cacheTtl);
Util.logSetting(log, "cacheMax (accounts)", cacheMax);
}
代码示例来源:origin: com.gitblit.fathom/fathom-xmlrpc
Object invokeMethod(Method method, List<Object> methodParameters) throws Exception {
Object[] argValues = null;
if (methodParameters != null) {
argValues = new Object[methodParameters.size()];
for (int i = 0; i < methodParameters.size(); i++) {
argValues[i] = methodParameters.get(i);
}
}
try {
method.setAccessible(true);
return method.invoke(invokeTarget, argValues);
} catch (IllegalAccessException | IllegalArgumentException e) {
throw e;
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
log.error("Failed to execute {}", Util.toString(method), t);
throw new FathomException(t.getMessage());
}
}
代码示例来源:origin: gitblit/fathom
public DomainPermission(String actions, String targets) {
this.domain = getDomain(getClass());
this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
this.targets = Util.splitToSet(targets, SUBPART_DIVIDER_TOKEN);
encodeParts(this.domain, actions, targets);
}
代码示例来源:origin: com.gitblit.fathom/fathom-security-ldap
@Override
public void start() {
log.debug("Realm '{}' configuration:", getRealmName());
Util.logSetting(log, "url", ldapUrl);
Util.logSetting(log, "username", ldapUsername);
Util.logSetting(log, "password", ldapPassword);
Util.logSetting(log, "bindPattern", ldapBindPattern);
Util.logSetting(log, "accountBase", accountBase);
Util.logSetting(log, "accountPattern", accountPattern);
Util.logSetting(log, "nameMapping", nameMapping);
Util.logSetting(log, "emailMapping", emailMapping);
Util.logSetting(log, "groupBase", groupBase);
Util.logSetting(log, "groupMemberPattern", groupMemberPattern);
Util.logSetting(log, "adminGroups", adminGroups);
super.logCacheSettings(log);
}
代码示例来源:origin: gitblit/fathom
public static Class<?> getParameterGenericType(Method method, Parameter parameter) {
Type parameterType = parameter.getParameterizedType();
if (!ParameterizedType.class.isAssignableFrom(parameterType.getClass())) {
throw new FathomException("Please specify a generic parameter type for '{}' of '{}'",
parameter.getType().getName(), Util.toString(method));
}
ParameterizedType parameterizedType = (ParameterizedType) parameterType;
try {
Class<?> genericClass = (Class<?>) parameterizedType.getActualTypeArguments()[0];
return genericClass;
} catch (ClassCastException e) {
throw new FathomException("Please specify a generic parameter type for '{}' of '{}'",
parameter.getType().getName(), Util.toString(method));
}
}
代码示例来源:origin: com.gitblit.fathom/fathom-security
protected void setParts(String wildcardString, boolean caseSensitive) {
if (wildcardString == null || wildcardString.trim().length() == 0) {
throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
}
wildcardString = wildcardString.trim();
List<String> parts = Arrays.asList(wildcardString.split(PART_DIVIDER_TOKEN));
this.parts = new ArrayList<>();
for (String part : parts) {
Set<String> subparts = Util.splitToSet(part, SUBPART_DIVIDER_TOKEN);
if (!caseSensitive) {
subparts = lowercase(subparts);
}
if (subparts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted.");
}
this.parts.add(subparts);
}
if (this.parts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted.");
}
}
代码示例来源:origin: gitblit/fathom
@Override
public void start() {
log.debug("Realm '{}' configuration:", getRealmName());
Util.logSetting(log, "url", ldapUrl);
Util.logSetting(log, "username", ldapUsername);
Util.logSetting(log, "password", ldapPassword);
Util.logSetting(log, "bindPattern", ldapBindPattern);
Util.logSetting(log, "accountBase", accountBase);
Util.logSetting(log, "accountPattern", accountPattern);
Util.logSetting(log, "nameMapping", nameMapping);
Util.logSetting(log, "emailMapping", emailMapping);
Util.logSetting(log, "groupBase", groupBase);
Util.logSetting(log, "groupMemberPattern", groupMemberPattern);
Util.logSetting(log, "adminGroups", adminGroups);
super.logCacheSettings(log);
}
代码示例来源:origin: gitblit/fathom
/**
* Validates that the declared content-types can actually be generated by Fathom.
*
* @param fathomContentTypes
*/
protected void validateProduces(Collection<String> fathomContentTypes) {
Set<String> ignoreProduces = new TreeSet<>();
ignoreProduces.add(Produces.TEXT);
ignoreProduces.add(Produces.HTML);
ignoreProduces.add(Produces.XHTML);
for (String produces : declaredProduces) {
if (ignoreProduces.contains(produces)) {
continue;
}
if (!fathomContentTypes.contains(produces)) {
throw new FatalException("{} declares @{}(\"{}\") but there is no registered ContentTypeEngine for that type!",
Util.toString(method), Produces.class.getSimpleName(), produces);
}
}
}
代码示例来源:origin: gitblit/fathom
protected void setParts(String wildcardString, boolean caseSensitive) {
if (wildcardString == null || wildcardString.trim().length() == 0) {
throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
}
wildcardString = wildcardString.trim();
List<String> parts = Arrays.asList(wildcardString.split(PART_DIVIDER_TOKEN));
this.parts = new ArrayList<>();
for (String part : parts) {
Set<String> subparts = Util.splitToSet(part, SUBPART_DIVIDER_TOKEN);
if (!caseSensitive) {
subparts = lowercase(subparts);
}
if (subparts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted.");
}
this.parts.add(subparts);
}
if (this.parts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted.");
}
}
代码示例来源:origin: gitblit/fathom
public static void logSetting(Logger log, Enum<?> name, Object value) {
logSetting(log, name.toString(), value);
}
代码示例来源:origin: com.gitblit.fathom/fathom-rest
/**
* Validates that the declared content-types can actually be generated by Fathom.
*
* @param fathomContentTypes
*/
protected void validateProduces(Collection<String> fathomContentTypes) {
Set<String> ignoreProduces = new TreeSet<>();
ignoreProduces.add(Produces.TEXT);
ignoreProduces.add(Produces.HTML);
ignoreProduces.add(Produces.XHTML);
for (String produces : declaredProduces) {
if (ignoreProduces.contains(produces)) {
continue;
}
if (!fathomContentTypes.contains(produces)) {
throw new FatalException("{} declares @{}(\"{}\") but there is no registered ContentTypeEngine for that type!",
Util.toString(method), Produces.class.getSimpleName(), produces);
}
}
}
代码示例来源:origin: com.gitblit.fathom/fathom-security
public DomainPermission(String actions) {
domain = getDomain(getClass());
this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
encodeParts(domain, actions, null);
}
代码示例来源:origin: com.gitblit.fathom/fathom-security-htpasswd
@Override
public void start() {
log.debug("Realm '{}' configuration:", getRealmName());
Util.logSetting(log, "file", file);
Util.logSetting(log, "allowClearPasswords", isAllowClearTextPasswords);
}
代码示例来源:origin: gitblit/fathom
Object invokeMethod(Method method, List<Object> methodParameters) throws Exception {
Object[] argValues = null;
if (methodParameters != null) {
argValues = new Object[methodParameters.size()];
for (int i = 0; i < methodParameters.size(); i++) {
argValues[i] = methodParameters.get(i);
}
}
try {
method.setAccessible(true);
return method.invoke(invokeTarget, argValues);
} catch (IllegalAccessException | IllegalArgumentException e) {
throw e;
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
log.error("Failed to execute {}", Util.toString(method), t);
throw new FathomException(t.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!