org.springframework.data.rest.webmvc.RootResourceInformation Java Examples

The following examples show how to use org.springframework.data.rest.webmvc.RootResourceInformation. 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: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_LOCK_MAPPING, method = RequestMethod.PUT)
public ResponseEntity<Resource<?>> lock(RootResourceInformation repoInfo,
										@PathVariable String repository,
										@PathVariable String id, Principal principal)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(LOCK_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	if (domainObj != null) {
		return ResponseEntity.ok().build();
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #2
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_LOCK_MAPPING, method = RequestMethod.DELETE)
public ResponseEntity<Resource<?>> unlock(RootResourceInformation repoInfo,
										  @PathVariable String repository,
										  @PathVariable String id, Principal principal)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(UNLOCK_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	if (domainObj != null) {
		return ResponseEntity.ok().build();
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #3
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_VERSION_MAPPING, method = RequestMethod.PUT)
public ResponseEntity<Resource<?>> version(RootResourceInformation repoInfo,
										   @PathVariable String repository,
										   @PathVariable String id,
										   @RequestBody VersionInfo info,
										   Principal principal,
										   PersistentEntityResourceAssembler assembler)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(VERSION_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj, info);

	if (domainObj != null) {
		return new ResponseEntity(assembler.toResource(domainObj), HttpStatus.OK);
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #4
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_FINDALLLATESTVERSION_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> findAllLatestVersion(RootResourceInformation repoInfo,
											  PersistentEntityResourceAssembler assembler,
											  @PathVariable String repository)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	RepositoryInformation repositoryInfo = RepositoryUtils.findRepositoryInformation(repositories, repository);
	Class<?> domainType = repositoryInfo.getDomainType();

	List result = (List)ReflectionUtils.invokeMethod(FINDALLLATESTVERSION_METHOD, repositories.getRepositoryFor(domainType).get());

	return ResponseEntity.ok(toResources(result, assembler, this.pagedResourcesAssembler, domainType, null));
}
 
Example #5
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping(value = FINDALLVERSIONS_METHOD_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> findAllVersions(RootResourceInformation repoInfo,
										 PersistentEntityResourceAssembler assembler,
										 @PathVariable String repository,
										 @PathVariable String id)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	List result = (List)ReflectionUtils.invokeMethod(FINDALLVERSIONS_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	return ResponseEntity.ok(toResources(result, assembler, this.pagedResourcesAssembler, domainObj.getClass(), null));
}
 
Example #6
Source File: ContentSearchRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@StoreType("contentstore")
@RequestMapping(value = ENTITY_CONTENTSEARCH_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> searchContent(RootResourceInformation repoInfo,
		DefaultedPageable pageable,
		Sort sort,
		PersistentEntityResourceAssembler assembler,
		@PathVariable String repository,
		@RequestParam(name = "queryString") String queryString)
		throws HttpRequestMethodNotSupportedException {

	return searchContentInternal(repoInfo, pageable, sort, assembler, "search", new String[]{queryString});
}
 
Example #7
Source File: ContentSearchRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@StoreType("contentstore")
@RequestMapping(value = ENTITY_SEARCHMETHOD_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> searchContent(RootResourceInformation repoInfo,
									   DefaultedPageable pageable,
									   Sort sort,
									   PersistentEntityResourceAssembler assembler,
									   @PathVariable String repository,
									   @RequestParam(name = "keyword") List<String> keywords)
		throws HttpRequestMethodNotSupportedException {

	return searchContentInternal(repoInfo, pageable, sort, assembler, "findKeyword", keywords.toArray(new String[]{}));
}