use of org.apache.ranger.plugin.util.RangerRESTUtils in project ranger by apache.
the class AssetMgr method createPluginInfo.
public void createPluginInfo(String serviceName, String pluginId, HttpServletRequest request, int entityType, Long downloadedVersion, long lastKnownVersion, long lastActivationTime, int httpCode) {
RangerRESTUtils restUtils = new RangerRESTUtils();
final String ipAddress = getRemoteAddress(request);
final String appType = restUtils.getAppIdFromPluginId(pluginId);
String tmpHostName = null;
if (StringUtils.isNotBlank(pluginId)) {
tmpHostName = restUtils.getHostnameFromPluginId(pluginId, serviceName);
}
if (StringUtils.isBlank(tmpHostName) && request != null) {
tmpHostName = request.getRemoteHost();
}
final String hostName = (StringUtils.isBlank(tmpHostName)) ? ipAddress : tmpHostName;
RangerPluginInfo pluginSvcVersionInfo = new RangerPluginInfo();
pluginSvcVersionInfo.setServiceName(serviceName);
pluginSvcVersionInfo.setAppType(appType);
pluginSvcVersionInfo.setHostName(hostName);
pluginSvcVersionInfo.setIpAddress(ipAddress);
if (entityType == RangerPluginInfo.ENTITY_TYPE_POLICIES) {
pluginSvcVersionInfo.setPolicyActiveVersion(lastKnownVersion);
pluginSvcVersionInfo.setPolicyActivationTime(lastActivationTime);
pluginSvcVersionInfo.setPolicyDownloadedVersion(downloadedVersion);
pluginSvcVersionInfo.setPolicyDownloadTime(new Date().getTime());
} else {
pluginSvcVersionInfo.setTagActiveVersion(lastKnownVersion);
pluginSvcVersionInfo.setTagActivationTime(lastActivationTime);
pluginSvcVersionInfo.setTagDownloadedVersion(downloadedVersion);
pluginSvcVersionInfo.setTagDownloadTime(new Date().getTime());
}
createOrUpdatePluginInfo(pluginSvcVersionInfo, entityType == RangerPluginInfo.ENTITY_TYPE_POLICIES, httpCode);
}
Aggregations