log.trace("Registering the built-in handlers.");
}
Registry registry = registryService.getRegistry(
CarbonConstants.REGISTRY_SYSTEM_USERNAME);
RegistryContext registryContext = registry.getRegistryContext();
HandlerManager handlerManager = registryContext.getHandlerManager();
if (log.isTraceEnabled()) {
log.trace("Engaging the Operation Statistics Handler.");
}
// handler to record system statistics
OperationStatisticsHandler systemStatisticsHandler = new OperationStatisticsHandler();
URLMatcher systemStatisticsURLMatcher = new URLMatcher();
systemStatisticsURLMatcher.setPattern(".*");
handlerManager.addHandler(null, systemStatisticsURLMatcher, systemStatisticsHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the Comment URL Handler.");
}
// this handler will return the comment for a path ending as ;comments:<number>
CommentURLHandler commentURLHandler = new CommentURLHandler();
URLMatcher commentURLMatcher = new URLMatcher();
commentURLMatcher.setGetPattern(".+;comments:[0-9]+");
commentURLMatcher.setDeletePattern(".+;comments:[0-9]+");
handlerManager.addHandler(
new String[]{Filter.GET, Filter.DELETE}, commentURLMatcher, commentURLHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the Comment Collection URL Handler.");
}
// this will return all the comments for the path if the path ending as ;comments
CommentCollectionURLHandler commentCollectionURLHandler = new CommentCollectionURLHandler();
URLMatcher commentCollectionURLMatcher = new URLMatcher();
commentCollectionURLMatcher.setGetPattern(".+;comments");
handlerManager.addHandler(new String[]{Filter.GET},
commentCollectionURLMatcher, commentCollectionURLHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the Rating URL Handler.");
}
// this will return the rating of a user if the path is ending as ;ratings:<username>
RatingURLHandler ratingURLHandler = new RatingURLHandler();
URLMatcher ratingURLMatcher = new URLMatcher();
ratingURLMatcher.setGetPattern(".+;ratings:.+");
handlerManager.addHandler(new String[]{Filter.GET}, ratingURLMatcher, ratingURLHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the Rating Collection URL Handler.");
}
// this will return all the ratings for a path if the path is ending as ;ratings
RatingCollectionURLHandler ratingCollectionURLHandler = new RatingCollectionURLHandler();
URLMatcher ratingCollectionURLMatcher = new URLMatcher();
ratingCollectionURLMatcher.setGetPattern(".+;ratings");
handlerManager.addHandler(
new String[]{Filter.GET}, ratingCollectionURLMatcher, ratingCollectionURLHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the Tag URL Handler.");
}
// this will return the tags for a path if the path is ending as
// ;tags:<tag-name>:<user-name>
TagURLHandler tagURLHandler = new TagURLHandler();
URLMatcher tagURLMatcher = new URLMatcher();
tagURLMatcher.setGetPattern(".+;.+:.+:.+");
handlerManager.addHandler(new String[]{Filter.GET}, tagURLMatcher, tagURLHandler);
if (log.isTraceEnabled()) {
log.trace("Engaging the SQL Query Handler.");
}
// this will return the results for a custom query if the resource has the
// media type:SQL_QUERY_MEDIA_TYPE
SQLQueryHandler sqlQueryHandler = new SQLQueryHandler();
MediaTypeMatcher sqlMediaTypeMatcher =
new MediaTypeMatcher(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
handlerManager.addHandler(
new String[]{Filter.GET, Filter.PUT}, sqlMediaTypeMatcher, sqlQueryHandler);
// Register Simulation Handler
handlerManager.addHandler(null, new SimulationFilter(), new SimulationHandler(),
HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
if (log.isTraceEnabled()) {
log.trace("Engaging the Cashing Registry Handler.");
}
// handler to cache registry operation results.
CachingHandler cachingHandler = new CachingHandler();
URLMatcher cachingURLMatcher = new URLMatcher();
cachingURLMatcher.setPattern(".*");
handlerManager.addHandler(null, cachingURLMatcher, cachingHandler);
handlerManager.addHandler(null, cachingURLMatcher, cachingHandler,
HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
if (log.isTraceEnabled()) {
log.trace("Engaging the RegexBase Restriction Handler.");
}
// handler to validate registry root's immediate directory paths prior to move and rename operations
Handler regexBaseRestrictionHandler = new RegexBaseRestrictionHandler();
URLMatcher logUrlMatcher = new URLMatcher();
logUrlMatcher.setPattern(".*");
handlerManager.addHandler(new String[] {Filter.RENAME, Filter.MOVE}, logUrlMatcher, regexBaseRestrictionHandler,
HandlerLifecycleManager.DEFAULT_SYSTEM_HANDLER_PHASE);
}