use of lombok.SneakyThrows in project cas by apereo.
the class CasVersion method getDateTime.
/**
* Gets last modified date/time for the module.
*
* @return the date/time
*/
@SneakyThrows
public static ZonedDateTime getDateTime() {
final Class clazz = CasVersion.class;
final URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
if ("file".equals(resource.getProtocol())) {
return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
}
if ("jar".equals(resource.getProtocol())) {
final String path = resource.getPath();
final File file = new File(path.substring(5, path.indexOf('!')));
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
if ("vfs".equals(resource.getProtocol())) {
final File file = new VfsResource(resource.openConnection().getContent()).getFile();
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
LOGGER.warn("Unhandled url protocol: [{}] resource: [{}]", resource.getProtocol(), resource);
return ZonedDateTime.now();
}
use of lombok.SneakyThrows in project admin-console-beta by connexta.
the class GraphQLServlet method query.
private void query(String query, String operationName, Map<String, Object> variables, GraphQLSchema schema, HttpServletRequest req, HttpServletResponse resp, GraphQLContext context) throws IOException {
if (Subject.getSubject(AccessController.getContext()) == null && context.getSubject().isPresent()) {
Subject.doAs(context.getSubject().get(), new PrivilegedAction<Void>() {
@Override
@SneakyThrows
public Void run() {
query(query, operationName, variables, schema, req, resp, context);
return null;
}
});
} else {
runListeners(operationListeners, l -> runListener(l, it -> it.beforeGraphQLOperation(context, operationName, query, variables)));
ExecutionResult executionResult = new GraphQL(schema, getQueryExecutionStrategy(), getMutationExecutionStrategy()).execute(query, operationName, context, transformVariables(schema, query, variables));
List<GraphQLError> errors = executionResult.getErrors();
Object data = executionResult.getData();
String response = mapper.writeValueAsString(createResultFromDataAndErrors(data, errors));
resp.setContentType(APPLICATION_JSON_UTF8);
resp.setStatus(STATUS_OK);
resp.getWriter().write(response);
if (errorsPresent(errors)) {
runListeners(operationListeners, l -> l.onFailedGraphQLOperation(context, operationName, query, variables, data, errors));
} else {
runListeners(operationListeners, l -> l.onSuccessfulGraphQLOperation(context, operationName, query, variables, data));
}
}
}
use of lombok.SneakyThrows in project spring-data-mongodb by spring-projects.
the class ResultsWriter method jsonifyResults.
/**
* Convert {@link RunResult}s to JMH Json representation.
*
* @param results
* @return json string representation of results.
* @see org.openjdk.jmh.results.format.JSONResultFormat
*/
@SneakyThrows
static String jsonifyResults(Collection<RunResult> results) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ResultFormatFactory.getInstance(ResultFormatType.JSON, new PrintStream(baos, true, "UTF-8")).writeOut(results);
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}
use of lombok.SneakyThrows in project cas by apereo.
the class SamlIdPMetadataConfiguration method samlSelfSignedCertificateWriter.
@ConditionalOnMissingBean(name = "samlSelfSignedCertificateWriter")
@Bean
@SneakyThrows
public SamlIdPCertificateAndKeyWriter samlSelfSignedCertificateWriter() {
final URL url = new URL(casProperties.getServer().getPrefix());
final DefaultSamlIdPCertificateAndKeyWriter generator = new DefaultSamlIdPCertificateAndKeyWriter();
generator.setHostname(url.getHost());
generator.setUriSubjectAltNames(CollectionUtils.wrap(url.getHost().concat("/idp/metadata")));
return generator;
}
use of lombok.SneakyThrows in project cas by apereo.
the class AbstractSamlObjectBuilder method newSoapObject.
/**
* New soap object t.
*
* @param <T> the type parameter
* @param objectType the object type
* @return the t
*/
@SneakyThrows
public <T extends SOAPObject> T newSoapObject(final Class<T> objectType) {
final QName qName = getSamlObjectQName(objectType);
final SOAPObjectBuilder<T> builder = (SOAPObjectBuilder<T>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName);
if (builder == null) {
throw new IllegalStateException("No SAML object builder is registered for class " + objectType.getName());
}
return objectType.cast(builder.buildObject(qName));
}
Aggregations