Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Dec 9, 2019
1 parent 33e8b34 commit 00151ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void initRestTemplate() {
}

@PostMapping("/EntityDescriptor")
@Transactional
public ResponseEntity<?> create(@RequestBody EntityDescriptorRepresentation edRepresentation) {
final String entityId = edRepresentation.getEntityId();

Expand All @@ -93,11 +94,13 @@ public ResponseEntity<?> create(@RequestBody EntityDescriptorRepresentation edRe
}

@PostMapping(value = "/EntityDescriptor", consumes = "application/xml")
@Transactional
public ResponseEntity<?> upload(@RequestBody byte[] entityDescriptorXml, @RequestParam String spName) throws Exception {
return handleUploadingEntityDescriptorXml(entityDescriptorXml, spName);
}

@PostMapping(value = "/EntityDescriptor", consumes = "application/x-www-form-urlencoded")
@Transactional
public ResponseEntity<?> upload(@RequestParam String metadataUrl, @RequestParam String spName) throws Exception {
try {
byte[] xmlContents = this.restTemplate.getForObject(metadataUrl, byte[].class);
Expand All @@ -112,6 +115,7 @@ public ResponseEntity<?> upload(@RequestParam String metadataUrl, @RequestParam
}

@PutMapping("/EntityDescriptor/{resourceId}")
@Transactional
public ResponseEntity<?> update(@RequestBody EntityDescriptorRepresentation edRepresentation, @PathVariable String resourceId) {
User currentUser = userService.getCurrentUser();
EntityDescriptor existingEd = entityDescriptorRepository.findByResourceId(resourceId);
Expand Down Expand Up @@ -163,6 +167,7 @@ public ResponseEntity<?> getAll() {
}

@GetMapping("/EntityDescriptor/{resourceId}")
@Transactional(readOnly = true)
public ResponseEntity<?> getOne(@PathVariable String resourceId) {
User currentUser = userService.getCurrentUser();
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
Expand All @@ -180,6 +185,7 @@ public ResponseEntity<?> getOne(@PathVariable String resourceId) {
}

@GetMapping(value = "/EntityDescriptor/{resourceId}", produces = "application/xml")
@Transactional(readOnly = true)
public ResponseEntity<?> getOneXml(@PathVariable String resourceId) throws MarshallingException {
User currentUser = userService.getCurrentUser();
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
Expand All @@ -195,7 +201,7 @@ public ResponseEntity<?> getOneXml(@PathVariable String resourceId) throws Marsh
}
}

@Transactional
@Transactional(readOnly = true)
@GetMapping(value = "/EntityDescriptor/disabledNonAdmin")
public Iterable<EntityDescriptorRepresentation> getDisabledAndNotOwnedByAdmin() {
return entityDescriptorRepository.findAllDisabledAndNotOwnedByAdmin()
Expand All @@ -205,6 +211,7 @@ public Iterable<EntityDescriptorRepresentation> getDisabledAndNotOwnedByAdmin()

@Secured("ROLE_ADMIN")
@DeleteMapping(value = "/EntityDescriptor/{resourceId}")
@Transactional
public ResponseEntity<?> deleteOne(@PathVariable String resourceId) {
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
if (ed == null) {
Expand All @@ -220,6 +227,7 @@ public ResponseEntity<?> deleteOne(@PathVariable String resourceId) {
//Versioning endpoints

@GetMapping("/EntityDescriptor/{resourceId}/Versions")
@Transactional(readOnly = true)
public ResponseEntity<?> getAllVersions(@PathVariable String resourceId) {
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
if (ed == null) {
Expand All @@ -236,6 +244,7 @@ public ResponseEntity<?> getAllVersions(@PathVariable String resourceId) {
}

@GetMapping("/EntityDescriptor/{resourceId}/Versions/{versionId}")
@Transactional(readOnly = true)
public ResponseEntity<?> getSpecificVersion(@PathVariable String resourceId, @PathVariable String versionId) {
EntityDescriptorRepresentation edRepresentation =
versionService.findSpecificVersionOfEntityDescriptor(resourceId, versionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public ResponseEntity<?> update(@PathVariable String resourceId, @RequestBody Me
//Versioning endpoints

@GetMapping("/MetadataResolvers/{resourceId}/Versions")
@Transactional(readOnly = true)
public ResponseEntity<?> getAllVersions(@PathVariable String resourceId) {
MetadataResolver resolver = resolverRepository.findByResourceId(resourceId);
if (resolver == null) {
Expand Down

0 comments on commit 00151ec

Please sign in to comment.