List of usage examples for org.apache.commons.io FilenameUtils getName
public static String getName(String filename)
From source file:com.ephesoft.gxt.admin.server.ImportTableUploadServlet.java
/** * This API is used to get table file name. * /* w ww .ja v a2s.c om*/ * @param item {@link FileItem} uploaded file item. * @return {@link String} table file name. */ private String getTableFileName(final FileItem item) { String tableFileName = item.getName(); if (tableFileName != null) { tableFileName = tableFileName.substring(tableFileName.lastIndexOf(File.separator) + 1); tableFileName = FilenameUtils.getName(tableFileName); } return tableFileName; }
From source file:net.sourceforge.dita4publishers.impl.bos.BosMemberBase.java
/** * @return//from w ww . j a v a 2s.co m */ public String getFileName() { if (this.fileName == null && this.getEffectiveUri() != null) { this.fileName = FilenameUtils.getName(this.getEffectiveUri().getPath()); } return this.fileName; }
From source file:io.github.retz.inttest.RetzIntTest.java
@Test public void runAppTest() throws Exception { URI uri = new URI("http://" + RETZ_HOST + ":" + RETZ_PORT); Client client = Client.newBuilder(uri).setAuthenticator(config.getAuthenticator()).build(); Application echoApp = new Application("echo-app", Arrays.asList(), Arrays.asList("file:///spawn_retz_server.sh"), Optional.empty(), "deadbeef", 0, new MesosContainer(), true); LoadAppResponse loadRes = (LoadAppResponse) client.load(echoApp); assertThat(loadRes.status(), is("ok")); ListAppResponse listRes = (ListAppResponse) client.listApp(); assertThat(listRes.status(), is("ok")); List<String> appNameList = listRes.applicationList().stream().map(app -> app.getAppid()) .collect(Collectors.toList()); assertIncludes(appNameList, "echo-app"); {//from ww w . jav a 2 s .co m String echoText = "hoge from echo-app via Retz"; Job job = new Job("echo-app", "echo " + echoText, new Properties(), 2, 256, 32, 0, 1); Job runRes = client.run(job); assertThat(runRes.result(), is(RES_OK)); assertThat(runRes.state(), is(Job.JobState.FINISHED)); String toDir = "build/log/"; // These downloaded files are not inspected now, useful for debugging test cases, maybe ClientHelper.getWholeFile(client, runRes.id(), "stdout", toDir); ClientHelper.getWholeFile(client, runRes.id(), "stderr", toDir); String actualText = catStdout(client, runRes); List<String> lines = Arrays.asList(actualText.split("\n")); assertThat(lines, hasItem(echoText)); assertThat(lines, hasItem("Received SUBSCRIBED event")); assertThat(lines, hasItem("Received LAUNCH event")); } assertThat(ClientHelper.finished(client).size(), greaterThan(0)); assertThat(ClientHelper.running(client).size(), is(0)); assertThat(ClientHelper.queue(client).size(), is(0)); { String echoText = "PPAP"; Job job = new Job("echo-app", "mkdir -p a/b/c/d; echo " + echoText + " > a/b/c/e", new Properties(), 1, 32, 32); Job runRes = client.run(job); assertThat(runRes.result(), is(RES_OK)); assertThat(runRes.state(), is(Job.JobState.FINISHED)); Response response = client.getFile(runRes.id(), "a/b/c/e", 0, 1024); System.err.println(response.status()); GetFileResponse getFileResponse = (GetFileResponse) response; assertEquals(echoText + "\n", getFileResponse.file().get().data()); ListFilesResponse listFilesResponse = (ListFilesResponse) client.listFiles(runRes.id(), "a/b/c"); assertEquals(2, listFilesResponse.entries().size()); List<String> files = listFilesResponse.entries().stream().map(e -> FilenameUtils.getName(e.path())) .collect(Collectors.toList()); assertEquals("d", files.get(0)); assertEquals("e", files.get(1)); } UnloadAppResponse unloadRes = (UnloadAppResponse) client.unload("echo-app"); assertThat(unloadRes.status(), is("ok")); client.close(); }
From source file:com.epam.ngb.cli.TestHttpServer.java
public void addFeatureIndexedFileRegistration(Long refId, String path, String name, Long fileId, Long fileBioId, BiologicalDataItemFormat format, boolean doIndex, String prettyName) { onRequest().havingMethodEqualTo(HTTP_POST) .havingPathEqualTo(String.format(REGISTRATION_URL, format.name().toLowerCase())) .havingBodyEqualTo(TestDataProvider.getRegistrationJson(refId, path, name, doIndex, prettyName)) .respond().withBody(TestDataProvider.getFilePayloadJson(fileId, fileBioId, format, path, name == null ? FilenameUtils.getName(path) : name)) .withStatus(HTTP_STATUS_OK); }
From source file:io.dockstore.webservice.helpers.SourceCodeRepoInterface.java
/** * Default implementation that parses WDL content from a tool? * TODO: does this belong here?// w w w . ja va 2s. com * @param tool the source for the wdl content * @param content the actual wdl content * @return the tool that was given */ protected Tool parseWDLContent(Tool tool, String content) { // Use Broad WDL parser to grab data // Todo: Currently just checks validity of file. In the future pull data such as author from the WDL file try { String wdlSource = content; WdlParser parser = new WdlParser(); WdlParser.TokenStream tokens = new WdlParser.TokenStream( parser.lex(wdlSource, FilenameUtils.getName(tool.getDefaultWdlPath()))); WdlParser.Ast ast = (WdlParser.Ast) parser.parse(tokens).toAst(); if (ast == null) { LOG.info("Error with WDL file."); } else { tool.setValidTrigger(true); LOG.info("Repository has Dockstore.wdl"); } } catch (WdlParser.SyntaxError syntaxError) { LOG.info("Invalid WDL file."); } return tool; }
From source file:com.vmihalachi.turboeditor.fragment.EditorFragment.java
/** * {@inheritDoc}/* ww w. ja va 2 s. c o m*/ */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); String fileName = FilenameUtils.getName(getArguments().getString("filePath")); getActivity().getActionBar().setTitle(fileName); try { final FileInputStream inputStream = new FileInputStream(new File(this.sFilePath)); mEditor.setText(IOUtils.toString(inputStream, this.mCurrentEncoding)); inputStream.close(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new ErrorOpeningFileEvent()); } }
From source file:edu.cornell.med.icb.goby.alignments.IterateSortedAlignmentsToPileup.java
public void finish(RandomAccessSequenceCache randomAccessGenome, AlignmentToPileupMode.OutputFormat outputFormat) { // write reference if we have a genome: if (randomAccessGenome != null) { Sequence seq = new Sequence(); MutableString clippedBases = new MutableString(); for (int position = startPosition - maxVariationLength; position <= endPosition + 50; position++) { // do not assume target indices match between alignment and the reference genome, convert to string: final String targetId = getReferenceId(startReferenceIndex).toString(); clippedBases.append(randomAccessGenome.get(targetId, position)); }// w w w.j a v a 2 s .co m seq.basename = "reference (" + randomAccessGenome.getBasename() + ")"; writeSequence(outputFormat, seq, seq.basename, clippedBases); } // write alignment to output, reads are grouped by basename. for (String basename : basenameIds) { int i = 0; for (Sequence seq : sequenceBuffers) { if (seq.basename.equals(basename)) { final MutableString bases = sequenceBuffers.get(i).bases; if (bases.length() > startFlapStart) { // we remove the bases from 0 to the end of the flap, just before the longest // variation we have seen in this window. This will always include the variation of // interest in the printed window, and will make sure we show all the bases of the // variations that overlap this window. final String shortBasename = FilenameUtils .getName(AlignmentReaderImpl.getBasename(seq.basename)); final MutableString clippedBases = bases .substring(Math.max(0, startFlapStart - maxVariationLength)); writeSequence(outputFormat, seq, shortBasename, clippedBases); } } i++; } } }
From source file:com.xse.optstack.persconftool.ui.defaultdata.BaseDefaultPart.java
@PostConstruct public void postConstruct(final Composite parent) { parent.setLayout(new GridLayout(1, false)); parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); this.stackComposite = new Composite(parent, SWT.NONE); final GridData keyValueGridData = new GridData(SWT.FILL, SWT.FILL, true, true); this.stackComposite.setLayoutData(keyValueGridData); this.layout = new StackLayout(); this.stackComposite.setLayout(this.layout); this.keyValueComposite = LayoutHelper.createDefaultGridComposite(this.stackComposite, SWT.NONE, 1, false, SWT.FILL, SWT.FILL, true, true); this.sizeText = new CaptionText(this.keyValueComposite, SWT.NONE, "Size", 35, 0); this.sizeText.setLayoutData(BaseDefaultPart.createControlGridData()); this.sizeText.setValidator(new IntegerValidator(true, "Value needs to be a valid integer number!")); this.dataText = new CaptionText(this.keyValueComposite, SWT.NONE, "Data", 30, 0); this.dataText.setLayoutData(BaseDefaultPart.createControlGridData()); this.pathComposite = LayoutHelper.createDefaultGridComposite(this.stackComposite, SWT.NONE, 1, false, SWT.FILL, SWT.FILL, true, true); this.pathSelectionControl = new PathSelectionControl(this.pathComposite, SWT.NONE, "Local", "", 24, SWT.NONE);//from ww w . j a v a2 s .c o m this.pathSelectionControl.setLayoutData(BaseDefaultPart.createControlGridData()); this.fileNameText = new CaptionText(this.pathComposite, SWT.NONE, "File", 36, 0); this.fileNameText.setLayoutData(BaseDefaultPart.createControlGridData()); this.pathSelectionControl.addPathChangedListener(new IPathChangedListener() { @Override public void pathChanged(final String oldPath, final String newPath) { if ((BaseDefaultPart.this.activeResource.getConfiguration().getType() == EDefaultDataType.FILE) && !StringUtils.isEmpty(newPath)) { BaseDefaultPart.this.fileNameText.setText(FilenameUtils.getName(newPath)); } } }); this.setEnabledState(false); }
From source file:com.impetus.ankush2.agent.AgentNodeUpgrader.java
/** * Method to Upgrade Agent on node.//from ww w. j av a 2s .co m */ public void upgradeAgent() { String host = nodeConfig.getHost(); LOGGER.setCluster(clusterConfig); LOGGER.info(MESSAGE_UPGRADING_AGENT + ": " + nodeConfig.getHost(), Constant.Component.Name.AGENT, host); // connection SSHExec connection = null; boolean isRollbackRequired = false; try { // getting installed Agent version String installedAgentVersion = node.getAgentVersion(); if (agentBuildVersion.equals(installedAgentVersion)) { return; } // connecting to node. connection = SSHUtils.connectToNode(host, clusterConfig.getAuthConf()); if (connection == null) { throw new AnkushException("Could not connect to node: " + host); } // stopping Agent and taking Agent's backup stoppingAgentWithBackup(host, connection); System.out.println("Stopping Agent and taking Agent's backup done "); LOGGER.info("Stopping Agent and taking Agent's backup done", Constant.Component.Name.AGENT, host); // creating upgrade script directory LOGGER.info("Creating Agent upgrade directory.", Constant.Component.Name.AGENT, host); String upgradeScriptDirectory = AgentUpgrader.NODE_ANKUSH_HOME + "upgrade/"; // creating Agent upgrade directory createUpgradeDirectory(connection, upgradeScriptDirectory); // upload Agent upgrade script // setting isRollbackRequired to true to do rollback in // AnkushException catch clause after backup is done. isRollbackRequired = true; // Uploading the agent jar to node LOGGER.info("Copying Agent bundle...", Constant.Component.Name.AGENT, host); uploadBundle(connection, AppStoreWrapper.getResourcePath() + RESOURCE_BUNDLE_PATH, NODE_ANKUSH_HOME); // extracting new Agent extractNewAgent(connection); // uploading upgrade.sh to node String updateScriptPath = AppStoreWrapper.getResourcePath() + UPGRADE_SCRIPT_PATH; // node update script path. String nodeUpdateScriptPath = upgradeScriptDirectory + FilenameUtils.getName(updateScriptPath); uploadBundle(connection, updateScriptPath, nodeUpdateScriptPath); // running agent ugrade script if (!executeUpgradeScript(connection, upgradeScriptDirectory)) { throw new AnkushException("Please run the upgrade scripts available under " + CommonUtil.getUserHome(clusterConfig.getAuthConf().getUsername()) + ".ankush/upgrade/ directory to upgrade the agent manually and restart Agent."); } // TODO: Component wise upgrade changes // Removing upgrade and backup directory after successful upgrade removeUpgradeAndBackupDir(connection, upgradeScriptDirectory); // starting Agent startAgent(connection); node.setAgentVersion(agentBuildVersion); nodeConfig.setStatus(true); } catch (AnkushException e) { LOGGER.error(e.getMessage(), Constant.Component.Name.AGENT, host, e); nodeConfig.setStatus(false); if (isRollbackRequired) { rollBack(connection); } } finally { // disconnecting node if (connection != null) { connection.disconnect(); } } // saving node with status true/false in nodeConfig object node.setNodeConfig(nodeConfig); nodeManager.save(node); }
From source file:com.ephesoft.gxt.admin.server.ImportDocumentTypeUploadServlet.java
/** * This API is used to get zip file name. * //from w ww . ja va 2 s . c om * @param item {@link FileItem} uploaded file item. * @return {@link String} zip file name. */ private String getZipFileName(final FileItem item) { String zipFileName = item.getName(); if (zipFileName != null) { zipFileName = zipFileName.substring(zipFileName.lastIndexOf(File.separator) + 1); zipFileName = FilenameUtils.getName(zipFileName); } return zipFileName; }