@Test public void uploadComponentIsHiddenWhenFeatureFlagIsNotEnabled() throws Exception { when(uploadConfiguration.isEnabled()).thenReturn(false); try { underTest.uploadComponent(mavenReleasesId, null); fail("Expected a WebApplicationException(NOT_FOUND) to be thrown"); } catch (WebApplicationException e) { assertThat(e.getResponse(), is(CoreMatchers.notNullValue())); assertThat(e.getResponse().getStatus(), is(404)); } }
@Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void uploadComponent(@QueryParam("repository") final String repositoryId, @Context final HttpServletRequest request) throws IOException { if (!uploadConfiguration.isEnabled()) { throw new WebApplicationException(NOT_FOUND); } Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryId); try { uploadManager.handle(repository, request); } catch (IllegalOperationException e) { throw new WebApplicationMessageException(Status.BAD_REQUEST, e.getMessage()); } }
ComponentsResource extends ComponentSupport implements Resource, ComponentsResourceDoc { @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void uploadComponent(@QueryParam("repository") final String repositoryId, @Context final HttpServletRequest request) throws IOException { if (!uploadConfiguration.isEnabled()) { throw new WebApplicationException(NOT_FOUND); } Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryId); try { uploadManager.handle(repository, request); } catch (IllegalOperationException e) { throw new WebApplicationMessageException(Status.BAD_REQUEST, e.getMessage()); } } }
ComponentsResource extends ComponentSupport implements Resource, ComponentsResourceDoc { @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void uploadComponent(@QueryParam("repository") final String repositoryId, @Context final HttpServletRequest request) throws IOException { if (!uploadConfiguration.isEnabled()) { throw new WebApplicationException(NOT_FOUND); } Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryId); try { uploadManager.handle(repository, request); } catch (IllegalOperationException e) { throw new WebApplicationMessageException(Status.BAD_REQUEST, e.getMessage()); } } @Inject  ComponentsResource(final RepositoryManagerRESTAdapter repositoryManagerRESTAdapter,
                            final BrowseService browseService,
                            final ComponentEntityAdapter componentEntityAdapter,
                            final MaintenanceService maintenanceService,
                            @Named("component") final ContinuationTokenHelper continuationTokenHelper,
                            final UploadManager uploadManager,
                            final UploadConfiguration uploadConfiguration,
                            final ComponentXOFactory componentXOFactory,
                            final Set<ComponentsResourceExtension> componentsResourceExtensions); }
ComponentsResource extends ComponentSupport implements Resource, ComponentsResourceDoc { @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void uploadComponent(@QueryParam("repository") final String repositoryId, @Context final HttpServletRequest request) throws IOException { if (!uploadConfiguration.isEnabled()) { throw new WebApplicationException(NOT_FOUND); } Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryId); try { uploadManager.handle(repository, request); } catch (IllegalOperationException e) { throw new WebApplicationMessageException(Status.BAD_REQUEST, e.getMessage()); } } @Inject  ComponentsResource(final RepositoryManagerRESTAdapter repositoryManagerRESTAdapter,
                            final BrowseService browseService,
                            final ComponentEntityAdapter componentEntityAdapter,
                            final MaintenanceService maintenanceService,
                            @Named("component") final ContinuationTokenHelper continuationTokenHelper,
                            final UploadManager uploadManager,
                            final UploadConfiguration uploadConfiguration,
                            final ComponentXOFactory componentXOFactory,
                            final Set<ComponentsResourceExtension> componentsResourceExtensions); @Override @GET Page<ComponentXO> getComponents(@QueryParam("continuationToken") final String continuationToken,
                                         @QueryParam("repository") final String repositoryId); @Override @GET @Path("/{id}") ComponentXO getComponentById(@PathParam("id") final String id); @Override @DELETE @Path("/{id}") void deleteComponent(@PathParam("id") final String id); @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) void uploadComponent(@QueryParam("repository") final String repositoryId,
                              @Context final HttpServletRequest request); }
ComponentsResource extends ComponentSupport implements Resource, ComponentsResourceDoc { @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void uploadComponent(@QueryParam("repository") final String repositoryId, @Context final HttpServletRequest request) throws IOException { if (!uploadConfiguration.isEnabled()) { throw new WebApplicationException(NOT_FOUND); } Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryId); try { uploadManager.handle(repository, request); } catch (IllegalOperationException e) { throw new WebApplicationMessageException(Status.BAD_REQUEST, e.getMessage()); } } @Inject  ComponentsResource(final RepositoryManagerRESTAdapter repositoryManagerRESTAdapter,
                            final BrowseService browseService,
                            final ComponentEntityAdapter componentEntityAdapter,
                            final MaintenanceService maintenanceService,
                            @Named("component") final ContinuationTokenHelper continuationTokenHelper,
                            final UploadManager uploadManager,
                            final UploadConfiguration uploadConfiguration,
                            final ComponentXOFactory componentXOFactory,
                            final Set<ComponentsResourceExtension> componentsResourceExtensions); @Override @GET Page<ComponentXO> getComponents(@QueryParam("continuationToken") final String continuationToken,
                                         @QueryParam("repository") final String repositoryId); @Override @GET @Path("/{id}") ComponentXO getComponentById(@PathParam("id") final String id); @Override @DELETE @Path("/{id}") void deleteComponent(@PathParam("id") final String id); @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) void uploadComponent(@QueryParam("repository") final String repositoryId,
                              @Context final HttpServletRequest request); static final String RESOURCE_URI; }