List of usage examples for java.lang String concat
public String concat(String str)
From source file:org.alfresco.mobile.android.api.services.impl.AbstractDocumentFolderServiceImpl.java
private static String addAspects(String objectId, List<String> nodeAspects, List<String> aspectToApplied) { String objectIdWithAspects = objectId; Set<String> aspects = new HashSet<String>(nodeAspects); if (aspectToApplied != null) { aspects.addAll(aspectToApplied); }// w w w . ja va2s . co m for (String aspect : aspects) { if (!objectIdWithAspects.contains(aspect)) { objectIdWithAspects = objectIdWithAspects.concat("," + CMISPREFIX_ASPECTS + aspect); } } return objectIdWithAspects; }
From source file:mobi.nordpos.catalog.action.ProductCreateActionBean.java
@ValidationMethod(priority = 1) public void validateProductReferency(ValidationErrors errors) { try {//from w w w . j a va 2 s . co m String plu = getPLU(getProduct().getProductCategory().getCode()); String code = getShortCode(); getProduct().setReference(plu.concat("-").concat(code)); } catch (SQLException ex) { getContext().getValidationErrors().addGlobalError(new SimpleError(ex.getMessage())); } }
From source file:com.afis.jx.ckfinder.connector.utils.FileUtils.java
/** * rename file with double extension.//from w ww . j a v a2 s . com * * @param type a {@code ResourceType} object holding list of allowed and denied extensions against which file extension will be tested. * @param fileName file name * @return new file name with . replaced with _ (but not last) */ public static String renameFileWithBadExt(final ResourceType type, final String fileName) { if (type == null || fileName == null) { return null; } if (fileName.indexOf('.') == -1) { return fileName; } StringTokenizer tokens = new StringTokenizer(fileName, "."); String cfileName = tokens.nextToken(); String currToken; while (tokens.hasMoreTokens()) { currToken = tokens.nextToken(); if (tokens.hasMoreElements()) { cfileName = cfileName.concat(checkSingleExtension(currToken, type) ? "." : "_"); cfileName = cfileName.concat(currToken); } else { cfileName = cfileName.concat(".".concat(currToken)); } } return cfileName; }
From source file:latexstudio.editor.remote.UploadToDropbox.java
@Override public void actionPerformed(ActionEvent e) { DbxClient client = DbxUtil.getDbxClient(); if (client == null) { return;//from www . j a v a 2s. c om } String sourceFileName = ApplicationUtils.getTempSourceFile(); File file = new File(sourceFileName); FileInputStream inputStream = null; try { inputStream = new FileInputStream(file); } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } String defaultFileName = etc.getCurrentFile() == null ? "welcome.tex" : etc.getCurrentFile().getName(); String fileName = (String) JOptionPane.showInputDialog(null, "Please enter file name", "Upload file", JOptionPane.INFORMATION_MESSAGE, null, null, defaultFileName); if (fileName != null) { fileName = fileName.endsWith(TEX_EXTENSION) ? fileName : fileName.concat(TEX_EXTENSION); try { DbxEntry.File uploadedFile = client.uploadFile("/OpenLaTeXStudio/" + fileName, DbxWriteMode.add(), file.length(), inputStream); JOptionPane.showMessageDialog(null, "Successfuly uploaded file " + uploadedFile.name + " (" + uploadedFile.humanSize + ")", "File uploaded to Dropbox", JOptionPane.INFORMATION_MESSAGE); revtc.close(); } catch (DbxException ex) { DbxUtil.showDbxAccessDeniedPrompt(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } finally { IOUtils.closeQuietly(inputStream); } } }
From source file:ua.pp.msk.gradle.http.Client.java
public Client(String url, String user, String password) throws ClientSslException, MalformedURLException { if (!url.contains("/nexus/service/local/artifact/maven/content")) { url = url.concat("/nexus/service/local/artifact/maven/content"); }/* w w w . j a v a 2 s .c om*/ URL targetURL = new URL(url); init(targetURL, user, password); }
From source file:no.dusken.barweb.admin.PluginStoreController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); if (isFormSubmission(request)) { // A map containing messages in the form pluginUid.setting -> value for each setting that is changed. Map<String, String> updateMsgMap = new HashMap<String, String>(); //Check if settings has changed and store the ones that has. for (BarwebPlugin plugin : pluginManager.getPlugins()) { PluginStore store = pluginStoreProvider.getStore(plugin); Set<String> settings = store.getStrings(); for (String setting : settings) { String settingKey = plugin.getPluginUid().concat("-").concat(setting); String currentValue = ServletRequestUtils.getStringParameter(request, settingKey, null); String oldValue = store.getString(setting, null); if (currentValue != null && oldValue != null && !currentValue.equals(oldValue)) { store.setString(setting, currentValue); updateMsgMap.put(settingKey, oldValue.concat("->").concat(currentValue)); }//ww w. j a v a 2 s . c o m } } map.put("updatemap", updateMsgMap); } Map<BarwebPlugin, Map<String, String>> plugins = new HashMap<BarwebPlugin, Map<String, String>>(); for (BarwebPlugin plugin : pluginManager.getPlugins()) { PluginStore store = pluginStoreProvider.getStore(plugin); plugins.put(plugin, getKeyValueMap(store)); } map.put("plugins", plugins); map.put("locale", Locale.getDefault()); return new ModelAndView(view, map); }
From source file:org.openmrs.module.atomfeed.AtomFeedUtil.java
/** * This method writes the atom feed data to the given stream. <br/> * The given stream is not closed//from w w w . j a v a 2 s . c om * * @param stream an open outputstream that will be written to * @param asOfDate if not null, limits the entries to only ones updated after this date * @should download full stream with null date * @should download partial stream by given date * @should stream multiline entry */ public static void getAtomFeedStream(OutputStream stream, Date asOfDate) { OutputStream out = new BufferedOutputStream(stream); File atomheaderfile = getFeedHeaderFile(); if (atomheaderfile.exists()) { try { // stream the atom header to output String atomHeader = FileUtils.readFileToString(atomheaderfile); // truncate "</feed>" from the atom header string if (StringUtils.isNotBlank(atomHeader)) { atomHeader = StringUtils.substringBeforeLast(atomHeader, "</feed>"); } // write part of the header to the stream out.write(atomHeader.getBytes()); // then stream the entries to the output File atomfile = getFeedEntriesFile(); // if the date filtering parameter is passed in // we need to limit the entries to only ones, which were // updated after this date if (asOfDate != null) { String entry; BufferedReader br = new BufferedReader(new FileReader(atomfile)); while ((entry = br.readLine()) != null) { // if current entry has a new line then handle it gracefully while (!StringUtils.endsWith(entry, "</entry>")) { String newLine = br.readLine(); // if end of file is reached and new line does not contain new entry if (newLine != null && !StringUtils.contains(newLine, "<entry>")) { entry = entry.concat("\n").concat(newLine); } else { // otherwise an invalid entry is found, terminate processing throw new Exception("Invalid atom feed entry. No end tag </entry> found."); } } Date updated = new SimpleDateFormat(RFC_3339_DATE_FORMAT) .parse(StringUtils.substringBetween(entry, "<updated>", "</updated>")); if (updated.compareTo(asOfDate) > -1) { // write entry to the stream entry = entry.concat("\n"); out.write(entry.getBytes()); } else { // if entry with updatedDate lower that given one is reached // we need to stop filtering break; } } } else { // bulk write all entries to the stream out.write(FileUtils.readFileToByteArray(atomfile)); } // write the "</feed>" element that isn't in the entries file (and was // in the header file) out.write("</feed>".getBytes()); out.flush(); } catch (Exception e) { log.error("Unable to stream atom header file and/or entries file, because of error: ", e); } } }
From source file:com.addthis.hydra.task.output.HDFSOutputWrapperFactory.java
private String getModifiedTarget(String target, OutputStreamFlags outputFlags) throws IOException { PartitionData partitionData = getPartitionData(target); String modifiedFileName; int i = 0;//from ww w . j a v a 2s .c om while (true) { modifiedFileName = getFileName(target, partitionData, outputFlags, i++); Path test = new Path(dir, modifiedFileName); Path testTmp = new Path(dir, modifiedFileName.concat(".tmp")); boolean testExists = fileSystem.exists(test); if ((outputFlags.getMaxFileSize() > 0) && ((testExists && (fileLength(test) >= outputFlags.getMaxFileSize())) || (fileSystem.exists(testTmp) && (fileLength(testTmp) >= outputFlags.getMaxFileSize())))) { // to big already continue; } if (!outputFlags.isNoAppend() || !testExists) { break; } } return modifiedFileName; }
From source file:com.jpmorgan.cakeshop.bean.QuorumConfigBean.java
public void createQuorumConfig(String keyName, final String destination) throws IOException { File confFile = new File(destination.concat(keyName.concat(".conf"))); if (!confFile.exists()) { keyName = destination.concat(keyName); try (FileWriter writer = new FileWriter(confFile)) { writer.write("url = \"http://127.0.0.1:9000/\""); writer.write("\n"); writer.write("port = 9000"); writer.write("\n"); writer.write("socketPath = \"" + keyName + ".ipc\""); writer.write("\n"); writer.write("otherNodeUrls = []"); writer.write("\n"); writer.write("publicKeyPath = \"" + keyName + ".pub\""); writer.write("\n"); writer.write("privateKeyPath = \"" + keyName + ".key\""); writer.write("\n"); writer.write("archivalPublicKeyPath = \"" + keyName + "a" + ".pub\""); writer.write("\n"); writer.write("archivalPrivateKeyPath = \"" + keyName + "a" + ".key\""); writer.write("\n"); writer.write("storagePath = \"" + destination + "constellation\""); writer.flush();/*from ww w . j a v a 2 s.co m*/ } } }