Source:
public Response provideAsPlugin( @ApiParam("Name of the handle retrieved from upload") @PathParam("handle") String handle, @ApiParam("Name of the plugin file") @QueryParam("name") String name, @ApiParam("Should a discovery scan be started?") @QueryParam("scan") @DefaultValue("false") boolean startScan, @ApiParam(value = "The delay in millis before the agents update their plugins. Any negative value disables " + "the automatic update of agents", defaultValue = "-1") @QueryParam("pushOutDelay") @DefaultValue("-1") long pushOutDelay, @Context HttpHeaders headers ) { if (name==null || name.isEmpty()) { throw new BadArgumentException("A valid 'name' must be given"); } File content = getFileForHandle(handle); if (!content.exists() || !content.canRead()) { throw new StuffNotFoundException("Content with handle " + handle); } Response.ResponseBuilder builder; try { boolean isAllowed = LookupUtil.getAuthorizationManager().hasGlobalPermission(caller, Permission.MANAGE_SETTINGS); if (!isAllowed) { log.error("An unauthorized user [" + caller + "] attempted to upload a plugin"); throw new PermissionException("You are not authorized to do this"); } File dir = LookupUtil.getPluginManager().getPluginDropboxDirectory(); File targetFile = new File(dir,name); FileOutputStream fos = new FileOutputStream(targetFile); try { FileInputStream fis = new FileInputStream(content); try { StreamUtil.copy(fis, fos); } finally { fis.close(); } } finally { fos.close(); } if (startScan) { PluginDeploymentScannerMBean scanner = LookupUtil.getPluginDeploymentScanner(); scanner.scanAndRegister(); } if (pushOutDelay >= 0) { LookupUtil.getPluginManager().schedulePluginUpdateOnAgents(caller, pushOutDelay); } builder=Response.ok(); } catch (Exception e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); builder.entity(e.getMessage()); } MediaType mediaType = headers.getAcceptableMediaTypes().get(0); builder.type(mediaType); return builder.build(); }

Target:
public Response provideAsPlugin( @ApiParam("Name of the handle retrieved from upload") @PathParam("handle") String handle, @ApiParam("Name of the plugin file") @QueryParam("name") String name, @ApiParam("Should a discovery scan be started?") @QueryParam("scan") @DefaultValue("false") boolean startScan, @ApiParam(value = "The delay in millis before the agents update their plugins. Any negative value disables " + "the automatic update of agents", defaultValue = "-1") @QueryParam("pushOutDelay") @DefaultValue("-1") long pushOutDelay, @Context HttpHeaders headers ) { if (name==null || name.isEmpty()) { throw new BadArgumentException("A valid 'name' must be given"); } File content = getFileForHandle(handle); if (!content.exists() || !content.canRead()) { throw new StuffNotFoundException("Content with handle " + handle); } Response.ResponseBuilder builder; try { boolean isAllowed = LookupUtil.getAuthorizationManager().hasGlobalPermission(caller, Permission.MANAGE_SETTINGS); if (!isAllowed) { log.error("An unauthorized user [" + caller + "] attempted to upload a plugin"); throw new PermissionException("You are not authorized to do this"); } if (pushOutDelay >= 0 && !startScan) { throw new BadArgumentException( "Pushing changes to agents without starting a scan for changes first doesn't make sense."); } File dir = LookupUtil.getPluginManager().getPluginDropboxDirectory(); File targetFile = new File(dir,name); FileOutputStream fos = new FileOutputStream(targetFile); try { FileInputStream fis = new FileInputStream(content); try { StreamUtil.copy(fis, fos); } finally { fis.close(); } } finally { fos.close(); } if (startScan) { PluginDeploymentScannerMBean scanner = LookupUtil.getPluginDeploymentScanner(); scanner.scanAndRegister(); } if (pushOutDelay >= 0) { LookupUtil.getPluginManager().schedulePluginUpdateOnAgents(caller, pushOutDelay); } builder=Response.ok(); } catch (Exception e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); builder.entity(e.getMessage()); } MediaType mediaType = headers.getAcceptableMediaTypes().get(0); builder.type(mediaType); return builder.build(); }