/** * validate HDFSResource Site and File Path * @param site * @param filePath * @throws Exception */ public void validate( String site, String filePath ) throws Exception { if (isNullOrEmpty(site)) throw new Exception("Invalid Request Received ... Site is Empty Or Null.."); if (isNullOrEmpty(filePath)) throw new Exception("Invalid Request Received ... file/Directory Path is Empty Or Null.."); }
@GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public HDFSResourceWebResponse getHDFSResource(@QueryParam("site") String site, @QueryParam("path") String filePath) { LOG.info("Starting HDFS Resource Browsing. Query Parameters ==> Site :" + site + " Path : " + filePath); HDFSResourceWebResponse response = new HDFSResourceWebResponse(); HDFSResourceWebRequestValidator validator = new HDFSResourceWebRequestValidator(); List<FileStatusEntity> result = new ArrayList<>(); List<FileStatus> fileStatuses = null; try { validator.validate(site, filePath); // First Step would be validating Request Map<String, Object> config = getAppConfig(site, HDFS_APPLICATION); Configuration conf = convert(config); HDFSFileSystem fileSystem = new HDFSFileSystem(conf); fileStatuses = fileSystem.browse(filePath); // Join with File Sensitivity Info HDFSResourceSensitivityDataJoiner joiner = new HDFSResourceSensitivityDataJoiner(dao); result = joiner.joinFileSensitivity(site, fileStatuses); LOG.info("Successfully browsed files in HDFS ."); } catch (Exception ex) { response.setException(EagleExceptionWrapper.wrap(ex)); LOG.error(" Exception When browsing Files for the HDFS Path :" + filePath + " ", ex); } response.setObj(result); return response; }
@GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public HDFSResourceWebResponse getHDFSResource(@QueryParam("site") String site , @QueryParam("path") String filePath ) { LOG.info("Starting MAPRFS Resource Browsing. Query Parameters ==> Site :"+site+" Path : "+filePath ); HDFSResourceWebResponse response = new HDFSResourceWebResponse(); HDFSResourceWebRequestValidator validator = new HDFSResourceWebRequestValidator(); List<FileStatusEntity> result = new ArrayList<>(); List<FileStatus> fileStatuses = null; try { validator.validate(site, filePath); // First Step would be validating Request Map<String, Object> config = getAppConfig(site, MAPRFS_APPLICATION); Configuration conf = convert(config); HDFSFileSystem fileSystem = new HDFSFileSystem(conf); fileStatuses = fileSystem.browse(filePath); // Join with File Sensitivity Info HDFSResourceSensitivityDataJoiner joiner = new HDFSResourceSensitivityDataJoiner(dao); result = joiner.joinFileSensitivity(site, fileStatuses); LOG.info("Successfully browsed files in MAPRFS ."); } catch( Exception ex ) { response.setException(EagleExceptionWrapper.wrap(ex)); LOG.error(" Exception When browsing Files for the MAPRFS Path :"+filePath+" " , ex); } response.setObj(result); return response; }
@GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public HDFSResourceWebResponse getHDFSResource( @QueryParam("site") String site , @QueryParam("path") String filePath ) { LOG.info("Starting HDFS Resource Browsing. Query Parameters ==> Site :"+site+" Path : "+filePath ); HDFSResourceWebResponse response = new HDFSResourceWebResponse(); HDFSResourceWebRequestValidator validator = new HDFSResourceWebRequestValidator(); MetadataAccessConfigRepo repo = new MetadataAccessConfigRepo(); List<FileStatusEntity> result = new ArrayList<>(); List<FileStatus> fileStatuses = null; try { validator.validate(site, filePath); // First Step would be validating Request Config config = repo.getConfig(HDFSResourceConstants.HDFS_APPLICATION, site); Configuration conf = repo.convert(config); HDFSFileSystem fileSystem = new HDFSFileSystem(conf); fileStatuses = fileSystem.browse(filePath); // Join with File Sensitivity Info HDFSResourceSensitivityDataJoiner joiner = new HDFSResourceSensitivityDataJoiner(); result = joiner.joinFileSensitivity(site, fileStatuses); LOG.info("Successfully browsed files in HDFS ."); } catch( Exception ex ) { response.setException(EagleExceptionWrapper.wrap(ex)); LOG.error(" Exception When browsing Files for the HDFS Path :"+filePath+" " , ex); } response.setObj(result); return response; } }
/** * validate HDFSResource Site and File Path * @param site * @param filePath * @throws Exception */ public void validate( String site, String filePath ) throws Exception { if (isNullOrEmpty(site)) throw new Exception("Invalid Request Received ... Site is Empty Or Null.."); if (isNullOrEmpty(filePath)) throw new Exception("Invalid Request Received ... file/Directory Path is Empty Or Null.."); }