RegisterFile extends MetadataAPIBase { @Override public RegisterFileInfo execute(String[] params) { try { RegisterFileInfo registerFileInfo = new RegisterFileInfo(); CommandLine commandLine = getCommandLine(params, PARAMS_STRUCTURE); String pid = commandLine.getOptionValue("sub-process-id"); LOGGER.debug("subProcessId is " + pid); String sId = commandLine.getOptionValue("server-id"); LOGGER.debug("serverId is " + sId); String path = commandLine.getOptionValue("path"); LOGGER.debug("path is " + path); String fSize = commandLine.getOptionValue("file-size"); LOGGER.debug("file size is " + fSize); String fHash = commandLine.getOptionValue("file-hash"); LOGGER.debug("file-hash " + fHash); LOGGER.debug("creation _ts modified "+commandLine.getOptionValue("creation-timestamp")); String creationTs = commandLine.getOptionValue("creation-timestamp").replace("__"," "); LOGGER.debug("creation Ts " + creationTs); String batchId = commandLine.getOptionValue("batch-id"); LOGGER.debug("batchId " + batchId); if ("0".equalsIgnoreCase(batchId) || "NULL".equalsIgnoreCase(batchId)) { registerFileInfo.setBatchId(null); } else { registerFileInfo.setBatchId(new Long(batchId)); } registerFileInfo.setSubProcessId(Integer.parseInt(pid)); registerFileInfo.setPath(path); registerFileInfo.setServerId(Integer.parseInt(sId)); registerFileInfo.setFileSize(Long.parseLong(fSize)); registerFileInfo.setFileHash(fHash); registerFileInfo.setCreationTs(Timestamp.valueOf(creationTs)); registerFileInfo = registerFileDAO.registerFile(registerFileInfo); LOGGER.debug("registerFileInfo " + registerFileInfo.getPath() + " " + registerFileInfo.getBatchId()); LOGGER.debug("registerFileInfo " + registerFileInfo.getSubProcessId() + " " + registerFileInfo.getCreationTs()); return registerFileInfo; } catch (Exception e) { LOGGER.error("Error occurred", e); throw new MetadataException(e); } } RegisterFile(); @Override RegisterFileInfo execute(String[] params);  }
@Ignore @Test public void testExecute() throws Exception { String[] args = {"-cTS", "2014-12-11 11:56:17", "-fh", "3", "-sId", "1", "-fs", "3", "-p", "134", "--path", "/home/cool5", "--batch-id", "null"}; RegisterFile bs = new RegisterFile(); RegisterFileInfo info = bs.execute(args); LOGGER.debug(info); }