ServletConnectionFactory.java revision 21dcdac963f79c098a5ea1a2c5c5e109429c9786
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014-2015 ForgeRock AS. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/**
* The ConnectionFactory responsible for providing Connections to routing requests initiated
* from an external request on the api servlet.
*/
configurationFactory = false, immediate = true)
@Properties({
@Property(name = Constants.SERVICE_DESCRIPTION, value = "OpenIDM Common REST Servlet Connection Factory")
})
public class ServletConnectionFactory implements ConnectionFactory {
/** Event name prefix for monitoring the router */
/**
* Setup logging for the {@link org.forgerock.openidm.servlet.internal.ServletConnectionFactory}.
*/
// the created connection factory
protected ConnectionFactory connectionFactory;
/** the Request Handler (Router) */
/** Script Registry service. */
/** Enhanced configuration service. */
private EnhancedConfig enhancedConfig;
throw new IllegalArgumentException(
"Factory configuration not allowed, must not have property: "
}
try {
} catch (Throwable t) {
}
}
}
private ConnectionFactory newWrappedInternalConnectionFactory(final ConnectionFactory connectionFactory) {
return new ConnectionFactory() {
public void close() {
}
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
throws ResourceException {
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
throws ResourceException {
try {
} finally {
}
}
.thenAlways(new Runnable() {
public void run() {
}
});
}
};
}
try {
return newResultPromise(getConnection());
} catch (ResourceException e) {
return e.asPromise();
}
}
/**
* @param request the router request
* @return an event name For monitoring purposes
*/
// For query and action group statistics by full URI
// Create has only the component name in the getResourceName to start with
} else {
// For RUD, patch group statistics without the local resource identifier
idContext = request.getResourcePathObject().head(request.getResourcePathObject().size() - 1).toString();
}
.append("/")
.toString();
}
};
}
/**
* Initialize the router with configuration. Supports modifying router configuration.
*
* @param configuration the router configuration listing filters that are installed
* @param handler the request handler (router)
* @param auditFilter the audit filter to attach to the request handler
* @return the RequestHandler decorated with a FilterChain consisting of any filters that are configured
*/
RequestHandler init(JsonValue configuration, final RequestHandler handler, final AuditFilter auditFilter)
throws ScriptException, ResourceException {
final List<Filter> filters = new ArrayList<>(filterConfig.size() + 1); // add one for the logging filter
filters.add(Filters.conditionalFilter(Filters.matchResourcePath("^(?!.*(^audit/)).*$"), auditFilter));
}
}
// filters will always have at least the logging filter
}
/**
* Create a Filter from the filter configuration.
*
* @param config
* the configuration describing a single filter.
* @return a Filter
* @throws org.forgerock.json.JsonValueException
* TODO.
*/
// Require at least one of the following
return null;
}
// Check for condition on pattern
}
// Check for condition on type
}
if (!requestTypes.isEmpty()) {
}
// Create the filter
// Check for a condition script
try {
} catch (ScriptException e) {
}
return false;
}
};
}
return filter;
}
return null;
}
}
new ResultHandler<Response>() {
}
};
new ExceptionHandler<ResourceException>() {
if (logger.isTraceEnabled()) {
logger.trace("Resource exception: {} {}: \"{}\"", exception.getCode(), exception.getReason(), exception.getMessage(), exception);
logger.warn("Resource exception: {} {}: \"{}\"", exception.getCode(), exception.getReason(), exception.getMessage(), exception);
}
}
};
private Filter newLoggingFilter() {
return new Filter() {
public Promise<ActionResponse, ResourceException> filterAction(Context context, ActionRequest request, RequestHandler next) {
}
public Promise<ResourceResponse, ResourceException> filterCreate(Context context, CreateRequest request, RequestHandler next) {
}
public Promise<ResourceResponse, ResourceException> filterDelete(Context context, DeleteRequest request, RequestHandler next) {
}
public Promise<ResourceResponse, ResourceException> filterPatch(Context context, PatchRequest request, RequestHandler next) {
}
public Promise<QueryResponse, ResourceException> filterQuery(Context context, QueryRequest request, QueryResourceHandler handler, RequestHandler next) {
}
public Promise<ResourceResponse, ResourceException> filterRead(Context context, ReadRequest request, RequestHandler next) {
}
public Promise<ResourceResponse, ResourceException> filterUpdate(Context context, UpdateRequest request, RequestHandler next) {
}
};
}
// ----- Implementation of ConnectionFactory
return connectionFactory.getConnection();
}
return connectionFactory.getConnectionAsync();
}
public void close() {
}
}