public void moveItem( ResourceStoreRequest from, ResourceStoreRequest to ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { copyItem( from, to ); deleteItem( from ); }
public StorageItem dereferenceLink( StorageLinkItem link ) throws AccessDeniedException, ItemNotFoundException, IllegalOperationException, StorageException { return dereferenceLink( link, false, false ); }
protected void initializeConfiguration() throws ConfigurationException { if ( getApplicationConfiguration().getConfigurationModel() != null ) { configure( getApplicationConfiguration() ); } }
public void createCollection( ResourceStoreRequest request, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().createCollection( request, userAttributes ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }
public StorageItem retrieveItem( ResourceStoreRequest request ) throws ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it StorageItem item; try { request.pushRequestPath( route.getRepositoryPath() ); item = route.getTargetedRepository().retrieveItem( request ); } finally { request.popRequestPath(); } return mangle( false, request, route, item ); } else { // this is "above" repositories return retrieveVirtualPath( request, route ); } }
public Collection<StorageItem> list( ResourceStoreRequest request ) throws ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it Collection<StorageItem> items; try { request.pushRequestPath( route.getRepositoryPath() ); items = route.getTargetedRepository().list( request ); } finally { request.popRequestPath(); } ArrayList<StorageItem> result = new ArrayList<StorageItem>( items.size() ); for ( StorageItem item : items ) { result.add( mangle( true, request, route, item ) ); } return result; } else { // this is "above" repositories return listVirtualPath( request, route ); } }
public boolean authorizePath( ResourceStoreRequest request, Action action ) TargetSet matched = this.getTargetsForRequest( request ); RequestRoute route = this.getRequestRouteForRequest( request ); if ( route.getTargetedRepository() != null ) request.pushRequestPath( route.getOriginalRequestPath() ); matched.addTargetSet( this.itemAuthorizer.getGroupsTargetSet( route.getTargetedRepository(), request ) );
public StorageItem dereferenceLinkItem( StorageLinkItem item ) throws NoSuchResourceStoreException, ItemNotFoundException, AccessDeniedException, IllegalOperationException, StorageException { return getRootRouter().dereferenceLink( item ); }
protected StorageItem mangle( boolean isList, ResourceStoreRequest request, RequestRoute route, StorageItem item ) throws AccessDeniedException, ItemNotFoundException, IllegalOperationException, StorageException { if ( isList ) { ( (AbstractStorageItem) item ).setPath( ItemPathUtils.concatPaths( route.getOriginalRequestPath(), item.getName() ) ); } else { ( (AbstractStorageItem) item ).setPath( route.getOriginalRequestPath() ); } if ( isFollowLinks() && item instanceof StorageLinkItem ) { return dereferenceLink( (StorageLinkItem) item ); } else { return item; } }
@Override public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { // let check the mappedValues 1st boolean result = false; if (mappedValue != null) { result = super.isAccessAllowed(request, response, mappedValue); // if we are not allowed at start, forbid it if (!result) { return false; } } String actionVerb = getHttpMethodAction(request); Action action = Action.valueOf(actionVerb); if (null == action) { return false; } return rootRouter.authorizePath(getResourceStoreRequest(request, false), action); } }
public void setFollowLinks( boolean followLinks ) { getCurrentConfiguration( true ).setResolveLinks( followLinks ); }
@Override protected CRouting getCurrentConfiguration( boolean forWrite ) { return ( (CRoutingCoreConfiguration) getCurrentCoreConfiguration() ).getConfiguration( forWrite ); }
protected StorageItem retrieveVirtualPath( ResourceStoreRequest request, RequestRoute route ) throws ItemNotFoundException { ResourceStoreRequest req = new ResourceStoreRequest( route.getOriginalRequestPath() ); DefaultStorageCollectionItem result = new DefaultStorageCollectionItem( this, req, true, false ); result.getItemContext().putAll( request.getRequestContext() ); return result; }
@Override protected void doDelete(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final ResourceStoreRequest rsr = getResourceStoreRequest(request); try { repositoryRouter.deleteItem(rsr); response.setStatus(HttpServletResponse.SC_NO_CONTENT); ((Stopwatch) rsr.getRequestContext().get(STOPWATCH_KEY)).stop(); } catch (Exception e) { ((Stopwatch) rsr.getRequestContext().get(STOPWATCH_KEY)).stop(); handleException(request, response, rsr, e); } }
public TargetSet getTargetsForRequest( ResourceStoreRequest request ) { TargetSet result = new TargetSet(); try { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); result.addTargetSet( route.getTargetedRepository().getTargetsForRequest( request ) ); } finally { request.popRequestPath(); } } } catch ( ItemNotFoundException e ) { // nothing, empty set will be returned } return result; }
@VisibleForTesting Object renderStorageLinkItem(final Context context, final Request req, final Response res, final Variant variant, final ResourceStore store, final StorageLinkItem item) throws ResourceException { // we have a link, dereference it // TODO: we should be able to do HTTP redirects too! (parametrize the dereferencing?) try { return renderItem(context, req, res, variant, store, getRepositoryRouter().dereferenceLink(item)); } catch (Exception e) { handleException(req, res, e); return null; } }
@Override public boolean isAccessAllowed( ServletRequest request, ServletResponse response, Object mappedValue ) throws IOException { // let check the mappedValues 1st boolean result = false; if ( mappedValue != null ) { result = super.isAccessAllowed( request, response, mappedValue ); // if we are not allowed at start, forbid it if ( !result ) { return false; } } String actionVerb = getHttpMethodAction( request ); Action action = Action.valueOf( actionVerb ); if ( null == action ) { return false; } return rootRouter.authorizePath( getResourceStoreRequest( request, false ), action ); } }
public boolean isFollowLinks() { return getCurrentConfiguration( false ).isResolveLinks(); }
public void storeItem( ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().storeItem( request, is, userAttributes ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }
public void deleteItem( ResourceStoreRequest request ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().deleteItem( request ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }