use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class AssetREST method createXAsset.
@POST
@Path("/assets")
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_X_ASSET + "\")")
public VXAsset createXAsset(VXAsset vXAsset) {
if (logger.isDebugEnabled()) {
logger.debug("==> AssetREST.createXAsset(" + vXAsset + ")");
}
RangerService service = serviceUtil.toRangerService(vXAsset);
RangerService createdService = serviceREST.createService(service);
VXAsset ret = serviceUtil.toVXAsset(createdService);
if (logger.isDebugEnabled()) {
logger.debug("<== AssetREST.createXAsset(" + vXAsset + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class PublicAPIs method getPolicy.
@GET
@Path("/api/policy/{id}")
@Produces({ "application/json", "application/xml" })
public VXPolicy getPolicy(@PathParam("id") Long id) {
if (logger.isDebugEnabled()) {
logger.debug("==> PublicAPIs.getPolicy() " + id);
}
RangerPolicy policy = null;
RangerService service = null;
policy = serviceREST.getPolicy(id);
if (policy != null) {
service = serviceREST.getServiceByName(policy.getService());
}
VXPolicy ret = serviceUtil.toVXPolicy(policy, service);
if (logger.isDebugEnabled()) {
logger.debug("<== PublicAPIs.getPolicy()" + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class PublicAPIs method searchRepositories.
@GET
@Path("/api/repository/")
@Produces({ "application/json", "application/xml" })
public VXRepositoryList searchRepositories(@Context HttpServletRequest request) {
if (logger.isDebugEnabled()) {
logger.debug("==> PublicAPIs.searchRepositories()");
}
SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields);
List<RangerService> serviceList = serviceREST.getServices(filter);
VXRepositoryList ret = null;
if (serviceList != null) {
ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList);
}
if (logger.isDebugEnabled()) {
logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize()));
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class PublicAPIs method createPolicy.
@POST
@Path("/api/policy")
@Produces({ "application/json", "application/xml" })
public VXPolicy createPolicy(VXPolicy vXPolicy) {
if (logger.isDebugEnabled()) {
logger.debug("==> PublicAPIs.createPolicy()");
}
RangerService service = serviceREST.getServiceByName(vXPolicy.getRepositoryName());
RangerPolicy policy = serviceUtil.toRangerPolicy(vXPolicy, service);
VXPolicy ret = null;
if (policy != null) {
if (logger.isDebugEnabled()) {
logger.debug("RANGERPOLICY: " + policy.toString());
}
RangerPolicy createdPolicy = serviceREST.createPolicy(policy, null);
ret = serviceUtil.toVXPolicy(createdPolicy, service);
}
if (logger.isDebugEnabled()) {
logger.debug("<== PublicAPIs.createPolicy(" + policy + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class PublicAPIs method updatePolicy.
@PUT
@Path("/api/policy/{id}")
@Produces({ "application/json", "application/xml" })
public VXPolicy updatePolicy(VXPolicy vXPolicy, @PathParam("id") Long id) {
if (logger.isDebugEnabled()) {
logger.debug("==> PublicAPIs.updatePolicy(): " + vXPolicy);
}
XXPolicy existing = daoMgr.getXXPolicy().getById(id);
if (existing == null) {
throw restErrorUtil.createRESTException("Policy not found for Id: " + id, MessageEnums.DATA_NOT_FOUND);
}
vXPolicy.setId(id);
RangerService service = serviceREST.getServiceByName(vXPolicy.getRepositoryName());
RangerPolicy policy = serviceUtil.toRangerPolicy(vXPolicy, service);
VXPolicy ret = null;
if (policy != null) {
policy.setVersion(existing.getVersion());
RangerPolicy updatedPolicy = serviceREST.updatePolicy(policy);
ret = serviceUtil.toVXPolicy(updatedPolicy, service);
}
if (logger.isDebugEnabled()) {
logger.debug("<== PublicAPIs.updatePolicy(" + policy + "): " + ret);
}
return ret;
}
Aggregations