@Test public void testHandle() throws IOException { ComponentUpload component = createComponentUpload(PACKAGE_PATH, PACKAGE_NAME); UploadResponse uploadResponse = underTest.handle(repository, component); assertThat(uploadResponse.getAssetPaths(), contains(PACKAGE_PATH_FULL)); assertThat(uploadResponse.getComponentId().getValue(), is(NU_ID)); verify(contentPermissionChecker).isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), captor.capture()); VariableSource source = captor.getValue(); assertThat(source.get("format"), is(Optional.of(RFormat.NAME))); assertThat(source.get("path"), is(Optional.of(PACKAGE_PATH_FULL))); }
@Override public UploadResponse handle(final Repository repository, final ComponentUpload upload) throws IOException { final AssetUpload assetUpload = upload.getAssetUploads().get(0); final PartPayload payload = assetUpload.getPayload(); final Map<String, String> fields = assetUpload.getFields(); final String uploadPath = removeInitialSlashFromPath(fields.get(PATH_ID)); final String assetPath = buildPath(uploadPath, payload.getName()); ensurePermitted(repository.getName(), RFormat.NAME, assetPath, Collections.emptyMap()); validateArchiveUploadPath(assetPath); try { UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); Asset asset = repository.facet(RHostedFacet.class).upload(assetPath, payload); return new UploadResponse(asset); } finally { UnitOfWork.end(); } }
RUploadHandler extends UploadHandlerSupport { @Override public UploadResponse handle(final Repository repository, final ComponentUpload upload) throws IOException { final AssetUpload assetUpload = upload.getAssetUploads().get(0); final PartPayload payload = assetUpload.getPayload(); final Map<String, String> fields = assetUpload.getFields(); final String uploadPath = removeInitialSlashFromPath(fields.get(PATH_ID)); final String assetPath = buildPath(uploadPath, payload.getName()); ensurePermitted(repository.getName(), RFormat.NAME, assetPath, Collections.emptyMap()); validateArchiveUploadPath(assetPath); try { UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); Asset asset = repository.facet(RHostedFacet.class).upload(assetPath, payload); return new UploadResponse(asset); } finally { UnitOfWork.end(); } } }
RUploadHandler extends UploadHandlerSupport { @Override public UploadResponse handle(final Repository repository, final ComponentUpload upload) throws IOException { final AssetUpload assetUpload = upload.getAssetUploads().get(0); final PartPayload payload = assetUpload.getPayload(); final Map<String, String> fields = assetUpload.getFields(); final String uploadPath = removeInitialSlashFromPath(fields.get(PATH_ID)); final String assetPath = buildPath(uploadPath, payload.getName()); ensurePermitted(repository.getName(), RFormat.NAME, assetPath, Collections.emptyMap()); validateArchiveUploadPath(assetPath); try { UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); Asset asset = repository.facet(RHostedFacet.class).upload(assetPath, payload); return new UploadResponse(asset); } finally { UnitOfWork.end(); } } @Inject  RUploadHandler(@Named("simple") final VariableResolverAdapter variableResolverAdapter,
                        final ContentPermissionChecker contentPermissionChecker,
                        final Set<UploadDefinitionExtension> uploadDefinitionExtensions); }
RUploadHandler extends UploadHandlerSupport { @Override public UploadResponse handle(final Repository repository, final ComponentUpload upload) throws IOException { final AssetUpload assetUpload = upload.getAssetUploads().get(0); final PartPayload payload = assetUpload.getPayload(); final Map<String, String> fields = assetUpload.getFields(); final String uploadPath = removeInitialSlashFromPath(fields.get(PATH_ID)); final String assetPath = buildPath(uploadPath, payload.getName()); ensurePermitted(repository.getName(), RFormat.NAME, assetPath, Collections.emptyMap()); validateArchiveUploadPath(assetPath); try { UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); Asset asset = repository.facet(RHostedFacet.class).upload(assetPath, payload); return new UploadResponse(asset); } finally { UnitOfWork.end(); } } @Inject  RUploadHandler(@Named("simple") final VariableResolverAdapter variableResolverAdapter,
                        final ContentPermissionChecker contentPermissionChecker,
                        final Set<UploadDefinitionExtension> uploadDefinitionExtensions); @Override UploadResponse handle(final Repository repository, final ComponentUpload upload); @Override UploadDefinition getDefinition(); @Override VariableResolverAdapter getVariableResolverAdapter(); @Override ContentPermissionChecker contentPermissionChecker(); }
RUploadHandler extends UploadHandlerSupport { @Override public UploadResponse handle(final Repository repository, final ComponentUpload upload) throws IOException { final AssetUpload assetUpload = upload.getAssetUploads().get(0); final PartPayload payload = assetUpload.getPayload(); final Map<String, String> fields = assetUpload.getFields(); final String uploadPath = removeInitialSlashFromPath(fields.get(PATH_ID)); final String assetPath = buildPath(uploadPath, payload.getName()); ensurePermitted(repository.getName(), RFormat.NAME, assetPath, Collections.emptyMap()); validateArchiveUploadPath(assetPath); try { UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); Asset asset = repository.facet(RHostedFacet.class).upload(assetPath, payload); return new UploadResponse(asset); } finally { UnitOfWork.end(); } } @Inject  RUploadHandler(@Named("simple") final VariableResolverAdapter variableResolverAdapter,
                        final ContentPermissionChecker contentPermissionChecker,
                        final Set<UploadDefinitionExtension> uploadDefinitionExtensions); @Override UploadResponse handle(final Repository repository, final ComponentUpload upload); @Override UploadDefinition getDefinition(); @Override VariableResolverAdapter getVariableResolverAdapter(); @Override ContentPermissionChecker contentPermissionChecker();  }