Java Code Examples for javax.ws.rs.Consumes

The following are top voted examples for showing how to use javax.ws.rs.Consumes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gitplex-mit   File: CommitStatusResource.java   View source code 8 votes vote down vote up
@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();
   }
 
Example 2
Project: bluemix-liberty-microprofile-demo   File: MeetingBookingService.java   View source code 7 votes vote down vote up
@POST
@Path("/meeting")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Reservation make(Reservation reservation) {
	if (reservation.getId() != null)
		throw new BadRequestException(MessageFormat.format(ERROR_RESERVATION_IS_EXISTS_FMT, reservation.getId()));
	Set<Reservation> alreadyMadeReservations = reservationDao.getReservations(
			reservation.getVenue(), 
			reservation.getDate(), 
			reservation.getStartTime(),
			reservation.getDuration());
	if (alreadyMadeReservations != null && !alreadyMadeReservations.isEmpty())
		throw new BadRequestException(MessageFormat.format(ERROR_RESERVATION_CONFLICT_FMT, reservation.getVenue()));
	
	return reservationDao.createNew(reservation);
}
 
Example 3
Project: lra-service   File: InvoiceEndpoint.java   View source code 6 votes vote down vote up
@POST
@Path(LRAOperationAPI.REQUEST)
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
@LRA(value = LRA.Type.REQUIRED)
public Response requestInvoice(@HeaderParam(LRAClient.LRA_HTTP_HEADER) String lraUri, OrderInfo orderInfo) {
	String lraId = LRAClient.getLRAId(lraUri);
	log.info("processing request for LRA " + lraId);

	invoiceService.computeInvoice(lraId, orderInfo);

	//stub for compensation scenario
	if ("failInvoice".equals(orderInfo.getProduct().getProductId())) {
		return Response
				.status(Response.Status.BAD_REQUEST)
				.entity("Invoice for order " + orderInfo.getOrderId() + " failure")
				.build();
	}

	return Response
			.ok()
			.entity(String.format("Invoice for order %s processed", orderInfo.getOrderId()))
			.build();
}
 
Example 4
Project: athena   File: FlowClassifierWebResource.java   View source code 6 votes vote down vote up
/**
 * Update details of a flow classifier.
 *
 * @param id
 *            flow classifier id
 * @param stream
 *            InputStream
 * @return 200 OK, 404 if given identifier does not exist
 */
@PUT
@Path("{flow_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updateFlowClassifier(@PathParam("flow_id") String id, final InputStream stream) {
    try {

        JsonNode jsonTree = mapper().readTree(stream);
        JsonNode flow = jsonTree.get("flow_classifier");
        FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
        Boolean result = nullIsNotFound(get(FlowClassifierService.class).updateFlowClassifier(flowClassifier),
                                        FLOW_CLASSIFIER_NOT_FOUND);
        return Response.status(OK).entity(result.toString()).build();
    } catch (IOException e) {
        log.error("Update flow classifier failed because of exception {}.", e.toString());
        throw new IllegalArgumentException(e);
    }
}
 
Example 5
Project: clemon   File: UserResource.java   View source code 6 votes vote down vote up
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
@Path("/save")
public Object saveUser(@FormParam("userName") String userName,@FormParam("userPass") String userPass){
	String jsonData = "";
	User u = new User();
	u.setUserName(userName);
	u.setUserPass(userPass);
	try {
		userService.save(u);
	} catch (Exception e) {
		//-- 统一在过滤器中添加跨域访问的header信息,所以这里就不添加了
		jsonData = JsonUtil.toJsonByProperty("addUser","failure");
		return Response.ok(jsonData).status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR ).build();
	}
	jsonData = JsonUtil.toJsonByProperty("id", u.getId());
	return Response.ok(jsonData).status(HttpServletResponse.SC_OK).build();
}
 
Example 6
Project: opencps-v2   File: ServiceInfoManagement.java   View source code 6 votes vote down vote up
@GET
@Path("/{id}/filetemplates")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get FileTemplate list of ServiceInfo by its id)", response = FileTemplateResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the list of FileTemplate of ServiceInfo", response = FileTemplateResultsModel.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 getFileTemplatesOfServiceInfo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of ServiceInfo that need to be get the list of FileTemplates", required = true) @PathParam("id") String id);
 
Example 7
Project: microservices-transactions-tcc   File: CompositeTransactionParticipantController.java   View source code 6 votes vote down vote up
@DELETE
@Path("/tcc/{txid}")
@Consumes("application/tcc")
   @ApiOperation(
   		code = 204,
   		response = String.class,
           value = "Rollback a given composite transaction",
           notes = "See https://www.atomikos.com/Blog/TransactionManagementAPIForRESTTCC",
           consumes = "application/tcc"
       )
public void cancel(
		@ApiParam(value = "Id of the composite transaction to rollback", required = true) @PathParam("txid") String txid
		){
	LOG.info("Trying to rollback transaction [{}]", txid);
	
	getCompositeTransactionParticipantService().cancel(txid);
	
	LOG.info("Transaction [{}] rolled back", txid);
}
 
Example 8
Project: ctsms   File: FileResource.java   View source code 6 votes vote down vote up
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public FileOutVO updateFile(@FormDataParam("json") FormDataBodyPart json,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws AuthenticationException, AuthorisationException, ServiceException {
	// in.setId(fileId);
	json.setMediaType(MediaType.APPLICATION_JSON_TYPE);
	FileInVO in = json.getValueAs(FileInVO.class);
	FileStreamInVO stream = new FileStreamInVO();
	stream.setStream(input);
	stream.setMimeType(content.getMediaType().toString()); // .getType());
	stream.setSize(contentDisposition.getSize());
	stream.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getFileService().updateFile(auth, in, stream);
}
 
Example 9
Project: athena   File: OpenstackPortWebResource.java   View source code 6 votes vote down vote up
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createPorts(InputStream input) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode portNode = (ObjectNode) mapper.readTree(input);

        OpenstackPort openstackPort = PORT_CODEC.decode(portNode, this);
        OpenstackSwitchingService switchingService =
                getService(OpenstackSwitchingService.class);
        switchingService.createPorts(openstackPort);

        log.debug("REST API ports is called with {}", portNode.toString());
        return Response.status(Response.Status.OK).build();

    } catch (Exception e) {
        log.error("Creates Port failed because of exception {}",
                e.toString());
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString())
                .build();
    }
}
 
Example 10
Project: syndesis   File: OAuthAppHandler.java   View source code 6 votes vote down vote up
@PUT
@Path(value = "/{id}")
@Consumes("application/json")
public void update(@NotNull @PathParam("id") String id, @NotNull @Valid OAuthApp app) {
    final Connector connector = dataMgr.fetch(Connector.class, id);
    if (connector == null) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }

    final Connector updated = new Connector.Builder().createFrom(connector)
        .putOrRemoveConfiguredPropertyTaggedWith(Credentials.CLIENT_ID_TAG, app.clientId)
        .putOrRemoveConfiguredPropertyTaggedWith(Credentials.CLIENT_SECRET_TAG, app.clientSecret)
        .build();

    dataMgr.update(updated);
}
 
Example 11
Project: athena   File: RegionsWebResource.java   View source code 6 votes vote down vote up
/**
 * Updates the specified region using the supplied JSON input stream.
 *
 * @param regionId region identifier
 * @param stream region JSON stream
 * @return status of the request - UPDATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel RegionPost
 */
@PUT
@Path("{regionId}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateRegion(@PathParam("regionId") String regionId,
                             InputStream stream) {
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        JsonNode specifiedRegionId = jsonTree.get("id");

        if (specifiedRegionId != null &&
                !specifiedRegionId.asText().equals(regionId)) {
            throw new IllegalArgumentException(REGION_INVALID);
        }

        final Region region = codec(Region.class).decode(jsonTree, this);
        regionAdminService.updateRegion(region.id(),
                            region.name(), region.type(), region.masters());
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }

    return Response.ok().build();
}
 
Example 12
Project: opencps-v2   File: RegistrationLogManagement.java   View source code 6 votes vote down vote up
@POST
@Path("/registrations/{id}/logs")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "addRegistrationByRegistrationId)", response = RegistrationLogModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the RegistrationgModel was updated", response = RegistrationResultsModel.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 addRegistrationByRegistrationId(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of registration", required = true) @PathParam("id") long id,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("author") String author,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("payload") String payload,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("content") String content);
 
Example 13
Project: osc-core   File: ServerMgmtApis.java   View source code 6 votes vote down vote up
@ApiOperation(value = "Upload a private/public certificate zip file. ",
        notes = "Overwrites the entry marked &quot;internal&quot; in the truststore. "
        + "That is a private/public keypair used for secure connections by OSC. "
        + "The zip file should contain a  &quot;key.pem&quot; in PKCS8+PEM format (private key) and "
        + "certchain.pem or certchain.pkipath (the certificate chain). This results in the server restart ! ! !",
        response = BaseResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/internalkeypair")
@POST
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadKeypair(@Context HttpHeaders headers,
        @ApiParam(value = "The imported keypair zip file name",
        required = true) @PathParam("fileName") String fileName,
        @ApiParam(required = true) InputStream uploadedInputStream) {
    logger.info("Started uploading file " + fileName);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));
    return this.apiUtil.getResponseForBaseRequest(this.replaceInternalKeypairServiceApi,
            new UploadRequest(fileName, uploadedInputStream));
}
 
Example 14
Project: opencps-v2   File: PaymentFileManagement.java   View source code 6 votes vote down vote up
@POST
@Path("/{id}/payments/{referenceUid}/epaymentprofile")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add epaymentprofile", response = JSONObject.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns epaymentprofile was update", response = JSONObject.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class) })
public Response updateEpaymentProfile(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of Payment", required = true) @PathParam("id") String id,
		@ApiParam (value = "referenceUid of Payment", required = true) @PathParam("referenceUid") String referenceUid,
		@BeanParam PaymentFileInputModel input);
 
Example 15
Project: nifi-registry   File: BucketFlowResource.java   View source code 6 votes vote down vote up
@DELETE
@Path("{flowId}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Deletes a flow.",
        response = VersionedFlow.class
)
@ApiResponses({
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response deleteFlow(
        @PathParam("bucketId")
        @ApiParam("The bucket identifier")
            final String bucketId,
        @PathParam("flowId")
        @ApiParam("The flow identifier")
            final String flowId) {

    authorizeBucketAccess(RequestAction.DELETE, bucketId);
    final VersionedFlow deletedFlow = registryService.deleteFlow(bucketId, flowId);
    return Response.status(Response.Status.OK).entity(deletedFlow).build();
}
 
Example 16
Project: opencps-v2   File: RegistrationFormManagement.java   View source code 6 votes vote down vote up
@PUT
@Path("/registrations/{id}/forms/{referenceUid}/formdata")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update RegistrationForm")
@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 denied", response = ExceptionModel.class) })
public Response updateRegFormFormData(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "registrationId", required = true) @PathParam("id") long id,
		@ApiParam(value = "referenceUid", required = true) @PathParam("referenceUid") String referenceUid,
		@ApiParam(value = "formdata of registrationForm", required = true) @FormParam("formdata") String formdata)
		throws PortalException;
 
Example 17
Project: E-Clinic   File: ContactRestEndPoint.java   View source code 5 votes vote down vote up
@POST
@Path("create")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response create(@Valid Contact value) {
    try {
        contactService.create(value);
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity("Data is saved").build();
}
 
Example 18
Project: E-Clinic   File: GuardianRestEndPoint.java   View source code 5 votes vote down vote up
@PUT
@Path("update")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response update(@Valid Guardian value) throws Throwable {
    try {
        guardianService.update(value);
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity("Date is updated").build();
}
 
Example 19
Project: syndesis   File: JsonDBResource.java   View source code 5 votes vote down vote up
@Path("/{path: .*}.json")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@POST
public HashMap<String, String> push(@PathParam("path") String path, InputStream body) {
    HashMap<String, String> result = new HashMap<>();
    result.put("name", jsondb.push(path, body));
    return result;
}
 
Example 20
Project: elastic-job-cloud   File: CloudJobRestfulApi.java   View source code 5 votes vote down vote up
/**
 * 更新作业配置.
 *
 * @param jobConfig 作业配置
 */
@PUT
@Path("/update")
@Consumes(MediaType.APPLICATION_JSON)
public void update(final CloudJobConfiguration jobConfig) {
    producerManager.update(jobConfig);
}
 
Example 21
Project: opencps-v2   File: DeliverablesLogManagement.java   View source code 5 votes vote down vote up
@GET
@Path("/deliverables/{id}/logs")
@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 log 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 getDeliverableLog(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "id for Deliverable Log", required = true) @PathParam("id") Long id);
 
Example 22
Project: message-broker   File: QueuesApi.java   View source code 5 votes vote down vote up
@POST
@Consumes({"application/json"})
@Produces({"application/json"})
@ApiOperation(value = "Creates a queue", notes = "", response = QueueCreateResponse.class, tags = {})
@ApiResponses(value = {
        @ApiResponse(code = 201, message = "Queue created.", response = QueueCreateResponse.class),
        @ApiResponse(code = 400, message = "Bad Request. Invalid request or validation error.",
                     response = Error.class),
        @ApiResponse(code = 415, message = "Unsupported media type. The entity of the request was in a not "
                + "supported format.", response = Error.class)})
public Response createQueue(@Valid QueueCreateRequest body) {
    return delegate.createQueue(body);
}
 
Example 23
Project: java-ml-projects   File: DataSetResource.java   View source code 5 votes vote down vote up
@POST
@Path("{label}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void receiveFile(MultipartInput input, @PathParam("label") String label) {
	List<InputPart> parts = input.getParts();
	parts.stream().filter(p -> p.getMediaType().getType().startsWith("image"))
			.forEach(p -> this.saveImage(p, label));
	input.close();
}
 
Example 24
Project: GitHub   File: Resource.java   View source code 5 votes vote down vote up
@Path("/doubleInMapTest")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public MapTest getDoubleInMapTest() {

  return ImmutableMapTest.builder()
      .putMapDouble("double", 5.0)
      .build();
}
 
Example 25
Project: nifi-registry   File: BucketFlowResource.java   View source code 5 votes vote down vote up
@GET
@Path("{flowId}/versions/{versionNumber: \\d+}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Gets the given version of a flow",
        response = VersionedFlowSnapshot.class
)
@ApiResponses({
        @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlowVersion(
        @PathParam("bucketId")
        @ApiParam("The bucket identifier")
            final String bucketId,
        @PathParam("flowId")
        @ApiParam("The flow identifier")
            final String flowId,
        @PathParam("versionNumber")
        @ApiParam("The version number")
            final Integer versionNumber) {
    authorizeBucketAccess(RequestAction.READ, bucketId);

    final VersionedFlowSnapshot snapshot = registryService.getFlowSnapshot(bucketId, flowId, versionNumber);
    populateLinksAndPermissions(snapshot);

    return Response.status(Response.Status.OK).entity(snapshot).build();
}
 
Example 26
Project: opencps-v2   File: ServiceInfoManagement.java   View source code 5 votes vote down vote up
@GET
@Path("/statistics/domains")
@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 StatisticByLevel", response = StatisticsLevelResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of ServiceInfo", response = StatisticsLevelResultsModel.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 getStatisticByDomain(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext);
 
Example 27
Project: jersey-jwt   File: AuthenticationResource.java   View source code 5 votes vote down vote up
/**
 * Validate user credentials and issue a token for the user.
 *
 * @param credentials
 * @return
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public Response authenticate(UserCredentials credentials) {

    User user = usernamePasswordValidator.validateCredentials(credentials.getUsername(), credentials.getPassword());
    String token = authenticationTokenService.issueToken(user.getUsername(), user.getAuthorities());
    AuthenticationToken authenticationToken = new AuthenticationToken();
    authenticationToken.setToken(token);
    return Response.ok(authenticationToken).build();
}
 
Example 28
Project: opencps-v2   File: FileAttachManagement.java   View source code 5 votes vote down vote up
@GET
@Path("/{className}/{classPK}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getFileAttachs(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, 
		@PathParam("className") String className, @PathParam("classPK") String classPK,
		@BeanParam DataSearchModel query);
 
Example 29
Project: opencps-v2   File: EmployeeManagement.java   View source code 5 votes vote down vote up
@DELETE
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response delete(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@DefaultValue("0") @PathParam("id") long id);
 
Example 30
Project: opencps-v2   File: ServiceProcessManagement.java   View source code 5 votes vote down vote up
@PUT
@Path("/{id}/roles/{roleid}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Update the ServiceProcessRole of a ServiceProcess by its id", response = RoleInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ServiceProcessRole was update", response = RoleInputModel.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 updateServiceProcessRole(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id, @PathParam("roleid") long roleid,
		@BeanParam RoleInputModel input);
 
Example 31
Project: nifi-registry   File: BucketResource.java   View source code 5 votes vote down vote up
@GET
@Path("fields")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Retrieves field names for searching or sorting on buckets.",
        response = Fields.class
)
public Response getAvailableBucketFields() {
    final Set<String> bucketFields = registryService.getBucketFields();
    final Fields fields = new Fields(bucketFields);
    return Response.status(Response.Status.OK).entity(fields).build();
}
 
Example 32
Project: presto-manager   File: PackageAPI.java   View source code 5 votes vote down vote up
@PUT
@Consumes(TEXT_PLAIN)
@Produces(TEXT_PLAIN)
@ApiOperation(value = "Install Presto using rpm or tarball")
@ApiResponses(value = {
        @ApiResponse(code = 202, message = "Acknowledged request"),
        @ApiResponse(code = 400, message = "Invalid url"),
        @ApiResponse(code = 409, message = "Presto is already installed.")
})
public synchronized Response install(@ApiParam("Url to fetch package") String packageUrl,
        @QueryParam("checkDependencies") @DefaultValue("true") @ApiParam("If false, disables dependency checking") boolean checkDependencies)
{
    return controller.install(packageUrl, checkDependencies);
}
 
Example 33
Project: dremio-oss   File: SourceResource.java   View source code 5 votes vote down vote up
@POST
@Path("new_untitled_from_file/{path: .*}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public InitialPreviewResponse createUntitledFromSourceFile(@PathParam("path") String path)
  throws DatasetNotFoundException, DatasetVersionNotFoundException, NamespaceException, NewDatasetQueryException {
  return datasetsResource.createUntitledFromSourceFile(sourceName, path);
}
 
Example 34
Project: opencps-v2   File: DataManagement.java   View source code 5 votes vote down vote up
@POST
@Path("/{code}/dictgroups")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addDictgroups(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@PathParam("code") String code, @BeanParam DictGroupInputModel input);
 
Example 35
Project: elastic-job-cloud   File: CloudJobRestfulApi.java   View source code 5 votes vote down vote up
/**
 * 获取作业执行类型统计数据.
 * 
 * @return 作业执行类型统计数据
 */
@GET
@Path("/statistics/jobs/executionType")
@Consumes(MediaType.APPLICATION_JSON)
public JobExecutionTypeStatistics getJobExecutionTypeStatistics() {
    return statisticManager.getJobExecutionTypeStatistics();
}
 
Example 36
Project: opencps-v2   File: ServerConfigManagement.java   View source code 5 votes vote down vote up
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add a ServerConfig", response = ServerConfigDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the ServerConfig was created", response = ServerConfigDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response addServerConfig(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @BeanParam ServerConfigInputModel input);
 
Example 37
Project: verify-hub   File: RpAuthnResponseGeneratorResource.java   View source code 5 votes vote down vote up
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Timed
public Response generate(ResponseFromHubDto responseFromHub) throws JsonProcessingException {
    return Response.ok().entity(service.generate(responseFromHub)).type(MediaType.APPLICATION_JSON_TYPE).build();
}
 
Example 38
Project: SistemaAlmoxarifado   File: UsuarioResource.java   View source code 5 votes vote down vote up
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/getid")
public Response  getId(@HeaderParam("token") String token, 
        @QueryParam("id") int id) throws SQLException, Exception {
    
    if(!Verify(token, "admin")) 
        return Response.status(Response.Status.UNAUTHORIZED).build();
    
    Gson gson = new Gson();
    Usuario u = UsuarioDAO.retreave(id);
    
    return Response.status(Response.Status.OK)
            .entity(gson.toJson(u)).build();
}
 
Example 39
Project: opencps-v2   File: UserManagement.java   View source code 5 votes vote down vote up
@POST
@Path("/{id}/changepass")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addChangepass(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id,
		@FormParam("oldPassword") String oldPassword, @FormParam("newPassword") String newPassword);
 
Example 40
Project: Hybrid-Cloud-Applications-and-Services   File: BookingResource.java   View source code 5 votes vote down vote up
@POST
@ApiOperation("Create a booking")
@Consumes("application/json")
@Produces("application/json")
@ApiResponses({
	@ApiResponse(code = 201, message= "Booking created", response=String.class)})
public Response createBooking(Booking task){
	return Controller.createBooking(task);
}