ca.gc.aafc.dina.repository.ReadOnlyDinaRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dina-base-api Show documentation
Show all versions of dina-base-api Show documentation
Base DINA API package for Java built on SpringBoot and Crnk
package ca.gc.aafc.dina.repository;
import ca.gc.aafc.dina.entity.DinaEntity;
import ca.gc.aafc.dina.filter.DinaFilterResolver;
import ca.gc.aafc.dina.mapper.DinaMapper;
import ca.gc.aafc.dina.security.auth.ReadOnlyAuthorizationService;
import ca.gc.aafc.dina.service.DinaService;
import io.crnk.core.exception.MethodNotAllowedException;
import org.springframework.boot.info.BuildProperties;
import java.io.Serializable;
import java.util.Optional;
/**
* Read-only version of {@link DinaRepository}.
* create, save and delete will throw a {@link MethodNotAllowedException}.
* Authorization and auditing services is disabled.
* @param
* @param
*/
public class ReadOnlyDinaRepository extends DinaRepository {
public ReadOnlyDinaRepository(
DinaService dinaService,
DinaMapper dinaMapper,
Class resourceClass,
Class entityClass,
DinaFilterResolver filterResolver,
BuildProperties buildProperties
) {
super(
dinaService,
new ReadOnlyAuthorizationService(),
Optional.empty(),
dinaMapper,
resourceClass,
entityClass,
filterResolver,
null,
buildProperties, null);
}
/**
* Throws {@link MethodNotAllowedException}
* Create not allowed on read-only
* @param resource
* @param
* @return
*/
@Override
public S create(S resource) {
throw new MethodNotAllowedException("POST");
}
/**
* Throws {@link MethodNotAllowedException}
* Save not allowed on read-only
* @param resource
* @param
* @return
*/
@Override
public S save(S resource) {
throw new MethodNotAllowedException("PUT/PATCH");
}
/**
* Throws {@link MethodNotAllowedException}
* Delete not allowed on read-only
* @param id
*/
@Override
public void delete(Serializable id) {
throw new MethodNotAllowedException("DELETE");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy