/** * rest api : convert file/folder name to id * @param fName file/folder name * @param site sitename * */ @Path(MAPRFSResourceConstants.MAPRFS_FNAME_RESOLVER) @GET @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) public String getFid(@QueryParam("fName") String fName, @QueryParam("site") String site) { String ans = "FID NOT FOUND"; try{ Map<String, Object> config = getAppConfig(site, MAPRFS_APPLICATION); String defaultFS; defaultFS = (String) config.get("fs.defaultFS"); Configuration conf = new Configuration(); conf.set("fs.defaultFS",defaultFS); mprcmd = new MapRCliCommands(conf); ans = fNameToFid(fName); return ans; }catch (Exception e){ LOG.info("maprfs: can not convert file/dir name " + fName + "to fid", e); ans = "CAN NOT RESOLVE THIS FID"; } return ans; }
/** * rest api : convert volume name to id by calling mapr's rest api * @param vName volume name * @param site site Name * */ @Path(MAPRFSResourceConstants.MAPRFS_VNAME_RESOLVER) @GET // The Java method will produce content identified by the MIME Media type "text/plain" @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) public String getVid(@QueryParam("vName") String vName, @QueryParam("site") String site) { String ans= "VOLUME ID NOT FOUDN"; try{ // call mapr rest api to get corresponding id; Map<String, Object> config = getAppConfig(site, MAPRFS_APPLICATION); String username; String password; username = (String) config.get(MAPRFSResourceConstants.MAPRFS_USERNAME); password = (String) config.get(MAPRFSResourceConstants.MAPRFS_PASSWORD); // call String restUrl = (String) config.get(MAPRFSResourceConstants.MAPRFS_WEBUI_HTTPS) + MAPRFSResourceConstants.MAPRFS_VOLUME_INFO + "?name=" + vName; JSONObject response = HttpRequest.executeGet(restUrl,username,password); ans = extractVolumeId(response); }catch (Exception e){ LOG.info("maprfs: can not convert volume name" + vName + " to id", e); } return ans; }