@Consumes(MediaType.APPLICATION_JSON) @Path("/{projectName}/statuses/{commit}") @POST public Response save(@PathParam("projectName") String projectName, @PathParam("commit") String commit, Map<String, String> commitStatus, @Context UriInfo uriInfo) { Project project = getProject(projectName); if (!SecurityUtils.canWrite(project)) throw new UnauthorizedException(); String state = commitStatus.get("state").toUpperCase(); if (state.equals("PENDING")) state = "RUNNING"; Verification verification = new Verification(Verification.Status.valueOf(state), new Date(), commitStatus.get("description"), commitStatus.get("target_url")); String context = commitStatus.get("context"); if (context == null) context = "default"; verificationManager.saveVerification(project, commit, context, verification); UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder(); uriBuilder.path(context); commitStatus.put("id", "1"); return Response.created(uriBuilder.build()).entity(commitStatus).type(RestConstants.JSON_UTF8).build(); }
@PUT @Path("/log/change-level/{loggerName}/{newLevel}") public Response changeLogLevel(@PathParam("loggerName") String loggerName, @PathParam("newLevel") String newLevel) { LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); LoggerConfig loggerConfig = config.getLoggerConfig(loggerName); if (loggerConfig.getName().equals(LogManager.ROOT_LOGGER_NAME)) { return Response.ok("Not found", MediaType.TEXT_PLAIN).build(); } loggerConfig.setLevel(Level.valueOf(newLevel)); ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig. return Response.ok("Done", MediaType.TEXT_PLAIN).build(); }
@GET @Path("/products/{id}") @Produces(MediaType.APPLICATION_JSON) public Response getProduct(@PathParam("id") Long id) { return getProductStore().get(id).map(p -> Response.ok(p).build()) .orElse(Response.status(Status.NOT_FOUND).build()); }
@ApiOperation(value = "Creates a new appliance software version for a software function model", notes = "Creates a new appliance software version for a software function model", response = BaseResponse.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) }) @Path("/{applianceId}/versions") @POST public Response createApplianceSoftwareVersion(@Context HttpHeaders headers, @ApiParam(value = "Id of the Appliance Model", required = true) @PathParam("applianceId") Long applianceId, @ApiParam(required = true) ApplianceSoftwareVersionDto asvDto) { logger.info("Creating an Appliance Software Version"); this.userContext.setUser(OscAuthFilter.getUsername(headers)); this.apiUtil.setIdAndParentIdOrThrow(asvDto, null, applianceId, "Appliance Sofftware Version"); return this.apiUtil.getResponseForBaseRequest(this.addApplianceSoftwareVersionService, new BaseRequest<ApplianceSoftwareVersionDto>(asvDto)); }
@GET @Path("{planId}") @Produces({ MediaType.TEXT_HTML }) public Response getPlanAsHtml( @PathParam("serviceProviderId") final String serviceProviderId, @PathParam("planId") final String planId ) throws ServletException, IOException, URISyntaxException { // Start of user code getPlanAsHtml_init // End of user code final Plan aPlan = PlannerReasonerManager.getPlan(httpServletRequest, serviceProviderId, planId); if (aPlan != null) { httpServletRequest.setAttribute("aPlan", aPlan); // Start of user code getPlanAsHtml_setAttributes // End of user code RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/se/ericsson/cf/scott/sandbox/plan.jsp"); rd.forward(httpServletRequest,httpServletResponse); } throw new WebApplicationException(Status.NOT_FOUND); }
@DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Person deletePerson(@PathParam("id") String id) { Person PersonResponse = Person_Service.deletePerson(id); return PersonResponse; }
@GET @Path("places/{placeId}") @Produces({ MediaType.TEXT_HTML }) public Response getPlaceAsHtml( @PathParam("serviceProviderId") final String serviceProviderId, @PathParam("placeId") final String placeId ) throws ServletException, IOException, URISyntaxException { // Start of user code getPlaceAsHtml_init // End of user code final Place aPlace = WarehouseControllerManager.getPlace(httpServletRequest, serviceProviderId, placeId); if (aPlace != null) { httpServletRequest.setAttribute("aPlace", aPlace); // Start of user code getPlaceAsHtml_setAttributes // End of user code RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/se/ericsson/cf/scott/sandbox/place.jsp"); rd.forward(httpServletRequest,httpServletResponse); } throw new WebApplicationException(Status.NOT_FOUND); }
@GET @Path("{NestedLraId}/status") public Response getNestedLRAStatus(@PathParam("NestedLraId")String nestedLraId) { if (!lraService.hasTransaction(nestedLraId)) { // it must have compensated TODO maybe it's better to keep nested LRAs in separate collection return Response.ok(CompensatorStatus.Compensated.name()).build(); } Transaction lra = lraService.getTransaction(toURL(nestedLraId)); CompensatorStatus status = lra.getLRAStatus(); if (status == null || lra.getLRAStatus() == null) { LRALogger.i18NLogger.error_cannotGetStatusOfNestedLra(nestedLraId, lra.getId()); throw new IllegalLRAStateException(nestedLraId, "The LRA is still active", "getNestedLRAStatus"); } return Response.ok(lra.getLRAStatus().name()).build(); }
@GET @Path("/{file}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Get Presto log file") @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved logs"), @ApiResponse(code = 400, message = "Invalid parameters"), @ApiResponse(code = 404, message = "Resource not found")}) public Response getLog( @PathParam("file") @ApiParam("The name of a file") String file, @QueryParam("from") @ApiParam("Ignore logs before this date") Instant fromDate, @QueryParam("to") @ApiParam("Ignore logs after this date") Instant toDate, @QueryParam("level") @ApiParam("Only get logs of this level") @DefaultValue(LogsHandler.DEFAULT_LOG_LEVEL) String level, @QueryParam("n") @ApiParam("The maximum number of log entries to get") Integer maxEntries) { return logsHandler.getLogs(file, fromDate, toDate, level, maxEntries); }
/** * Update a named token with a new generated one. * * @param name * Token to update. * @return the new generated token. */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Path("{name:[\\w\\-\\.]+}") public String update(@PathParam("name") final String name) throws GeneralSecurityException { final SystemApiToken entity = repository.findByUserAndName(securityHelper.getLogin(), name); if (entity == null) { // No token with given name throw new EntityNotFoundException(); } // Token has been found, update it final String token = newToken(entity); repository.saveAndFlush(entity); return token; }
@PUT @Path("file_format/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public FileFormatUI saveFormatSettings(FileFormat fileFormat, @PathParam("path") String path) throws FileNotFoundException, HomeNotFoundException, NamespaceException { FilePath filePath = FilePath.fromURLPath(homeName, path); // merge file configs final DatasetConfig existingDSConfig = namespaceService.getDataset(filePath.toNamespaceKey()); final FileConfig oldConfig = toFileConfig(existingDSConfig); final FileConfig newConfig = fileFormat.asFileConfig(); newConfig.setCtime(oldConfig.getCtime()); newConfig.setFullPathList(oldConfig.getFullPathList()); newConfig.setName(oldConfig.getName()); newConfig.setOwner(oldConfig.getOwner()); newConfig.setLocation(oldConfig.getLocation()); catalogService.createOrUpdateDataset(namespaceService, new NamespaceKey(HomeFileConfig.HOME_PLUGIN_NAME), filePath.toNamespaceKey(), toDatasetConfig(newConfig, DatasetType.PHYSICAL_DATASET_HOME_FILE, securityContext.getUserPrincipal().getName(), existingDSConfig.getId())); return new FileFormatUI(FileFormat.getForFile(newConfig), filePath); }
@ApiOperation(value = "Deletes a Security Function Software Version", notes = "Deletes a Security Function Software Version if not referenced by any Distributed Appliances") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) }) @Path("/{applianceId}/versions/{ApplianceSoftwareVersionId}") @DELETE public Response deleteApplianceSoftwareVersion(@Context HttpHeaders headers, @ApiParam(value = "Id of the Appliance Model", required = true) @PathParam("applianceId") Long applianceId, @ApiParam(value = "Id of the Appliance Software Version", required = true) @PathParam("ApplianceSoftwareVersionId") Long applianceSoftwareVersionId) { logger.info( "Deleting Appliance Software Version " + applianceSoftwareVersionId + " from appliance " + applianceId); this.userContext.setUser(OscAuthFilter.getUsername(headers)); return this.apiUtil.getResponseForBaseRequest(this.deleteApplianceSoftwareVersionService, new BaseIdRequest(applianceSoftwareVersionId, applianceId)); }
@GET @Path("{resourceShapePath}") @Produces({ MediaType.TEXT_HTML }) public Response getResourceShapeAsHtml( @PathParam("resourceShapePath") final String resourceShapePath ) throws ServletException, IOException, URISyntaxException, OslcCoreApplicationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { final Class<?> resourceClass = Application.getResourceShapePathToResourceClassMap().get(resourceShapePath); ResourceShape aResourceShape = null; if (resourceClass != null) { aResourceShape = (ResourceShape) resourceClass.getMethod("createResourceShape").invoke(null); httpServletRequest.setAttribute("aResourceShape", aResourceShape); RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/se/ericsson/cf/scott/sandbox/resourceshape.jsp"); rd.forward(httpServletRequest,httpServletResponse); } throw new WebApplicationException(Status.NOT_FOUND); }
@GET @Produces({"application/xml", "application/json"}) @Path("/recent/region/producttype/{regionName}/{productTypeId}") public List<LiveSalesList> findRecentRegionProductType(@PathParam("regionName") String regionName, @PathParam("productTypeId") Integer productTypeId) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); javax.persistence.criteria.CriteriaQuery cq = cb.createQuery(); Root<LiveSalesList> liveSalesList = cq.from(LiveSalesList.class); cq.select(liveSalesList); cq.where(cb.and( cb.equal(liveSalesList.get(LiveSalesList_.productTypeId), productTypeId), cb.equal(liveSalesList.get(LiveSalesList_.region), regionName) )); Query q = getEntityManager().createQuery(cq); q.setMaxResults(500); return q.getResultList(); }
@POST @Path("/folder/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Folder createFolder(FolderName name, @PathParam("path") String path) throws Exception { String fullPath = PathUtils.toFSPathString(Arrays.asList(path, name.toString())); FolderPath folderPath = FolderPath.fromURLPath(homeName, fullPath); final FolderConfig folderConfig = new FolderConfig(); folderConfig.setFullPathList(folderPath.toPathList()); folderConfig.setName(folderPath.getFolderName().getName()); try { namespaceService.addOrUpdateFolder(folderPath.toNamespaceKey(), folderConfig); } catch(NamespaceNotFoundException nfe) { throw new ClientErrorException("Parent folder doesn't exist", nfe); } return newFolder(folderPath, folderConfig, null); }
@GET @Produces({"application/xml", "application/json"}) @Path("/recent/region/producttype/{regionName}/{productTypeId}/{orderLineId}") public List<LiveSalesList> findRecentRegionProductTypeFrom(@PathParam("regionName") String regionName, @PathParam("productTypeId") Integer productTypeId, @PathParam("orderLineId") Integer orderLineId) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); javax.persistence.criteria.CriteriaQuery cq = cb.createQuery(); Root<LiveSalesList> liveSalesList = cq.from(LiveSalesList.class); cq.select(liveSalesList); cq.where(cb.and( cb.equal(liveSalesList.get(LiveSalesList_.productTypeId), productTypeId), cb.equal(liveSalesList.get(LiveSalesList_.region), regionName), cb.gt(liveSalesList.get(LiveSalesList_.orderLineId), orderLineId) )); Query q = getEntityManager().createQuery(cq); q.setMaxResults(500); return q.getResultList(); }
/** * Box単位のRoleリソースのルート. * Boxに紐付いたロール一覧を返す。 * Box名として__を指定されたときは、Cellレベルのロールとみなす。 * @param boxName boxName * @param authzHeader authzHeader * @return JAXRS Response */ @Path("{box}") @GET public final Response cellRole( @PathParam("box") String boxName, @HeaderParam(HttpHeaders.AUTHORIZATION) final String authzHeader) { // アクセス制御 this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), CellPrivilege.AUTH_READ); // BoxパスがCell Levelであれば、Cell レベルロールを検索して一覧で返す。 if (BOX_PATH_CELL_LEVEL.equals(boxName)) { // TODO Bodyの生成 // EntitiesResponse er = this.op.getEntities(Role.EDM_TYPE_NAME, null); return Response.ok().entity(boxName).build(); } try { // EntityResponse boxEr = op.getEntity(Box.EDM_TYPE_NAME, OEntityKey.create(boxName), null); // EntitiesResponse rolesEr = (EntitiesResponse) op.getNavProperty(Role.EDM_TYPE_NAME, // OEntityKey.create(boxName), // "_role", null); // TODO Bodyの生成 return Response.ok().entity(boxName).build(); } catch (PersoniumCoreException pce) { if (PersoniumCoreException.OData.NO_SUCH_ENTITY == pce) { throw PersoniumCoreException.Dav.BOX_NOT_FOUND; } throw pce; } }
@Path("/{path: .*}.json") @Consumes(APPLICATION_JSON) @DELETE public Response delete(@PathParam("path") String path) { Response.Status status; if( jsondb.delete(path) ) { status = Response.Status.NO_CONTENT; } else { status = Response.Status.NOT_FOUND; } return Response.status(status).build(); }
@DELETE @Path("delete/{id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response delete(@PathParam("id") String id) throws Throwable { try { Contact get = contactService.get(Integer.valueOf(id)); contactService.delete(get); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity("Data is deleted").build(); }
@GET @Path(Urls.ConfigUrls.ENABLED_ID_PROVIDERS_FOR_SIGN_IN_PATH) @Timed public Collection<String> getEnabledIdentityProviderEntityIdsForSignIn( @PathParam(Urls.ConfigUrls.ENTITY_ID_PATH_PARAM) final String transactionEntityId) { return getIdpListForSignIn(transactionEntityId).stream().map(idp -> idp.getEntityId()).collect(Collectors.toList()); }
@GET @Path("find/{id}") @Produces(MediaType.APPLICATION_JSON) public Response find(@PathParam("id") @Valid String id) { JsonObject build = null; try { Pharmacist get = pharmacistService.get(Integer.valueOf(id)); build = Json.createObjectBuilder().add("id", get.getPharmacistId()).add("name", get.getPersonId().getFirstName()).build(); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity(build == null ? "No data found" : build).build(); }
@GET @Path("{category}") @Produces({ "application/hal+json", "application/hal+json;concept=eventcategory;v=1"}) @ApiOperation(value = "obtain all events scoped to a certain category", response = EventsRepresentation.class, notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " + "subscribers to the customer service should be able to listen for and react to. In other words this is the authoritative" + "feed for the customer service, allowing for subscribers to have these grouped into categories", authorizations = { @Authorization(value = "oauth2", scopes = {}), @Authorization(value = "oauth2-cc", scopes = {}), @Authorization(value = "oauth2-ac", scopes = {}), @Authorization(value = "oauth2-rop", scopes = {}), @Authorization(value = "Bearer") }, tags = {"interval", "events"}, produces = "application/hal+json, application/hal+json;concept=eventcategory;v=1", nickname = "getlocationEventsByCategory" ) @ApiResponses(value = { @ApiResponse(code = 415, message = "Content type not supported.") }) public Response getByCategory(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept, @PathParam("category") String category, @QueryParam("interval") String interval) { return eventCategoryProducers.getOrDefault(accept, this::handleUnsupportedContentType) .getResponse(uriInfo, request, category, interval); }
/** * PUT method for updating or creating an instance of CompanyResource * * @param content representation for the resource */ @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) public void putCompany(@PathParam("id") long id, Company content) { content.setId(id); DAOFactory.INSTANCE.getCompanyDAO().update(content); }
@DELETE @Path("delete/{id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response delete(@PathParam("id") String id) throws Throwable { try { Clinicmanager get = clinicManagerService.get(Integer.valueOf(id)); clinicManagerService.delete(get); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity("Data is deleted").build(); }
@GET @Path("/{id}/correcting") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @ApiOperation(value = "Owner requset correcting for Dossier", response = DossierDetailModel.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier has been correcting requested", response = DossierDetailModel.class), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) }) public Response correctingDossier(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @PathParam("id") String id);
@GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String output = "Hello say : " + msg; return Response.status(200).entity(output).build(); }
@Path("{commentId}") @DELETE public Response deleteComment(@PathParam("commentId") Long commentId) { return comments.findOptionalById(commentId) .map(c -> comments.delete(c)) .map(c -> Response.noContent().build()) .orElseThrow(() -> new CommentNotFoundException(commentId)); }
/** * Find the virtual machines matching to the given criteria. Look into * virtual machine name only. * * @param node * the node to be tested with given parameters. * @param criteria * the search criteria. Case is insensitive. * @return virtual machines. */ @GET @Path("{node:[a-z].*}/{criteria}") @Consumes(MediaType.APPLICATION_JSON) public List<VCloudVm> findAllByName(@PathParam("node") final String node, @PathParam("criteria") final String criteria) throws IOException, SAXException, ParserConfigurationException { // Check the node exists if (nodeRepository.findOneVisible(node, securityHelper.getLogin()) == null) { return Collections.emptyList(); } // Get the VMs and parse them return toVms(getVCloudResource(pvResource.getNodeParameters(node), "/query?type=vm&format=idrecords&filter=name==*" + criteria + "*&sortAsc=name&fields=name,guestOs&pageSize=10")); }
@Path("/{name}/pulls/{pullRequestNumber}/commits") @GET public Response getCommits(@PathParam("name") String projectName, @PathParam("pullRequestNumber") Long pullRequestNumber) { Project project = getProject(projectName); if (!SecurityUtils.canRead(project)) throw new UnauthorizedException("Unauthorized access to project '" + projectName + "'"); PullRequest request = pullRequestManager.find(project, pullRequestNumber); List<Map<String, Object>> entity = new ArrayList<>(); for (RevCommit commit: request.getCommits()) { Map<String, Object> commitMap = new HashMap<>(); commitMap.put("sha", commit.name()); Map<String, Object> commitDetailMap = new HashMap<>(); Map<String, String> authorMap = new HashMap<>(); authorMap.put("name", commit.getAuthorIdent().getName()); authorMap.put("email", commit.getAuthorIdent().getEmailAddress()); authorMap.put("date", new SimpleDateFormat(RestConstants.DATE_FORMAT).format(commit.getAuthorIdent().getWhen())); commitDetailMap.put("author", authorMap); Map<String, String> committerMap = new HashMap<>(); committerMap.put("name", commit.getCommitterIdent().getName()); committerMap.put("email", commit.getCommitterIdent().getEmailAddress()); committerMap.put("date", new SimpleDateFormat(RestConstants.DATE_FORMAT).format(commit.getCommitterIdent().getWhen())); commitDetailMap.put("committer", authorMap); commitMap.put("commit", commitDetailMap); entity.add(commitMap); } return Response.ok(entity, RestConstants.JSON_UTF8).build(); }
@GET @Path("/cluster/{id}") @Produces(MediaType.APPLICATION_JSON) public ClusterResponse getClusterInfo(@PathParam("id") final String id) throws Exception { ClusterEnriched cluster = service.getClusterInfo(new ClusterId(id)); return toClusterResponse(cluster); }
@GET @Path("/deliverables/{id}/preview") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED }) @ApiOperation(value = "Get info preview for deliverable id") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access defined", response = ExceptionModel.class) }) public Response getPreview(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @ApiParam(value = "id of Deliverable", required = true) @PathParam("id") Long id);
/** * Removes flow rules by application ID. * Removes a collection of flow rules generated by the given application. * * @param appId application identifier * @return 204 NO CONTENT */ @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("application/{appId}") public Response removeFlowByAppId(@PathParam("appId") String appId) { final ApplicationService appService = get(ApplicationService.class); final ApplicationId idInstant = nullIsNotFound(appService.getId(appId), APP_ID_NOT_FOUND); service.removeFlowRulesById(idInstant); return Response.noContent().build(); }
@DELETE @Path("delete/{id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response delete(@PathParam("id") String id) throws Throwable { System.out.println("delete"+ id); try { Nurse get = nurseService.get(Integer.valueOf(id)); nurseService.delete(get); } catch (Exception ex) { return Response.ok().header("Exception", ex.getMessage()).build(); } return Response.ok().entity("Data is deleted").build(); }
@GET @Produces(MediaType.APPLICATION_JSON) @Path("bubble/{urn}/thumbnail") public Response bubbleThumbnail( @Context HttpServletRequest request, @PathParam("urn") String urn ) throws IOException, URISyntaxException { APIImpl impl = getAPIImpl( request ); if( impl == null ) { return Response.status( Response.Status.UNAUTHORIZED ).build(); } String scope[] = { DataRESTAPI.SCOPE_VIEWABLE_READ }; ResultAuthentication result = impl.authenticate( scope ); if( result.isError() ) { return formatReturn( result ); } URL url = new URL( impl.getThumbnailURL( urn ) ); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod( "GET" ); result.setAuthHeader( connection ); int httpStatus = connection.getResponseCode(); if( httpStatus > 299 ) { return Response.status( httpStatus ) .header("Pragma", "no-cache") .header("Cache-Control", "no-cache") .entity( connection.getErrorStream() ) .build(); } // Copy Autodesk headers describing thumbnail Map<String, List<String>> headers = connection.getHeaderFields(); Iterator<String> itr = headers.keySet().iterator(); Response.ResponseBuilder builder = Response.status( httpStatus ); while( itr.hasNext() ) { String key = itr.next(); if( key == null ) continue; if( !key.startsWith( "x-ads" )) continue; String value = connection.getHeaderField( key ); builder.header( key, value ); } return builder.entity( connection.getInputStream() ) .header("content-encoding", connection.getContentEncoding() ) .header("content-type", connection.getContentType() ) .build(); }
/** * Abandons mastership of the specified device on the local node thus * forcing selection of a new master. If the local node is not a master * for this device, no master selection will occur. * * @param deviceId device identifier * @return status of the request - CREATED if the JSON is correct */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("{deviceId}/relinquish") public Response relinquishMastership(@PathParam("deviceId") String deviceId) { DeviceId id = DeviceId.deviceId(deviceId); mastershipService.relinquishMastershipSync(id); return Response.created(id.uri()).build(); }
@PUT @Produces( { MediaType.APPLICATION_JSON, "application/javascript", MediaType.APPLICATION_XML }) @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response keepAliveSession(@PathParam("session") String session, @Context UriInfo ui, byte[] data) { if (!ZooKeeperService.isConnected(contextPath, session)) { throwNotFound(session, ui); } ZooKeeperService.resetTimer(contextPath, session); return Response.status(Response.Status.OK).build(); }
@GET @Path("/{name}.json") @Produces(APPLICATION_JSON) public PluginConfigWrapper getStoragePluginJSON(@PathParam("name") String name) { try { StoragePlugin plugin = pluginConfiguration.getPlugin(name); if (plugin != null) { return new PluginConfigWrapper(name, plugin.getConfig()); } } catch (Exception e) { throw new BadRequestException("Failure while trying to access storage config: " + name, e); } return new PluginConfigWrapper(name, null); }
/** * Retreive and entity with the provided ID. * @param id ID of the entity to find. * @return A Response containing the entity. */ @GET @Path("/{id:[0-9][0-9]*}") public Response findById(@PathParam("id") final Long id) { if (id == null) { return Response.status(Status.NOT_FOUND).build(); } T entity = findEntityById(id); if (entity == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(entity).build(); }
@GET @Produces({ MediaType.APPLICATION_JSON }) @Path("user/{id}/search") public Page<NoShortcutSerializationWrapper<UserOutVO>> searchUserByCriteria(@PathParam("id") Long id, @Context UriInfo uriInfo) throws AuthenticationException, AuthorisationException, ServiceException { PSFUriPart psf = new PSFUriPart(uriInfo); Collection result = WebUtil.getServiceLocator().getSearchService().searchUserByCriteria(auth, id, ResourceUtils.LIST_GRAPH_MAX_USER_INSTANCES, psf); NoShortcutSerializationWrapper.transformVoCollection(result); return new Page<NoShortcutSerializationWrapper<UserOutVO>>(result, psf); }
@GET @Path("/{id}/cancelling") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @ApiOperation(value = "Owner requset cancalling for Dossier", response = DossierDetailModel.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier has been cancelled", response = DossierDetailModel.class), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class), @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) }) public Response cancellingDossier(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @PathParam("id") String id);