Search in sources :

Example 16 with PrivilegeDescription

use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.

the class XmEntitySpecResource method generateXmEntity.

/**
 * POST  /xm-entity-specs/generate-xm-entity : Generate a new xmEntity.
 *
 * @return the ResponseEntity with status 201 (Created) and with body the new xmEntity
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/xm-entity-specs/generate-xm-entity")
@Timed
@PreAuthorize("hasPermission({'rootTypeKey': #rootTypeKey}, 'XMENTITY_SPEC.GENERATE')")
@PrivilegeDescription("Privilege to generate a new random xmEntity with passed type. Used for demo")
public ResponseEntity<XmEntity> generateXmEntity(@ApiParam String rootTypeKey) throws URISyntaxException {
    log.debug("REST request to generate XmEntity");
    XmEntity result = xmEntityGeneratorService.generateXmEntity(rootTypeKey != null ? rootTypeKey : "");
    return ResponseEntity.created(new URI("/api/xm-entities/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) URI(java.net.URI) PostMapping(org.springframework.web.bind.annotation.PostMapping) Timed(com.codahale.metrics.annotation.Timed) PrivilegeDescription(com.icthh.xm.commons.permission.annotation.PrivilegeDescription) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

PrivilegeDescription (com.icthh.xm.commons.permission.annotation.PrivilegeDescription)16 Timed (com.codahale.metrics.annotation.Timed)15 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)15 HttpHeaders (org.springframework.http.HttpHeaders)8 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)7 ResponseEntity (org.springframework.http.ResponseEntity)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)7 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 URI (java.net.URI)5 Resource (org.springframework.core.io.Resource)4 FunctionContext (com.icthh.xm.ms.entity.domain.FunctionContext)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 LogicExtensionPoint (com.icthh.xm.commons.lep.LogicExtensionPoint)1 FindWithPermission (com.icthh.xm.commons.permission.annotation.FindWithPermission)1 Event (com.icthh.xm.ms.entity.domain.Event)1 LinkSpec (com.icthh.xm.ms.entity.domain.spec.LinkSpec)1 LinkProjection (com.icthh.xm.ms.entity.projection.LinkProjection)1 SearchDto (com.icthh.xm.ms.entity.service.dto.SearchDto)1 SneakyThrows (lombok.SneakyThrows)1 FetchSourceFilter (org.springframework.data.elasticsearch.core.query.FetchSourceFilter)1