use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class PatchMigration_J10002 method migrateServicesToNewSchema.
public void migrateServicesToNewSchema() throws Exception {
logger.info("==> MigrationPatch.migrateServicesToNewSchema()");
try {
List<XXAsset> repoList = daoMgr.getXXAsset().getAll();
if (repoList.isEmpty()) {
return;
}
if (!repoList.isEmpty()) {
EmbeddedServiceDefsUtil.instance().init(svcDBStore);
}
svcDBStore.setPopulateExistingBaseFields(true);
for (XXAsset xAsset : repoList) {
if (xAsset.getActiveStatus() == AppConstants.STATUS_DELETED) {
continue;
}
RangerService existing = svcDBStore.getServiceByName(xAsset.getName());
if (existing != null) {
logger.info("Repository/Service already exists. Ignoring migration of repo: " + xAsset.getName());
continue;
}
RangerService service = new RangerService();
service = mapXAssetToService(service, xAsset);
service = svcDBStore.createService(service);
serviceCounter++;
logger.info("New Service created. ServiceName: " + service.getName());
}
svcDBStore.setPopulateExistingBaseFields(false);
} catch (Exception e) {
throw new Exception("Error while migrating data to new Plugin Schema.", e);
}
logger.info("<== MigrationPatch.migrateServicesToNewSchema()");
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class AssetREST method getXAsset.
@GET
@Path("/assets/{id}")
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_X_ASSET + "\")")
public VXAsset getXAsset(@PathParam("id") Long id) {
if (logger.isDebugEnabled()) {
logger.debug("==> AssetREST.getXAsset(" + id + ")");
}
RangerService service = serviceREST.getService(id);
VXAsset ret = serviceUtil.toVXAsset(service);
if (logger.isDebugEnabled()) {
logger.debug("<== AssetREST.getXAsset(" + id + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class AssetREST method searchXResources.
@GET
@Path("/resources")
@Produces({ "application/xml", "application/json" })
public VXResourceList searchXResources(@Context HttpServletRequest request) {
if (logger.isDebugEnabled()) {
logger.debug("==> AssetREST.searchXResources()");
}
VXResourceList ret = new VXResourceList();
SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequest(request, xResourceService.sortFields);
List<RangerPolicy> policies = serviceREST.getPolicies(filter);
if (policies != null) {
List<VXResource> resources = new ArrayList<VXResource>();
for (RangerPolicy policy : policies) {
RangerService service = serviceREST.getServiceByName(policy.getService());
VXResource resource = serviceUtil.toVXResource(policy, service);
if (resource != null) {
resources.add(resource);
}
}
ret.setVXResources(resources);
}
if (logger.isDebugEnabled()) {
logger.debug("<== AssetREST.searchXResources(): count=" + ret.getResultSize());
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class AssetREST method createXResource.
@POST
@Path("/resources")
@Produces({ "application/xml", "application/json" })
public VXResource createXResource(VXResource vXResource) {
if (logger.isDebugEnabled()) {
logger.debug("==> AssetREST.createXResource(" + vXResource + ")");
}
RangerService service = serviceREST.getService(vXResource.getAssetId());
RangerPolicy policy = serviceUtil.toRangerPolicy(vXResource, service);
RangerPolicy createdPolicy = serviceREST.createPolicy(policy, null);
VXResource ret = serviceUtil.toVXResource(createdPolicy, service);
if (logger.isDebugEnabled()) {
logger.debug("<== AssetREST.createXResource(" + vXResource + "): " + ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class AssetREST method configTest.
@POST
@Path("/assets/testConfig")
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.TEST_CONFIG + "\")")
public VXResponse configTest(VXAsset vXAsset) {
if (logger.isDebugEnabled()) {
logger.debug("==> AssetREST.configTest(" + vXAsset + ")");
}
RangerService service = serviceUtil.toRangerService(vXAsset);
VXResponse ret = serviceREST.validateConfig(service);
if (logger.isDebugEnabled()) {
logger.debug("<== AssetREST.testConfig(" + vXAsset + "): " + ret);
}
return ret;
}
Aggregations