Java Code Examples for org.springframework.http.MediaType#APPLICATION_XML_VALUE

The following examples show how to use org.springframework.http.MediaType#APPLICATION_XML_VALUE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
@RequestMapping( value = { "/uid", "/id" }, method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode getUid( @RequestParam( required = false, defaultValue = "1" ) Integer limit, HttpServletResponse response )
    throws IOException, InvalidTypeException
{
    limit = Math.min( limit, 10000 );

    RootNode rootNode = new RootNode( "codes" );
    CollectionNode collectionNode = rootNode.addChild( new CollectionNode( "codes" ) );
    collectionNode.setWrapping( false );

    for ( int i = 0; i < limit; i++ )
    {
        collectionNode.addChild( new SimpleNode( "code", CodeGenerator.generateUid() ) );
    }

    setNoStore( response );

    return rootNode;
}
 
Example 2
Source File: SystemController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
@RequestMapping( value = "/uuid", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode getUuid( @RequestParam( required = false, defaultValue = "1" ) Integer limit, HttpServletResponse response )
    throws IOException, InvalidTypeException
{
    limit = Math.min( limit, 10000 );

    RootNode rootNode = new RootNode( "codes" );
    CollectionNode collectionNode = rootNode.addChild( new CollectionNode( "codes" ) );
    collectionNode.setWrapping( false );

    for ( int i = 0; i < limit; i++ )
    {
        collectionNode.addChild( new SimpleNode( "code", UUID.randomUUID().toString() ) );
    }

    setNoStore( response );

    return rootNode;
}
 
Example 3
Source File: MetadataImportExportController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
@PostMapping( value = "", consumes = MediaType.APPLICATION_XML_VALUE )
public void postXmlMetadata( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
    MetadataImportParams params = metadataImportService.getParamsFromMap( contextService.getParameterValuesMap() );
    Metadata metadata = renderService.fromXml( StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() ), Metadata.class );
    params.addMetadata( schemaService.getMetadataSchemas(), metadata );
    response.setContentType( MediaType.APPLICATION_XML_VALUE );

    if ( params.hasJobId() )
    {
        startAsyncMetadata( params, request, response );
    }
    else
    {
        ImportReport importReport = metadataImportService.importMetadata( params );
        renderService.toXml( response.getOutputStream(), importReport );
    }
}
 
Example 4
Source File: MessageConversationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@RequestMapping( value = "/read", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE,
    MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode markMessageConversationsRead(
    @RequestParam( value = "user", required = false ) String userUid, @RequestBody List<String> uids,
    HttpServletResponse response )
{
    return modifyMessageConversationRead( userUid, uids, response, true );
}
 
Example 5
Source File: MessageConversationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@RequestMapping( value = "/{uid}/assign", method = RequestMethod.DELETE, produces = {
    MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode removeUserAssigned(
    @PathVariable String uid,
    HttpServletResponse response )
{
    RootNode responseNode = new RootNode( "response" );

    User user = currentUserService.getCurrentUser();

    if ( !canModifyUserConversation( user, user ) &&
        (messageService.hasAccessToManageFeedbackMessages( user )) )
    {
        throw new UpdateAccessDeniedException( "Not authorized to modify this object." );
    }

    org.hisp.dhis.message.MessageConversation messageConversation = messageService
        .getMessageConversation( uid );

    if ( messageConversation == null )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "No MessageConversation found for the given ID." ) );
        return responseNode;
    }

    messageConversation.setAssignee( null );
    messageService.updateMessageConversation( messageConversation );
    responseNode.addChild( new SimpleNode( "message", "Message is no longer assigned to user" ) );
    response.setStatus( HttpServletResponse.SC_OK );

    return responseNode;
}
 
Example 6
Source File: MessageConversationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@RequestMapping( value = "/{uid}/status", method = RequestMethod.POST, produces = {
    MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode setMessageStatus(
    @PathVariable String uid,
    @RequestParam MessageConversationStatus messageConversationStatus,
    HttpServletResponse response )
{
    RootNode responseNode = new RootNode( "response" );

    User user = currentUserService.getCurrentUser();

    if ( !canModifyUserConversation( user, user ) &&
        (messageService.hasAccessToManageFeedbackMessages( user )) )
    {
        throw new UpdateAccessDeniedException( "Not authorized to modify this object." );
    }

    org.hisp.dhis.message.MessageConversation messageConversation = messageService
        .getMessageConversation( uid );

    if ( messageConversation == null )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "No MessageConversation found for the given ID." ) );
        return responseNode;
    }

    CollectionNode marked = responseNode
        .addChild( new CollectionNode( messageConversationStatus.name() ) );
    marked.setWrapping( false );

    messageConversation.setStatus( messageConversationStatus );
    messageService.updateMessageConversation( messageConversation );
    marked.addChild( new SimpleNode( "uid", messageConversation.getUid() ) );
    response.setStatus( HttpServletResponse.SC_OK );

    return responseNode;
}
 
Example 7
Source File: RelationshipController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@PutMapping( path = "/{id}", consumes = MediaType.APPLICATION_XML_VALUE, produces = APPLICATION_XML_VALUE )
public ImportSummary updateRelationshipXml(
    @PathVariable String id,
    ImportOptions importOptions,
    HttpServletRequest request
)
    throws IOException
{
    InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
    ImportSummary importSummary = relationshipService.updateRelationshipXml( id, inputStream, importOptions );
    importSummary.setImportOptions( importOptions );

    return importSummary;
}
 
Example 8
Source File: WebMessageService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
public void send( WebMessage webMessage, HttpServletResponse response, HttpServletRequest request )
{
    String type = request.getHeader( "Accept" );
    type = !StringUtils.isEmpty( type ) ? type : request.getContentType();
    type = !StringUtils.isEmpty( type ) ? type : MediaType.APPLICATION_JSON_VALUE;
    HttpStatus httpStatus = HttpStatus.valueOf( webMessage.getHttpStatusCode() );

    if ( httpStatus.is4xxClientError() || httpStatus.is5xxServerError() )
    {
        response.setHeader( "Cache-Control", CacheControl.noCache().cachePrivate().getHeaderValue() );
    }

    // allow type to be overridden by path extension
    if ( request.getPathInfo().endsWith( ".json" ) )
    {
        type = MediaType.APPLICATION_JSON_VALUE;
    }
    else if ( request.getPathInfo().endsWith( ".xml" ) )
    {
        type = MediaType.APPLICATION_XML_VALUE;
    }

    if ( isCompatibleWith( type, MediaType.APPLICATION_JSON ) )
    {
        sendJson( webMessage, response );
    }
    else if ( isCompatibleWith( type, MediaType.APPLICATION_XML ) )
    {
        sendXml( webMessage, response );
    }
    else
    {
        sendJson( webMessage, response ); // default to json
    }
}
 
Example 9
Source File: MessageConversationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@RequestMapping( method = RequestMethod.DELETE, produces = { MediaType.APPLICATION_JSON_VALUE,
    MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode removeUserFromMessageConversations(
    @RequestParam( "mc" ) List<String> mcUids, @RequestParam( value = "user", required = false ) String userUid,
    HttpServletResponse response )
    throws DeleteAccessDeniedException
{
    RootNode responseNode = new RootNode( "response" );

    User currentUser = currentUserService.getCurrentUser();

    User user = userUid == null ? currentUser : userService.getUser( userUid );

    if ( user == null )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "User does not exist: " + userUid ) );
        return responseNode;
    }

    if ( !canModifyUserConversation( currentUser, user ) )
    {
        throw new DeleteAccessDeniedException( "Not authorized to modify user: " + user.getUid() );
    }

    Collection<org.hisp.dhis.message.MessageConversation> messageConversations = messageService
        .getMessageConversations( user, mcUids );

    if ( messageConversations.isEmpty() )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "No MessageConversations found for the given UIDs." ) );
        return responseNode;
    }

    CollectionNode removed = responseNode.addChild( new CollectionNode( "removed" ) );

    for ( org.hisp.dhis.message.MessageConversation mc : messageConversations )
    {
        if ( mc.remove( user ) )
        {
            messageService.updateMessageConversation( mc );
            removed.addChild( new SimpleNode( "uid", mc.getUid() ) );
        }
    }

    response.setStatus( HttpServletResponse.SC_OK );

    return responseNode;
}
 
Example 10
Source File: SmsGatewayClient.java    From codenjoy with GNU General Public License v3.0 4 votes vote down vote up
@PostMapping(value = "", consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
ResponseEntity<String> sendSms(@RequestBody SmsService.SmsSendRequest smsSendRequest);
 
Example 11
Source File: DefaultViewController.java    From jakduk-api with MIT License 4 votes vote down vote up
@GetMapping(value = "/rss.xml", produces = MediaType.APPLICATION_XML_VALUE)
public String getRss() {
	return "documentRssFeedView";
}
 
Example 12
Source File: BookController.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GetMapping(produces = MediaType.APPLICATION_XML_VALUE, path = "/book")
public Book someBook() {
    return new Book("Guns germs and steel");
}
 
Example 13
Source File: InvestorServiceFetchController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 4 votes vote down vote up
/**
 * method example which produces both xml and json output, other methods
 * produces only json response and for other content type it errors out 406
 * content not allowed
 */
@GetMapping(path = "/investors/{investorId}/stocks/{symbol}", produces = { MediaType.APPLICATION_JSON_VALUE,
		MediaType.APPLICATION_XML_VALUE })
public Stock fetchAStockByInvestorIdAndStockId(@PathVariable String investorId, @PathVariable String symbol) {
	return investorServiceFetchOpertions.fetchSingleStockByInvestorIdAndStockSymbol(investorId, symbol);
}
 
Example 14
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 4 votes vote down vote up
/**
 * method example which produces both xml and json output, other methods
 * produces only json response and for other content type it errors out 406
 * content not allowed
 */
@GetMapping(path = "/investors/{investorId}/stocks/{symbol}", produces = { MediaType.APPLICATION_JSON_VALUE,
		MediaType.APPLICATION_XML_VALUE })
public Stock fetchAStockByInvestorIdAndStockId(@PathVariable String investorId, @PathVariable String symbol) {
	return investorService.fetchSingleStockByInvestorIdAndStockSymbol(investorId, symbol);
}
 
Example 15
Source File: CartController.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
/**
 * Interface: GET /api/rest/cart/options/payment
 * <p>
 * <p>
 * Display payment gateways available.
 * <p>
 * <p>
 * <h3>Headers for operation</h3><p>
 * <table border="1">
 *     <tr><td>Accept</td><td>application/xml</td></tr>
 *     <tr><td>yc</td><td>token uuid</td></tr>
 * </table>
 * <p>
 * <p>
 * <h3>Parameters for operation</h3><p>
 * NONE
 * <p>
 * <p>
 * <h3>Output</h3><p>
 * <table border="1">
 *     <tr><td>XML array object PaymentGatewayRO. "name" depends on the locale of the cart.</td><td>
 * <pre><code>
 * &lt;payment-gateways&gt;
 * 	&lt;payment-gateway pg-label="courierPaymentGatewayLabel"&gt;
 * 		&lt;name&gt;courierPaymentGateway&lt;/name&gt;
 * 	&lt;/payment-gateway&gt;
 * 	&lt;payment-gateway pg-label="testPaymentGatewayLabel"&gt;
 * 		&lt;name&gt;testPaymentGateway&lt;/name&gt;
 * 	&lt;/payment-gateway&gt;
 * &lt;/payment-gateways&gt;
 * </code></pre>
 *     </td></tr>
 * </table>
 *
 * @param request request
 * @param response response
 *
 * @return list of payment gateways options
 */
@ApiOperation(value = "Display payment gateways available.")
@RequestMapping(
        value = "/cart/options/payment",
        method = RequestMethod.GET,
        produces = { MediaType.APPLICATION_XML_VALUE }
)
public @ResponseBody PaymentGatewayListRO cartPaymentOptionsXML(final @ApiParam(value = "Request token") @RequestHeader(value = "yc", required = false) String requestToken,
                                                                final HttpServletRequest request,
                                                                final HttpServletResponse response) {

    cartMixin.throwSecurityExceptionIfRequireLoggedIn();
    cartMixin.persistShoppingCart(request, response);
    return new PaymentGatewayListRO(cartPaymentOptionsInternal());

}
 
Example 16
Source File: ShellCommandsController.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Gets a link index for the web service endpoints and REST API calls in GemFire for management and monitoring
 * using GemFire shell (Gfsh).
 * <p/>
 * @return a LinkIndex containing Links for all web service endpoints, REST API calls in GemFire.
 * @see com.gemstone.gemfire.management.internal.web.domain.Link
 * @see com.gemstone.gemfire.management.internal.web.domain.LinkIndex
 */
// TODO figure out a better way to maintain this link index, such as using an automated way to introspect
// the Spring Web MVC Controller RequestMapping Annotations.
// TODO refactor the URIs containing verbs!
@RequestMapping(value = "/index", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public LinkIndex index() {
  //logger.warning(String.format("Returning Link Index for Context Path (%1$s).",
  //  ServletUriComponentsBuilder.fromCurrentContextPath().build().toString()));
  return new LinkIndex()
    // Member Commands
    .add(new Link(CliStrings.LIST_MEMBER, toUri("/members")))
    .add(new Link(CliStrings.DESCRIBE_MEMBER, toUri("/members/{name}")))
    // Region Commands
    .add(new Link(CliStrings.LIST_REGION, toUri("/regions")))
    .add(new Link(CliStrings.DESCRIBE_REGION, toUri("/regions/{name}")))
    .add(new Link(CliStrings.ALTER_REGION, toUri("/regions/{name}"), HttpMethod.PUT))
    .add(new Link(CliStrings.CREATE_REGION, toUri("/regions"), HttpMethod.POST))
    .add(new Link(CliStrings.DESTROY_REGION, toUri("/regions/{name}"), HttpMethod.DELETE))
    // Index Commands
    .add(new Link(CliStrings.LIST_INDEX, toUri("/indexes")))
    .add(new Link(CliStrings.CREATE_INDEX, toUri("/indexes"), HttpMethod.POST))
    .add(new Link(CliStrings.DESTROY_INDEX, toUri("/indexes"), HttpMethod.DELETE))
    .add(new Link(CliStrings.DESTROY_INDEX, toUri("/indexes/{name}"), HttpMethod.DELETE))
    // Data Commands
    .add(new Link(CliStrings.GET, toUri("/regions/{region}/data"), HttpMethod.GET))
    .add(new Link(CliStrings.PUT, toUri("/regions/{region}/data"), HttpMethod.PUT))
    .add(new Link(CliStrings.REMOVE, toUri("/regions/{region}/data"), HttpMethod.DELETE))
    .add(new Link(CliStrings.EXPORT_DATA, toUri("/members/{member}/regions/{region}/data"), HttpMethod.GET))
    .add(new Link(CliStrings.IMPORT_DATA, toUri("/members/{member}/regions/{region}/data"), HttpMethod.POST))
    .add(new Link(CliStrings.LOCATE_ENTRY, toUri("/regions/{region}/data/location"), HttpMethod.GET))
    .add(new Link(CliStrings.QUERY, toUri("/regions/data/query"), HttpMethod.GET)) // verb!
    .add(new Link(CliStrings.REBALANCE, toUri("/regions/data/rebalance"), HttpMethod.POST)) // verb!
    // Function Commands
    .add(new Link(CliStrings.LIST_FUNCTION, toUri("/functions")))
    .add(new Link(CliStrings.DESTROY_FUNCTION, toUri("/functions/{id}"), HttpMethod.DELETE))
    .add(new Link(CliStrings.EXECUTE_FUNCTION, toUri("/functions/{id}"), HttpMethod.POST))
    // Config Commands
    .add(new Link(CliStrings.ALTER_RUNTIME_CONFIG, toUri("/config"), HttpMethod.POST))
    .add(new Link(CliStrings.DESCRIBE_CONFIG, toUri("/members/{member}/config")))
    .add(new Link(CliStrings.EXPORT_CONFIG, toUri("/config")))
    // Deploy Commands
    .add(new Link(CliStrings.LIST_DEPLOYED, toUri("/deployed")))
    .add(new Link(CliStrings.DEPLOY, toUri("/deployed"), HttpMethod.POST))
    .add(new Link(CliStrings.UNDEPLOY, toUri("/deployed"), HttpMethod.DELETE))
    // Disk Store Commands
    .add(new Link(CliStrings.LIST_DISK_STORE, toUri("/diskstores")))
    .add(new Link(CliStrings.BACKUP_DISK_STORE, toUri("/diskstores/backup"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.COMPACT_DISK_STORE, toUri("/diskstores/{name}/compact"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.CREATE_DISK_STORE, toUri("/diskstores"), HttpMethod.POST))
    .add(new Link(CliStrings.DESCRIBE_DISK_STORE, toUri("/diskstores/{name}")))
    .add(new Link(CliStrings.DESTROY_DISK_STORE, toUri("/diskstores/{name}"), HttpMethod.DELETE))
    .add(new Link(CliStrings.REVOKE_MISSING_DISK_STORE, toUri("/diskstores/{id}/revoke"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.SHOW_MISSING_DISK_STORE, toUri("/diskstores/missing")))
    // Launcher Lifecycle Commands
    .add(new Link(CliStrings.STATUS_LOCATOR, toUri("/members/{name}/locator")))
    .add(new Link(CliStrings.STATUS_SERVER, toUri("/members/{name}/server")))
    // Miscellaneous Commands
    .add(new Link(CliStrings.EXPORT_LOGS, toUri("/logs/export")))
    .add(new Link(CliStrings.EXPORT_STACKTRACE, toUri("/stacktraces/export")))
    .add(new Link(CliStrings.GC, toUri("/gc"), HttpMethod.POST))
    .add(new Link(CliStrings.GC, toUri("/members/{member}/gc"), HttpMethod.POST))
    .add(new Link(CliStrings.SHOW_DEADLOCK, toUri("/deadlocks")))
    .add(new Link(CliStrings.SHOW_LOG, toUri("/members/{member}/log")))
    .add(new Link(CliStrings.SHOW_METRICS, toUri("/metrics")))
    .add(new Link(CliStrings.SHUTDOWN, toUri("/shutdown"), HttpMethod.POST)) // verb!
    // Queue Commands
    .add(new Link(CliStrings.CREATE_ASYNC_EVENT_QUEUE, toUri("/async-event-queues"), HttpMethod.POST))
    .add(new Link(CliStrings.LIST_ASYNC_EVENT_QUEUES, toUri("/async-event-queues")))
    // Shell Commands
    .add(new Link(MBEAN_ATTRIBUTE_LINK_RELATION, toUri("/mbean/attribute")))
    .add(new Link(MBEAN_OPERATION_LINK_RELATION, toUri("/mbean/operation"), HttpMethod.POST))
    .add(new Link(MBEAN_QUERY_LINK_RELATION, toUri("/mbean/query"), HttpMethod.POST))
    .add(new Link(CliStrings.VERSION, toUri("/version")))
    // WAN Gateway Commands
    .add(new Link(CliStrings.LIST_GATEWAY, toUri("/gateways")))
    .add(new Link(CliStrings.CREATE_GATEWAYRECEIVER, toUri("/gateways/receivers"), HttpMethod.POST))
    .add(new Link(CliStrings.CREATE_GATEWAYSENDER, toUri("/gateways/senders"), HttpMethod.POST))
    .add(new Link(CliStrings.PAUSE_GATEWAYSENDER, toUri("/gateways/senders/{id}/pause"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.RESUME_GATEWAYSENDER, toUri("/gateways/senders/{id}/resume"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.START_GATEWAYRECEIVER, toUri("/gateways/receivers/start"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.START_GATEWAYSENDER, toUri("/gateways/senders/start"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.STATUS_GATEWAYRECEIVER, toUri("/gateways/receivers")))
    .add(new Link(CliStrings.STATUS_GATEWAYSENDER, toUri("/gateways/senders/{id}")))
    .add(new Link(CliStrings.STOP_GATEWAYRECEIVER, toUri("/gateways/receivers/stop"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.STOP_GATEWAYSENDER, toUri("/gateways/senders/{id}/stop"), HttpMethod.POST)); // verb!
}
 
Example 17
Source File: ShellCommandsController.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Gets a link index for the web service endpoints and REST API calls in GemFire for management and monitoring
 * using GemFire shell (Gfsh).
 * <p/>
 * @return a LinkIndex containing Links for all web service endpoints, REST API calls in GemFire.
 * @see com.gemstone.gemfire.management.internal.web.domain.Link
 * @see com.gemstone.gemfire.management.internal.web.domain.LinkIndex
 */
// TODO figure out a better way to maintain this link index, such as using an automated way to introspect
// the Spring Web MVC Controller RequestMapping Annotations.
// TODO refactor the URIs containing verbs!
@RequestMapping(value = "/index", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public LinkIndex index() {
  //logger.warning(String.format("Returning Link Index for Context Path (%1$s).",
  //  ServletUriComponentsBuilder.fromCurrentContextPath().build().toString()));
  return new LinkIndex()
    // Member Commands
    .add(new Link(CliStrings.LIST_MEMBER, toUri("/members")))
    .add(new Link(CliStrings.DESCRIBE_MEMBER, toUri("/members/{name}")))
    // Region Commands
    .add(new Link(CliStrings.LIST_REGION, toUri("/regions")))
    .add(new Link(CliStrings.DESCRIBE_REGION, toUri("/regions/{name}")))
    .add(new Link(CliStrings.ALTER_REGION, toUri("/regions/{name}"), HttpMethod.PUT))
    .add(new Link(CliStrings.CREATE_REGION, toUri("/regions"), HttpMethod.POST))
    .add(new Link(CliStrings.DESTROY_REGION, toUri("/regions/{name}"), HttpMethod.DELETE))
    // Index Commands
    .add(new Link(CliStrings.LIST_INDEX, toUri("/indexes")))
    .add(new Link(CliStrings.CREATE_INDEX, toUri("/indexes"), HttpMethod.POST))
    .add(new Link(CliStrings.DESTROY_INDEX, toUri("/indexes"), HttpMethod.DELETE))
    .add(new Link(CliStrings.DESTROY_INDEX, toUri("/indexes/{name}"), HttpMethod.DELETE))
    // Data Commands
    .add(new Link(CliStrings.GET, toUri("/regions/{region}/data"), HttpMethod.GET))
    .add(new Link(CliStrings.PUT, toUri("/regions/{region}/data"), HttpMethod.PUT))
    .add(new Link(CliStrings.REMOVE, toUri("/regions/{region}/data"), HttpMethod.DELETE))
    .add(new Link(CliStrings.EXPORT_DATA, toUri("/members/{member}/regions/{region}/data"), HttpMethod.GET))
    .add(new Link(CliStrings.IMPORT_DATA, toUri("/members/{member}/regions/{region}/data"), HttpMethod.POST))
    .add(new Link(CliStrings.LOCATE_ENTRY, toUri("/regions/{region}/data/location"), HttpMethod.GET))
    .add(new Link(CliStrings.QUERY, toUri("/regions/data/query"), HttpMethod.GET)) // verb!
    .add(new Link(CliStrings.REBALANCE, toUri("/regions/data/rebalance"), HttpMethod.POST)) // verb!
    // Function Commands
    .add(new Link(CliStrings.LIST_FUNCTION, toUri("/functions")))
    .add(new Link(CliStrings.DESTROY_FUNCTION, toUri("/functions/{id}"), HttpMethod.DELETE))
    .add(new Link(CliStrings.EXECUTE_FUNCTION, toUri("/functions/{id}"), HttpMethod.POST))
    // Config Commands
    .add(new Link(CliStrings.ALTER_RUNTIME_CONFIG, toUri("/config"), HttpMethod.POST))
    .add(new Link(CliStrings.DESCRIBE_CONFIG, toUri("/members/{member}/config")))
    .add(new Link(CliStrings.EXPORT_CONFIG, toUri("/config")))
    // Deploy Commands
    .add(new Link(CliStrings.LIST_DEPLOYED, toUri("/deployed")))
    .add(new Link(CliStrings.DEPLOY, toUri("/deployed"), HttpMethod.POST))
    .add(new Link(CliStrings.UNDEPLOY, toUri("/deployed"), HttpMethod.DELETE))
    // Disk Store Commands
    .add(new Link(CliStrings.LIST_DISK_STORE, toUri("/diskstores")))
    .add(new Link(CliStrings.BACKUP_DISK_STORE, toUri("/diskstores/backup"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.COMPACT_DISK_STORE, toUri("/diskstores/{name}/compact"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.CREATE_DISK_STORE, toUri("/diskstores"), HttpMethod.POST))
    .add(new Link(CliStrings.DESCRIBE_DISK_STORE, toUri("/diskstores/{name}")))
    .add(new Link(CliStrings.DESTROY_DISK_STORE, toUri("/diskstores/{name}"), HttpMethod.DELETE))
    .add(new Link(CliStrings.REVOKE_MISSING_DISK_STORE, toUri("/diskstores/{id}/revoke"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.SHOW_MISSING_DISK_STORE, toUri("/diskstores/missing")))
    // Launcher Lifecycle Commands
    .add(new Link(CliStrings.STATUS_LOCATOR, toUri("/members/{name}/locator")))
    .add(new Link(CliStrings.STATUS_SERVER, toUri("/members/{name}/server")))
    // Miscellaneous Commands
    .add(new Link(CliStrings.EXPORT_LOGS, toUri("/logs/export")))
    .add(new Link(CliStrings.EXPORT_STACKTRACE, toUri("/stacktraces/export")))
    .add(new Link(CliStrings.GC, toUri("/gc"), HttpMethod.POST))
    .add(new Link(CliStrings.GC, toUri("/members/{member}/gc"), HttpMethod.POST))
    .add(new Link(CliStrings.SHOW_DEADLOCK, toUri("/deadlocks")))
    .add(new Link(CliStrings.SHOW_LOG, toUri("/members/{member}/log")))
    .add(new Link(CliStrings.SHOW_METRICS, toUri("/metrics")))
    .add(new Link(CliStrings.SHUTDOWN, toUri("/shutdown"), HttpMethod.POST)) // verb!
    // Queue Commands
    .add(new Link(CliStrings.CREATE_ASYNC_EVENT_QUEUE, toUri("/async-event-queues"), HttpMethod.POST))
    .add(new Link(CliStrings.LIST_ASYNC_EVENT_QUEUES, toUri("/async-event-queues")))
    // Shell Commands
    .add(new Link(MBEAN_ATTRIBUTE_LINK_RELATION, toUri("/mbean/attribute")))
    .add(new Link(MBEAN_OPERATION_LINK_RELATION, toUri("/mbean/operation"), HttpMethod.POST))
    .add(new Link(MBEAN_QUERY_LINK_RELATION, toUri("/mbean/query"), HttpMethod.POST))
    .add(new Link(CliStrings.VERSION, toUri("/version")))
    // WAN Gateway Commands
    .add(new Link(CliStrings.LIST_GATEWAY, toUri("/gateways")))
    .add(new Link(CliStrings.CREATE_GATEWAYRECEIVER, toUri("/gateways/receivers"), HttpMethod.POST))
    .add(new Link(CliStrings.CREATE_GATEWAYSENDER, toUri("/gateways/senders"), HttpMethod.POST))
    .add(new Link(CliStrings.PAUSE_GATEWAYSENDER, toUri("/gateways/senders/{id}/pause"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.RESUME_GATEWAYSENDER, toUri("/gateways/senders/{id}/resume"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.START_GATEWAYRECEIVER, toUri("/gateways/receivers/start"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.START_GATEWAYSENDER, toUri("/gateways/senders/start"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.STATUS_GATEWAYRECEIVER, toUri("/gateways/receivers")))
    .add(new Link(CliStrings.STATUS_GATEWAYSENDER, toUri("/gateways/senders/{id}")))
    .add(new Link(CliStrings.STOP_GATEWAYRECEIVER, toUri("/gateways/receivers/stop"), HttpMethod.POST)) // verb!
    .add(new Link(CliStrings.STOP_GATEWAYSENDER, toUri("/gateways/senders/{id}/stop"), HttpMethod.POST)); // verb!
}
 
Example 18
Source File: MessageConversationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@RequestMapping( value = "/{uid}/assign", method = RequestMethod.POST, produces = {
    MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode setUserAssigned(
    @PathVariable String uid,
    @RequestParam( required = false ) String userId,
    HttpServletResponse response )
{
    RootNode responseNode = new RootNode( "response" );

    User user = currentUserService.getCurrentUser();

    if ( !canModifyUserConversation( user, user ) &&
        (messageService.hasAccessToManageFeedbackMessages( user )) )
    {
        throw new UpdateAccessDeniedException( "Not authorized to modify this object." );
    }

    org.hisp.dhis.message.MessageConversation messageConversation = messageService
        .getMessageConversation( uid );

    if ( messageConversation == null )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "No MessageConversation found for the given ID." ) );
        return responseNode;
    }

    User userToAssign;

    if ( (userToAssign = userService.getUser( userId )) == null )
    {
        response.setStatus( HttpServletResponse.SC_NOT_FOUND );
        responseNode.addChild( new SimpleNode( "message", "Could not find user to assign" ) );
        return responseNode;
    }

    if ( messageConversation.getMessageType() == MessageType.TICKET && !configurationService.isUserInFeedbackRecipientUserGroup( userToAssign ) )
    {
        response.setStatus( HttpServletResponse.SC_CONFLICT );
        responseNode.addChild( new SimpleNode( "message", "User provided is not a member of the system's feedback recipient group" ) );
        return responseNode;
    }

    messageConversation.setAssignee( userToAssign );
    messageService.updateMessageConversation( messageConversation );
    responseNode.addChild( new SimpleNode( "message", "User " + userToAssign.getName() + " was assigned successfully" ) );
    response.setStatus( HttpServletResponse.SC_OK );

    return responseNode;
}
 
Example 19
Source File: ContentController.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
/**
 * Interface: POST /api/rest/content/{id}/view
 * <p>
 * <p>
 * Display dynamic content. uitemplate is is correctly resolved using central view resolver.
 * <p>
 * <p>
 * <h3>Headers for operation</h3><p>
 * <table border="1">
 *     <tr><td>Accept</td><td>application/json</td></tr>
 *     <tr><td>Content-Type</td><td>application/json</td></tr>
 *     <tr><td>yc</td><td>token uuid (optional)</td></tr>
 * </table>
 * <p>
 * <p>
 * <h3>Parameters for operation</h3><p>
 * <table border="1">
 *     <tr><td>id</td><td>SEO URI or categoryId</td></tr>
 *     <tr><td>JSON variables to dynamic content</td><td>
 * <pre><code>
 *         {
 *             "datetime": "2015-01-01"
 *         }
 * </code></pre>
 *     </td></tr>
 * </table>
 * <p>
 * <p>
 * <h3>Output</h3><p>
 * <table border="1">
 *     <tr><td>JSON object ContentRO</td><td>
 * <pre><code>
 * {
 *         "availablefrom" : null,
 *         "categoryId" : 10002,
 *         "description" : "Dynamic Content Site Map Page",
 *         "metakeywords" : null,
 *         "uri" : "sitemap",
 *         "metadescription" : null,
 *         "contentBody" : "\n<p>This page demonstrates dynamic content featur ... \n\n\n",
 *         "availableto" : null,
 *         "breadcrumbs" : [
 *             {
 *                 "displayNames" : null,
 *                 "categoryId" : 10002,
 *                 "uri" : "sitemap",
 *                 "name" : "Sitemap"
 *             }
 *         ],
 *         "title" : null,
 *         "rank" : 0,
 *         "uitemplate" : "dynocontent",
 *         "attributes" : [],
 *         "displayTitles" : null,
 *         "displayNames" : null,
 *         "displayMetadescriptions" : null,
 *         "displayMetakeywords" : null,
 *         "name" : "Sitemap",
 *         "parentId" : 10000
 * }
 * </code></pre>
 *     </td></tr>
 * </table>
 *
 *
 * @param content SEO URI or categoryId
 * @param request request
 * @param response response
 *
 * @return content object
 */
@ApiOperation(value = "Display dynamic content. uitemplate is is correctly resolved using central view resolver.")
@RequestMapping(
        value = "/{id}/view",
        method = RequestMethod.POST,
        consumes = MediaType.APPLICATION_JSON_VALUE,
        produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }
)
public @ResponseBody ContentRO viewContent(final @ApiParam(value = "Request token") @RequestHeader(value = "yc", required = false) String requestToken,
                                           final @ApiParam(value = "Content ID or URI") @PathVariable(value = "id") String content,
                                           final @ApiParam(value = "Dynamic parameters") @RequestBody Map<String, Object> params,
                                           final HttpServletRequest request,
                                           final HttpServletResponse response) {

    cartMixin.throwSecurityExceptionIfRequireLoggedIn();
    cartMixin.persistShoppingCart(request, response);

    return viewContentInternal(content, params);
}
 
Example 20
Source File: RequestMappingHandlerMappingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@PostMapping(path = "/post", consumes = MediaType.APPLICATION_XML_VALUE)
public void post(@RequestBody(required = false) Foo foo) {
}