Search in sources :

Example 31 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class ServiceDBStore method getPaginatedServicePolicies.

public PList<RangerPolicy> getPaginatedServicePolicies(Long serviceId, SearchFilter filter) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
    }
    XXService service = daoMgr.getXXService().getById(serviceId);
    if (service == null) {
        throw new Exception("service does not exist - id='" + serviceId);
    }
    PList<RangerPolicy> ret = getPaginatedServicePolicies(service.getName(), filter);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
    }
    return ret;
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXService(org.apache.ranger.entity.XXService) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) JSONException(org.codehaus.jettison.json.JSONException)

Example 32 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class ServiceDBStore method getServicePoliciesIfUpdated.

@Override
public ServicePolicies getServicePoliciesIfUpdated(String serviceName, Long lastKnownVersion) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ")");
    }
    ServicePolicies ret = null;
    XXService serviceDbObj = daoMgr.getXXService().findByName(serviceName);
    if (serviceDbObj == null) {
        throw new Exception("service does not exist. name=" + serviceName);
    }
    XXServiceVersionInfo serviceVersionInfoDbObj = daoMgr.getXXServiceVersionInfo().findByServiceName(serviceName);
    if (serviceVersionInfoDbObj == null) {
        LOG.warn("serviceVersionInfo does not exist. name=" + serviceName);
    }
    if (lastKnownVersion == null || serviceVersionInfoDbObj == null || serviceVersionInfoDbObj.getPolicyVersion() == null || !lastKnownVersion.equals(serviceVersionInfoDbObj.getPolicyVersion())) {
        ret = RangerServicePoliciesCache.getInstance().getServicePolicies(serviceName, serviceDbObj.getId(), this);
    }
    if (ret != null && lastKnownVersion != null && lastKnownVersion.equals(ret.getPolicyVersion())) {
        // ServicePolicies are not changed
        ret = null;
    }
    if (LOG.isDebugEnabled()) {
        RangerServicePoliciesCache.getInstance().dump();
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceDBStore.getServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size()));
    }
    return ret;
}
Also used : ServicePolicies(org.apache.ranger.plugin.util.ServicePolicies) XXService(org.apache.ranger.entity.XXService) XXServiceVersionInfo(org.apache.ranger.entity.XXServiceVersionInfo) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) JSONException(org.codehaus.jettison.json.JSONException)

Example 33 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class RangerServiceService method getAllServices.

public List<RangerService> getAllServices() {
    List<XXService> xxServiceList = daoMgr.getXXService().getAll();
    List<RangerService> serviceList = new ArrayList<RangerService>();
    for (XXService xxService : xxServiceList) {
        RangerService service = populateViewBean(xxService);
        serviceList.add(service);
    }
    return serviceList;
}
Also used : ArrayList(java.util.ArrayList) RangerService(org.apache.ranger.plugin.model.RangerService) XXService(org.apache.ranger.entity.XXService)

Example 34 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class RangerServiceServiceBase method mapViewToEntityBean.

@Override
protected T mapViewToEntityBean(V vObj, T xObj, int OPERATION_CONTEXT) {
    String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid();
    xObj.setGuid(guid);
    XXServiceDef xServiceDef = daoMgr.getXXServiceDef().findByName(vObj.getType());
    if (xServiceDef == null) {
        throw restErrorUtil.createRESTException("No ServiceDefinition found with name :" + vObj.getType(), MessageEnums.INVALID_INPUT_DATA);
    }
    Long tagServiceId = null;
    String tagServiceName = vObj.getTagService();
    if (!StringUtils.isEmpty(tagServiceName)) {
        XXService xTagService = daoMgr.getXXService().findByName(tagServiceName);
        if (xTagService == null) {
            throw restErrorUtil.createRESTException("No Service found with name :" + tagServiceName, MessageEnums.INVALID_INPUT_DATA);
        }
        tagServiceId = xTagService.getId();
    }
    xObj.setType(xServiceDef.getId());
    xObj.setName(vObj.getName());
    xObj.setTagService(tagServiceId);
    if (OPERATION_CONTEXT == OPERATION_CREATE_CONTEXT) {
        xObj.setTagVersion(vObj.getTagVersion());
    }
    xObj.setDescription(vObj.getDescription());
    xObj.setIsEnabled(vObj.getIsEnabled());
    return xObj;
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXService(org.apache.ranger.entity.XXService)

Example 35 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class XAccessAuditService method mapEntityToViewBean.

protected VXAccessAudit mapEntityToViewBean(VXAccessAudit vObj, XXAccessAudit mObj) {
    vObj.setAuditType(mObj.getAuditType());
    vObj.setAccessResult(mObj.getAccessResult());
    vObj.setAccessType(mObj.getAccessType());
    vObj.setAclEnforcer(mObj.getAclEnforcer());
    vObj.setAgentId(mObj.getAgentId());
    vObj.setPolicyId(mObj.getPolicyId());
    vObj.setRepoName(mObj.getRepoName());
    vObj.setRepoType(mObj.getRepoType());
    vObj.setResultReason(mObj.getResultReason());
    vObj.setSessionId(mObj.getSessionId());
    vObj.setEventTime(mObj.getEventTime());
    vObj.setRequestUser(mObj.getRequestUser());
    vObj.setRequestData(mObj.getRequestData());
    vObj.setResourcePath(mObj.getResourcePath());
    vObj.setResourceType(mObj.getResourceType());
    vObj.setClientIP(mObj.getClientIP());
    vObj.setClientType(mObj.getClientType());
    vObj.setSequenceNumber(mObj.getSequenceNumber());
    vObj.setEventCount(mObj.getEventCount());
    vObj.setEventDuration(mObj.getEventDuration());
    vObj.setTags(mObj.getTags());
    XXService xService = daoManager.getXXService().findByName(mObj.getRepoName());
    if (xService != null) {
        XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType());
        vObj.setServiceType(xServiceDef.getName());
    }
    return vObj;
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXService(org.apache.ranger.entity.XXService)

Aggregations

XXService (org.apache.ranger.entity.XXService)73 XXServiceDef (org.apache.ranger.entity.XXServiceDef)34 RangerService (org.apache.ranger.plugin.model.RangerService)23 Test (org.junit.Test)21 XXServiceDao (org.apache.ranger.db.XXServiceDao)19 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)19 VXString (org.apache.ranger.view.VXString)19 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)17 ArrayList (java.util.ArrayList)14 XXServiceVersionInfo (org.apache.ranger.entity.XXServiceVersionInfo)14 Date (java.util.Date)13 WebApplicationException (javax.ws.rs.WebApplicationException)11 IOException (java.io.IOException)9 ServiceTags (org.apache.ranger.plugin.util.ServiceTags)9 XXServiceVersionInfoDao (org.apache.ranger.db.XXServiceVersionInfoDao)7 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)7 UnknownHostException (java.net.UnknownHostException)6 XXServiceConfigMap (org.apache.ranger.entity.XXServiceConfigMap)6 JSONException (org.codehaus.jettison.json.JSONException)6 HashMap (java.util.HashMap)5