168168@ Scope ("request" )
169169@ Transactional (propagation = Propagation .REQUIRES_NEW )
170170public class ServiceREST {
171+ private static final Logger LOG = LoggerFactory .getLogger (ServiceREST .class );
172+ private static final Logger PERF_LOG = RangerPerfTracer .getPerfLogger ("rest.ServiceREST" );
173+
171174 public static final String PARAM_SERVICE_NAME = "serviceName" ;
172175 public static final String PARAM_SERVICE_TYPE = "serviceType" ;
173176 public static final String PARAM_POLICY_NAME = "policyName" ;
@@ -189,8 +192,7 @@ public class ServiceREST {
189192 public static final String PURGE_RECORD_TYPE_LOGIN_LOGS = "login_records" ;
190193 public static final String PURGE_RECORD_TYPE_TRX_LOGS = "trx_records" ;
191194 public static final String PURGE_RECORD_TYPE_POLICY_EXPORT_LOGS = "policy_export_logs" ;
192- private static final Logger LOG = LoggerFactory .getLogger (ServiceREST .class );
193- private static final Logger PERF_LOG = RangerPerfTracer .getPerfLogger ("rest.ServiceREST" );
195+
194196 private final RangerAdminConfig config = RangerAdminConfig .getInstance ();
195197 private final int maxPolicyNameLength = config .getInt ("ranger.policyname.maxlength" , 255 );
196198 private final boolean isPolicyNameLengthValidationEnabled = config .getBoolean ("ranger.policyname.maxlength.validation.enabled" , true );
@@ -634,8 +636,7 @@ public RangerService createService(RangerService service) {
634636 if (session != null && !session .isSpnegoEnabled ()) {
635637 bizUtil .hasAdminPermissions ("Services" );
636638
637- // TODO: As of now we are allowing SYS_ADMIN to create all the
638- // services including KMS
639+ // TODO: As of now we are allowing SYS_ADMIN to create all the services including KMS
639640 bizUtil .hasKMSPermissions ("Service" , xxServiceDef .getImplclassname ());
640641 }
641642 if (session != null && session .isSpnegoEnabled ()) {
@@ -713,8 +714,7 @@ public RangerService updateService(RangerService service, @Context HttpServletRe
713714
714715 bizUtil .hasAdminPermissions ("Services" );
715716
716- // TODO: As of now we are allowing SYS_ADMIN to create all the
717- // services including KMS
717+ // TODO: As of now we are allowing SYS_ADMIN to create all the services including KMS
718718
719719 XXServiceDef xxServiceDef = daoManager .getXXServiceDef ().findByName (service .getType ());
720720 bizUtil .hasKMSPermissions ("Service" , xxServiceDef .getImplclassname ());
@@ -745,7 +745,7 @@ public void deleteService(@PathParam("id") Long id) {
745745
746746 String deletedServiceName = deleteServiceById (id );
747747
748- LOG .debug ("<== ServiceREST.deleteService() - [id={}],[deletedServiceName={}]" , deletedServiceName , deletedServiceName );
748+ LOG .debug ("<== ServiceREST.deleteService() - [id={}],[deletedServiceName={}]" , id , deletedServiceName );
749749 }
750750
751751 @ GET
@@ -966,7 +966,7 @@ public List<RangerServiceHeaderInfo> getServiceHeaders(@Context HttpServletReque
966966 @ Produces ("application/json" )
967967 @ PreAuthorize ("@rangerPreAuthSecurityHandler.isAPIAccessible(\" " + RangerAPIList .COUNT_SERVICES + "\" )" )
968968 public Long countServices (@ Context HttpServletRequest request ) {
969- LOG .debug ("==> ServiceREST.countServices(): " );
969+ LOG .debug ("==> ServiceREST.countServices()" );
970970
971971 Long ret = null ;
972972 RangerPerfTracer perf = null ;
@@ -1534,7 +1534,7 @@ public RangerPolicy createPolicy(RangerPolicy policy, @Context HttpServletReques
15341534 @ Consumes ("application/json" )
15351535 @ Produces ("application/json" )
15361536 public RangerPolicy applyPolicy (RangerPolicy policy , @ Context HttpServletRequest request ) {
1537- LOG .debug ("==> ServiceREST.applyPolicy({}, {} )" , policy );
1537+ LOG .debug ("==> ServiceREST.applyPolicy({})" , policy );
15381538
15391539 RangerPolicy ret = null ;
15401540
@@ -2040,12 +2040,14 @@ public void importPoliciesFromFile(@Context HttpServletRequest request, @FormDat
20402040 List <String > serviceNameList = new ArrayList <>();
20412041
20422042 getServiceNameList (request , serviceNameList );
2043+
20432044 Map <String , String > servicesMappingMap = new LinkedHashMap <>();
20442045 List <String > sourceServices = new ArrayList <>();
20452046 List <String > destinationServices = new ArrayList <>();
20462047 Map <String , String > zoneMappingMap = new LinkedHashMap <>();
20472048 List <String > sourceZones = new ArrayList <>();
20482049 List <String > destinationZones = new ArrayList <>();
2050+
20492051 if (zoneMapStream != null ) {
20502052 zoneMappingMap = svcStore .getMapFromInputStream (zoneMapStream );
20512053 processZoneMapping (zoneMappingMap , sourceZones , destinationZones );
@@ -2061,6 +2063,7 @@ public void importPoliciesFromFile(@Context HttpServletRequest request, @FormDat
20612063 String zoneNameInJson = null ;
20622064 Map <String , RangerPolicy > policiesMap = new LinkedHashMap <>();
20632065 List <String > dataFileSourceServices = new ArrayList <>();
2066+
20642067 if (fileName .endsWith ("json" )) {
20652068 try {
20662069 RangerExportPolicyList rangerExportPolicyList = null ;
@@ -2131,6 +2134,7 @@ public void importPoliciesFromFile(@Context HttpServletRequest request, @FormDat
21312134 String destinationZoneName = getDestinationZoneName (destinationZones , zoneNameInJson );
21322135 if (isOverride && !updateIfExists && StringUtils .isEmpty (polResource )) {
21332136 LOG .debug ("Deleting Policy from provided services in servicesMapJson file..." );
2137+
21342138 if (CollectionUtils .isNotEmpty (sourceServices ) && CollectionUtils .isNotEmpty (destinationServices )) {
21352139 deletePoliciesProvidedInServiceMap (sourceServices , destinationServices , destinationZoneName ); //In order to delete Zone specific policies from service
21362140 }
@@ -2695,8 +2699,7 @@ public HashMap<String, Object> getCSRFProperties(@Context HttpServletRequest req
26952699 @ PreAuthorize ("@rangerPreAuthSecurityHandler.isAPIAccessible(\" " + RangerAPIList .GET_METRICS_BY_TYPE + "\" )" )
26962700 public String getMetricByType (@ PathParam ("type" ) String type ) {
26972701 LOG .debug ("==> ServiceREST.getMetricByType(serviceDefName={})" , type );
2698- // as of now we are allowing only users with Admin role to access this
2699- // API
2702+ // as of now we are allowing only users with Admin role to access this API
27002703 bizUtil .checkSystemAdminAccess ();
27012704 bizUtil .blockAuditorRoleUser ();
27022705 String ret = null ;
@@ -2756,7 +2759,6 @@ public ResponseEntity<List<ServiceDeleteResponse>> deleteClusterServices(@PathPa
27562759 deleteResponse .setServiceName (serviceName );
27572760 deleteResponse .setIsDeleted (Boolean .TRUE );
27582761 } catch (Throwable e ) {
2759- //log and proceed
27602762 LOG .warn ("Skipping deletion of service with ID={}" , serviceId );
27612763 e .printStackTrace ();
27622764 deleteResponse .setIsDeleted (Boolean .FALSE );
@@ -3237,8 +3239,7 @@ private boolean validateDestZoneServiceMapping(String destinationZoneName, Range
32373239 LOG .error ("destination zone provided does not exist" );
32383240 throw restErrorUtil .createRESTException ("destination zone provided does not exist" );
32393241 }
3240- // CHECK IF json policies service is there on destination and asscioated with
3241- // destination zone.
3242+ // CHECK IF json policies service is there on destination and asscioated with destination zone.
32423243
32433244 String serviceNameToCheck = policyInJson .getService ();
32443245
0 commit comments