use of org.xwiki.resource.ResourceType in project xwiki-platform by xwiki.
the class XWikiRequestProcessor method processPath.
@Override
protected String processPath(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
String url = httpServletRequest.getRequestURL().toString();
try {
ExtendedURL extendedURL = new ExtendedURL(new URL(url), httpServletRequest.getContextPath());
ResourceType type = this.typeResolver.resolve(extendedURL, Collections.<String, Object>emptyMap());
EntityResourceReference entityResourceReference = (EntityResourceReference) this.resolver.resolve(extendedURL, type, Collections.<String, Object>emptyMap());
return "/" + entityResourceReference.getAction().getActionName() + "/";
} catch (Exception e) {
throw new IOException(String.format("Failed to extract the Entity Action from URL [%s]", url), e);
}
}
use of org.xwiki.resource.ResourceType in project xwiki-platform by xwiki.
the class IntegrationTest method assertURL.
private void assertURL(String url, ResourceType expectedType, ResourceReference expectedReference) throws Exception {
ExtendedURL extendedURL = new ExtendedURL(new URL(url), "xwiki");
ResourceType resourceType = this.resourceTypeResolver.resolve(extendedURL, Collections.<String, Object>emptyMap());
assertEquals(expectedType.getId(), resourceType.getId());
ResourceReference reference = this.resourceReferenceResolver.resolve(extendedURL, resourceType, Collections.<String, Object>emptyMap());
assertEquals(expectedReference, reference);
}
use of org.xwiki.resource.ResourceType in project xwiki-platform by xwiki.
the class IntegrationTest method extractResourceReference.
@Test
public void extractResourceReference() throws Exception {
// Entity Resource References
assertURL("http://localhost:8080/xwiki/bin/view/space/page", EntityResourceReference.TYPE, new EntityResourceReference(new DocumentReference("xwiki", "space", "page"), EntityResourceAction.VIEW));
assertURL("http://localhost:8080/xwiki/wiki/mywiki/view/space/page", new ResourceType("wiki"), new EntityResourceReference(new DocumentReference("mywiki", "space", "page"), EntityResourceAction.VIEW));
// Resources Resource References
assertURL("http://localhost:8080/xwiki/resources/js/prototype/prototype.js", ResourcesResourceReference.TYPE, new ResourcesResourceReference());
// Skins Resource References
assertURL("http://localhost:8080/xwiki/skins/flamingo/logo.png", SkinsResourceReference.TYPE, new SkinsResourceReference());
}
use of org.xwiki.resource.ResourceType in project xwiki-platform by xwiki.
the class BinEntityResourceReferenceResolverTest method testCreateResource.
private ResourceReference testCreateResource(String testURL, String expectedActionName, EntityReference expectedReference, EntityReference returnedReference, EntityType expectedEntityType) throws Exception {
when(this.entityReferenceResolver.resolve(expectedReference, expectedEntityType)).thenReturn(returnedReference);
ExtendedURL extendedURL = new ExtendedURL(new URL(testURL), null);
// Remove the resource type segment since this is what gets passed to specific Reference Resolvers.
extendedURL.getSegments().remove(0);
EntityResourceReference entityResource = this.resolver.resolve(extendedURL, new ResourceType("bin"), Collections.<String, Object>emptyMap());
assertEquals(expectedActionName, entityResource.getAction().getActionName());
assertEquals(returnedReference, entityResource.getEntityReference());
return entityResource;
}
use of org.xwiki.resource.ResourceType in project xwiki-platform by xwiki.
the class WikiEntityResourceReferenceResolverTest method testCreateResource.
private ResourceReference testCreateResource(String testURL, String expectedActionName, EntityReference expectedReference, EntityReference returnedReference, EntityType expectedEntityType) throws Exception {
when(this.entityReferenceResolver.resolve(expectedReference, expectedEntityType)).thenReturn(returnedReference);
ExtendedURL extendedURL = new ExtendedURL(new URL(testURL), null);
// Remove the resource type segment since this is what gets passed to specific Reference Resolvers.
extendedURL.getSegments().remove(0);
EntityResourceReference entityResource = this.resolver.resolve(extendedURL, new ResourceType("wiki"), Collections.<String, Object>emptyMap());
assertEquals(expectedActionName, entityResource.getAction().getActionName());
assertEquals(returnedReference, entityResource.getEntityReference());
return entityResource;
}
Aggregations