List of usage examples for org.apache.commons.lang SystemUtils FILE_SEPARATOR
String FILE_SEPARATOR
To view the source code for org.apache.commons.lang SystemUtils FILE_SEPARATOR.
Click Source Link
The file.separator
System Property.
From source file:org.exem.flamingo.web.filesystem.hdfs.HdfsBrowserController.java
@RequestMapping(value = "copyToLocal", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)// ww w. j a v a 2 s. c o m public Response copyToLocal(@RequestParam String srcFullyQualifiedPath) { String username = getSessionUsername(); Long orgId = getOrgId(); String linuxUserHome = defaultLinuxUserHome + SystemUtils.FILE_SEPARATOR + username; boolean result = false; Response response = new Response(); if (getSessionUserLevel() == 1) { result = fileSystemService.copyToLocal(srcFullyQualifiedPath, linuxUserHome, username); } else { response.setSuccess(false); response.getError().setMessage(" ? ? ? ."); } response.setSuccess(result); return response; }
From source file:org.exem.flamingo.web.filesystem.hdfs.HdfsFileSystemServiceImpl.java
@Override public List<String> copyFiles(List<String> srcFileList, String dstPath, String username) { validateForbiddenPath(dstPath);/* w w w. j a va2s. c om*/ namenode2AgentService = getNamenode2AgentService(); List<String> copiedFiles = new ArrayList<>(); String dstFilePath; long length; boolean copied; // TODO > Bulk insert executeBatch ? if (srcFileList.size() > 1) { for (String srcFilePath : srcFileList) { if (dstPath.equalsIgnoreCase("/")) { dstFilePath = dstPath + FileUtils.getFilename(srcFilePath); } else { dstFilePath = dstPath + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(srcFilePath); } copied = namenode2AgentService.copy(srcFilePath, dstFilePath, username); if (copied) { copiedFiles.add(srcFilePath); } length = getFileInfo(srcFilePath).getLength(); //TODO Audit //auditService.log(username, FileSystemType.HDFS, AuditType.COPY, FileType.FILE, RequestType.UI, srcFilePath, dstFilePath, length); } } else { String srcPath = srcFileList.get(0); if (dstPath.equalsIgnoreCase("/")) { dstFilePath = dstPath + FileUtils.getFilename(srcPath); } else { dstFilePath = dstPath + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(srcPath); } copied = namenode2AgentService.copy(srcPath, dstFilePath, username); if (copied) { copiedFiles.add(srcPath); } length = getFileInfo(srcPath).getLength(); //TODO Audit //auditService.log(username, FileSystemType.HDFS, AuditType.COPY, FileType.FILE, RequestType.UI, srcPath, dstPath, length); } return copiedFiles; }
From source file:org.exem.flamingo.web.filesystem.hdfs.HdfsFileSystemServiceImpl.java
@Override public List<String> moveFiles(List<String> srcFileList, String dstPath, String username) { validateForbiddenPath(dstPath);// w ww. j a va 2s . co m namenode2AgentService = getNamenode2AgentService(); List<String> movedFiles = new ArrayList<>(); String dstFilePath; long length; boolean moved; /** * Case 1. ? * Case 2. ? ? */ if (srcFileList.size() > 1) { for (String srcFilePath : srcFileList) { if (dstPath.equalsIgnoreCase("/")) { dstFilePath = dstPath + FileUtils.getFilename(srcFilePath); } else { dstFilePath = dstPath + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(srcFilePath); } length = getFileInfo(srcFilePath).getLength(); moved = namenode2AgentService.move(srcFilePath, dstFilePath); if (moved) { movedFiles.add(srcFilePath); } //TODO Audit //auditService.log(username, FileSystemType.HDFS, AuditType.MOVE, FileType.FILE, RequestType.UI, srcFilePath, dstFilePath, length); } } else { String srcPath = srcFileList.get(0); if (dstPath.equalsIgnoreCase("/")) { dstFilePath = dstPath + FileUtils.getFilename(srcPath); } else { dstFilePath = dstPath + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(srcPath); } moved = namenode2AgentService.move(srcPath, dstFilePath); if (moved) { movedFiles.add(srcPath); } //TODO Audit //length = getFileInfo(srcPath).getLength(); //auditService.log(username, FileSystemType.HDFS, AuditType.MOVE, FileType.FILE, RequestType.UI, srcPath, dstFilePath, length); } return movedFiles; }
From source file:org.exem.flamingo.web.filesystem.hdfs.HdfsFileSystemServiceImpl.java
@Override public boolean copyToLocal(String srcFullyQualifiedPath, String linuxUserHome, String username) { namenode2AgentService = getNamenode2AgentService(); validateForbiddenPath(FileUtils.getPath(srcFullyQualifiedPath)); //long length = getFileInfo(srcFullyQualifiedPath).getLength(); String dstFullyQualifiedPath = linuxUserHome + SystemUtils.FILE_SEPARATOR + FileUtils.getDirectoryName(srcFullyQualifiedPath); //TODO Audit //auditService.log(username, FileSystemType.HDFS, AuditType.COPY_TO_LOCAL, FileType.FILE, RequestType.UI, srcFullyQualifiedPath, "", length); return namenode2AgentService.copyToLocal(srcFullyQualifiedPath, dstFullyQualifiedPath, linuxUserHome, username);/*from w w w .j av a 2 s. com*/ }
From source file:org.jiemamy.eclipse.core.ui.composer.DbImporterWizardPage.java
private void createButtons(Composite cmpButtons) { btnAddJar = new Button(cmpButtons, SWT.PUSH); btnAddJar.setText("(&A)"); // RESOURCE btnAddJar.addSelectionListener(new SelectionAdapter() { @Override//from www .ja v a 2s. c om public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(getShell(), SWT.MULTI | SWT.OPEN); fileDialog.setText("JDBC?jar??"); // RESOURCE fileDialog.setFilterExtensions(JAR_EXTENSIONS); if (fileDialog.open() == null) { return; } String[] fileNames = fileDialog.getFileNames(); String filterPath = fileDialog.getFilterPath(); for (String fileName : fileNames) { lstDriverJars.add(filterPath + SystemUtils.FILE_SEPARATOR + fileName); } if (ArrayUtils.isEmpty(fileNames) == false) { driverListChanged(); } } }); btnRemoveJar = new Button(cmpButtons, SWT.PUSH); btnRemoveJar.setText("(&R)"); // RESOURCE btnRemoveJar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int[] selectionIndices = lstDriverJars.getSelectionIndices(); if (ArrayUtils.isEmpty(selectionIndices)) { return; } Arrays.sort(selectionIndices); ArrayUtils.reverse(selectionIndices); for (int selectionIndex : selectionIndices) { lstDriverJars.remove(selectionIndex); } if (ArrayUtils.isEmpty(selectionIndices) == false) { driverListChanged(); } } }); }
From source file:org.nomt.agent.nmon.job.NmonJob.java
@Override public void perform() { logger.debug("NmonJob.perform()"); SimpleDateFormat sdFormat = new SimpleDateFormat("yyyyMMddhhmmss"); AgentConfig config = AgentConfig.getInstance(); String nmonDir = config.getNmonBinaryDir(); String nmonDataDir = config.getNmonOutputDir(); String nmonFileName = nmonDataDir + SystemUtils.FILE_SEPARATOR + "nmon_data_" + sdFormat.format(System.currentTimeMillis()) + ".nmon"; String nmonCmd = nmonDir + SystemUtils.FILE_SEPARATOR + "nmon -c 1 -F " + nmonFileName; String executeCommand = ShellUtil.getInstance().executeCommand(nmonCmd); logger.debug("Execute command {}, execute result is {}", nmonCmd, executeCommand); // wait 3 seconds in case the nmon file is not finished. ThreadUtil.sleep(3000);/* w w w .j a v a 2s . c o m*/ NmonDataFiles.putNewFile(nmonFileName); }
From source file:org.openflamingo.fs.hdfs.HdfsFileSystemProvider.java
/** * ? ? ??./* ww w . j av a 2 s . com*/ * <p/> * <ul> * <li>? ?? ?.</li> * <li>? ?? ?? ( ?).</li> * <li>? ? ? ??.</li> * </ul> * * @param from ?? ? ? ? ? * @param to ?? ? * @return ?? ?? <tt>true</tt>, ? <tt>false</tt> */ @Override public boolean move(String from, String to) { if (!exists(from)) { throw new FileSystemException(bundle.message("S_FS", "CANNOT_MOVE", from)); } if (getFileInfo(to).isFile()) { throw new FileSystemException(bundle.message("S_FS", "ALREADY_NOT_MOVE", to, from)); } // ?? ? ? ?? ?? . String target = to + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(from); if (exists(target)) { throw new FileSystemException(bundle.message("S_FS", "ALREADY_EXISTS_NOT_MOVE", target)); } try { Path srcPath = new Path(from); Path dstPath = new Path(to); return fs.rename(srcPath, dstPath); } catch (Exception ex) { throw new FileSystemException(bundle.message("S_FS", "CANNOT_MOVE", from, to), ex); } }
From source file:org.openflamingo.fs.hdfs.HdfsFileSystemProvider.java
@Override public boolean copy(String from, String to) { // ?? ? ? ?? ?? . String target = null;/*from w ww .j a va 2 s . c o m*/ if ("/".equals(to)) { target = to + FileUtils.getFilename(from); } else { target = to + SystemUtils.FILE_SEPARATOR + FileUtils.getFilename(from); } if (exists(target)) throw new FileSystemException(bundle.message("S_FS", "ALREADY_NOT_COPY", target)); try { if (fs.isFile(new Path(from))) { FSDataInputStream fis = fs.open(new Path(from)); FSDataOutputStream fos = fs.create(new Path(target)); org.springframework.util.FileCopyUtils.copy(fis, fos); IOUtils.closeQuietly(fos); IOUtils.closeQuietly(fis); } else { FileUtil.copy(fs, new Path(from), fs, new Path(to), false, new Configuration()); } return true; } catch (Exception ex) { throw new FileSystemException(bundle.message("S_FS", "CANNOT_COPY", from, to), ex); } }
From source file:ws.michalski.velogen.VeloGenManager.java
/** * Liefert Output-Path fr generierte Dateien * //from w w w . j ava2 s . c om * 1. Es wird geprft, ob Parameter -op gesetzt ist, sonst * 2. wird geprft, ob config diese Information enthlt, sonst * 3. wird Unterverzeichnis ./output genutzt. * * * @return */ public String getOutputPath() { String outputPath = null; if (veloCmd.getCommonParam().getOutputPath() != null) { outputPath = veloCmd.getCommonParam().getOutputPath(); } else if (config.getOutputPath() != null) { outputPath = config.getOutputPath(); } else { outputPath = SystemUtils.USER_DIR + SystemUtils.FILE_SEPARATOR + "output"; } Path path = Paths.get(outputPath); if (Files.notExists(path, LinkOption.NOFOLLOW_LINKS) || !Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS)) { logger.error("Output path error"); // TODO: Exception } if (logger.isDebugEnabled()) { logger.debug("Path " + path.toAbsolutePath().normalize().toString()); } return path.toAbsolutePath().normalize().toString(); }