Examples of RepositoryInvoker


Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

    // Force ID on unmarshalled object
    BeanWrapper<Object> incomingWrapper = BeanWrapper.create(payload.getContent(), conversionService);
    incomingWrapper.setProperty(payload.getPersistentEntity().getIdProperty(), id);

    RepositoryInvoker invoker = resourceInformation.getInvoker();
    Object objectToSave = incomingWrapper.getBean();

    return invoker.invokeFindOne(id) == null ? createAndReturn(objectToSave, invoker, assembler) : saveAndReturn(
        objectToSave, invoker, PUT, assembler);
  }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

  public ResponseEntity<?> deleteItemResource(RootResourceInformation resourceInformation, @BackendId Serializable id)
      throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

    resourceInformation.verifySupportedMethod(HttpMethod.DELETE, ResourceType.ITEM);

    RepositoryInvoker invoker = resourceInformation.getInvoker();
    Object domainObj = invoker.invokeFindOne(id);

    if (domainObj == null) {
      throw new ResourceNotFoundException();
    }

    publisher.publishEvent(new BeforeDeleteEvent(domainObj));
    invoker.invokeDelete(id);
    publisher.publishEvent(new AfterDeleteEvent(domainObj));

    return new ResponseEntity<Object>(HttpStatus.NO_CONTENT);
  }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

  private Object getItemResource(RootResourceInformation resourceInformation, Serializable id)
      throws HttpRequestMethodNotSupportedException, ResourceNotFoundException {

    resourceInformation.verifySupportedMethod(HttpMethod.GET, ResourceType.ITEM);

    RepositoryInvoker repoMethodInvoker = resourceInformation.getInvoker();

    if (!repoMethodInvoker.exposesFindOne()) {
      throw new ResourceNotFoundException();
    }

    return repoMethodInvoker.invokeFindOne(id);
  }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

      if (id == null) {
        new ResourceNotFoundException();
      }

      RepositoryInvoker invoker = information.getInvoker();
      Object existingObject = invoker.invokeFindOne(id);

      if (existingObject == null) {
        throw new ResourceNotFoundException();
      }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

    }

    @RequestMapping(value = BASE_MAPPING + "/file", method = GET)
    public void filePropertyOfEntity(RootResourceInformation repoRequest, ServletResponse response, @BackendId Serializable id, @PathVariable String property) throws Exception {
        PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity();
        RepositoryInvoker invoker = repoRequest.getInvoker();

        Object domainObj = invoker.invokeFindOne(id);

        if (null == domainObj) {
            throw new ResourceNotFoundException();
        }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

    }

    @RequestMapping(value = BASE_MAPPING + "/binary", method = GET)
    public ResponseEntity<?> filePropertyValueOfEntity(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception {
        PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity();
        RepositoryInvoker invoker = repoRequest.getInvoker();

        Object domainObj = invoker.invokeFindOne(id);

        if (null == domainObj) {
            throw new ResourceNotFoundException();
        }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

    }

    @RequestMapping(value = BASE_MAPPING + "/file", method = DELETE)
    public ResponseEntity<?> deleteFileOfPropertyOfEntity(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception {
        PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity();
        RepositoryInvoker invoker = repoRequest.getInvoker();

        Object domainObj = invoker.invokeFindOne(id);

        if (null == domainObj) {
            throw new ResourceNotFoundException();
        }

        PersistentProperty<?> prop = persistentEntity.getPersistentProperty(property);
        if (null == prop) {
            throw new ResourceNotFoundException();
        }

        if (!isOfFileType(prop)) {
            return toEmptyResponse(METHOD_NOT_ALLOWED);
        }

        fileResourceStorage().delete(domainObj, prop);

        invoker.invokeSave(domainObj);

        return toEmptyResponse(OK);
    }
View Full Code Here

Examples of org.springframework.data.rest.core.invoke.RepositoryInvoker

    }

    @Override
    public RepositoryInvoker getInvokerFor(Class<?> domainType) {
        DynamicJpaRepository dynamicJpaRepository = (DynamicJpaRepository) repositories.getRepositoryFor(domainType);
        RepositoryInvoker repositoryInvoker = delegate.getInvokerFor(domainType);

        return new DynamicRepositoryInvokerWrapper(dynamicJpaRepository, repositoryInvoker);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.