* @return a ResponseContext indicating the disposition of the request
*/
@SuppressWarnings({"ConstantConditions"})
public ResponseContext extensionRequest(RequestContext request) {
Target target = request.getTarget();
final TargetType type = target.getType();
if (!(target instanceof ResourceTarget)) {
if (type.equals(ResponseTarget.RESPONSE_TYPE)) {
return ((ResponseTarget) target).getResponse();
}
// Deal with non-resource URLs, like "/tags..."
if (type.equals(RegistryResolver.TAG_URL_TYPE)) {
return processTagURLRequest(request);
}
}
Resource resource = ((ResourceTarget) target).getResource();
String path = resource.getPath();
if (type.equals(RegistryResolver.TAGS_TYPE)) {
return processTagsRequest(request, path);
}
if (type.equals(RegistryResolver.LOGS_TYPE)) {
return processLogsRequest(request, path);
}
if (type.equals(RegistryResolver.RATINGS_TYPE)) {
return processRatingsRequest(request, path);
}
if (type.equals(RegistryResolver.VERSIONS_TYPE)) {
return processVersionsRequest(request, path);
}
if (type.equals(RegistryResolver.RENAME_TYPE)) {
return processRenameRequest(request, path);
}
if (type.equals(RegistryResolver.COPY_TYPE)) {
return processCopyRequest(request, path);
}
if (type.equals(RegistryResolver.MOVE_TYPE)) {
return processMoveRequest(request, path);
}
if (type.equals(RegistryResolver.DELETE_TYPE)) {
return processDeleteRequest(request, path);
}
if (type.equals(RegistryResolver.QUERY_TYPE)) {
return processQueryRequest(request, path);
}
if (type.equals(RegistryResolver.COLLECTION_CUSTOM_TYPE)) {
if (request.getMethod().equals("HEAD")) {
// Doing a HEAD on a collection
try {
return buildHeadEntryResponse(request, getId(resource),
resource.getLastModified());
} catch (ResponseContextException e) {
log.error(e);
return e.getResponseContext();
}
}
// Must be a PUT.
return putCollection(request, path);
}
if (type.equals(RegistryResolver.ASSOCIATIONS_TYPE)) {
String temp = resource.getPermanentPath();
if (temp == null) {
temp = resource.getPath();
}
return processAssociationRequest(request, temp);
}
if (type.equals(RegistryResolver.COMMENTS_TYPE)) {
return processCommentsRequest(request, path);
}
if (type.equals(RegistryResolver.RESTORE_TYPE)) {
try {
getSecureRegistry(request).restoreVersion(resource.getPermanentPath());
} catch (RegistryException e) {
return new StackTraceResponseContext(e);
}
return new EmptyResponseContext(200);
}
if (type.equals(RegistryResolver.ASPECT_TYPE)) {
return processAspectRequest(request, path);
}
if (type.equals(RegistryResolver.CHECKPOINT_TYPE)) {
return processCheckpointRequest(request, path);
}
// Deal with imports
if (type.equals(RegistryResolver.IMPORT_TYPE)) {
return processImportRequest(request, path);
}
// handle dump, restore request.
if (type.equals(RegistryResolver.DUMP_TYPE)) {
return processDumpRequest(request, path);
}
return null;
}