List of usage examples for org.apache.commons.lang StringUtils lowerCase
public static String lowerCase(String str)
Converts a String to lower case as per String#toLowerCase() .
From source file:org.intermine.web.logic.config.WebConfig.java
/** * Format strings in a SO format to be more human readable. For example, * transcription_factor becomes "Transcription Factor", and "U11_snRNA" becomes * "U11 snRNA"./*ww w .j av a 2 s .c o m*/ * @param input the string to format * @return A reformatted version of the string. */ private static String deSlashify(final String input) { final String[] parts = StringUtils.split(input, "_"); final String[] outputParts = new String[parts.length]; for (int i = 0; i < parts.length; i++) { final String part = parts[i]; if (part.equals(StringUtils.lowerCase(part))) { outputParts[i] = StringUtils.capitalize(part); } else { outputParts[i] = part; } } return StringUtils.join(outputParts, " "); }
From source file:org.intermine.webservice.server.query.CodeService.java
private WebserviceCodeGenerator getCodeGenerator(String lang) { lang = StringUtils.lowerCase(lang); if ("perl".equals(lang) || "pl".equals(lang)) { return new WebservicePerlCodeGenerator(); } else if ("java".equals(lang)) { return new WebserviceJavaCodeGenerator(); } else if ("python".equals(lang) || "py".equals(lang)) { return new WebservicePythonCodeGenerator(); } else if ("javascript".equals(lang) || "js".equals(lang)) { return new WebserviceJavaScriptCodeGenerator(); } else if ("ruby".equals(lang) || "rb".equals(lang)) { return new WebserviceRubyCodeGenerator(); } else {/*from w ww . j a v a2 s. co m*/ throw new BadRequestException("Unknown code generation language: " + lang); } }
From source file:org.intermine.webservice.server.WebService.java
/** * If user name and password is specified in request, then it setups user * profile in session. User was authenticated. It uses HTTP basic access * authentication./*w w w. j a va 2s .co m*/ * {@link "http://en.wikipedia.org/wiki/Basic_access_authentication"} */ private void authenticate() { String authToken = request.getParameter(AUTH_TOKEN_PARAM_KEY); final String authString = request.getHeader(AUTHENTICATION_FIELD_NAME); final ProfileManager pm = im.getProfileManager(); if (StringUtils.isEmpty(authToken) && StringUtils.isEmpty(authString)) { return; // Not Authenticated. } // Accept tokens passed in the Authorization header. if (StringUtils.isEmpty(authToken) && StringUtils.startsWith(authString, "Token ")) { authToken = StringUtils.removeStart(authString, "Token "); } try { // Use a token if provided. if (StringUtils.isNotEmpty(authToken)) { permission = pm.getPermission(authToken, im.getClassKeys()); } else { // Try and read the authString as a basic auth header. // Strip off the "Basic" part - but don't require it. final String encoded = StringUtils.removeStart(authString, "Basic "); final String decoded = new String(Base64.decodeBase64(encoded.getBytes())); final String[] parts = decoded.split(":", 2); if (parts.length != 2) { throw new UnauthorizedException( "Invalid request authentication. " + "Authorization field contains invalid value. " + "Decoded authorization value: " + parts[0]); } final String username = StringUtils.lowerCase(parts[0]); final String password = parts[1]; permission = pm.getPermission(username, password, im.getClassKeys()); } } catch (AuthenticationException e) { throw new UnauthorizedException(e.getMessage()); } LoginHandler.setUpPermission(im, permission); }
From source file:org.itracker.web.taglib.FormatDateTag.java
private static String cleanupFormatPatternName(String f) { if (StringUtils.isEmpty(f)) { f = "full"; } else if (StringUtils.equalsIgnoreCase("notime", f)) { f = "dateonly"; } else if (StringUtils.equalsIgnoreCase(f, "short") || StringUtils.equalsIgnoreCase(f, "dateonly") || StringUtils.equalsIgnoreCase(f, "full")) { f = StringUtils.lowerCase(f); }//from w ww.j av a2 s. c o m return f; }
From source file:org.jahia.modules.modulemanager.flow.ModuleManagementFlowHandler.java
public boolean uploadModule(MultipartFile moduleFile, MessageContext context, boolean forceUpdate, boolean autoStart) { if (moduleFile == null) { context.addMessage(new MessageBuilder().error().source("moduleFile") .code("serverSettings.manageModules.install.moduleFileRequired").build()); return false; }// w w w. j av a 2s . c o m String originalFilename = moduleFile.getOriginalFilename(); if (!FilenameUtils.isExtension(StringUtils.lowerCase(originalFilename), "jar")) { context.addMessage(new MessageBuilder().error().source("moduleFile") .code("serverSettings.manageModules.install.wrongFormat").build()); return false; } File file = null; try { file = File.createTempFile("module-", "." + StringUtils.substringAfterLast(originalFilename, ".")); moduleFile.transferTo(file); installBundles(file, context, originalFilename, forceUpdate, autoStart); return true; } catch (Exception e) { context.addMessage(new MessageBuilder().source("moduleFile") .code("serverSettings.manageModules.install.failed").arg(e.getMessage()).error().build()); logger.error(e.getMessage(), e); } finally { FileUtils.deleteQuietly(file); } return false; }
From source file:org.jahia.services.sites.JahiaSitesService.java
public JCRSiteNode getSiteByServerName(String serverName, JCRSessionWrapper session) throws RepositoryException { Query q = session.getWorkspace().getQueryManager() .createQuery("select * from [jnt:virtualsite] as s where lower(s.[j:serverName])='" + JCRContentUtils.sqlEncode(StringUtils.lowerCase(serverName)) + "' and ischildnode(s, '/sites/')", Query.JCR_SQL2); NodeIterator ni = q.execute().getNodes(); if (ni.hasNext()) { return (JCRSiteNode) ni.next(); }/*w w w . j av a2 s . c o m*/ return null; }
From source file:org.jahia.utils.maven.plugin.contentgenerator.OutputService.java
/** * Remove spaces and lower-cases the string * @param s/*from w ww. j a v a 2 s . co m*/ * @return String */ public String formatStringForXml(String s) { String s2 = StringUtils.replace(s, " ", ""); StringUtils.lowerCase(s2); return s2; }
From source file:org.jahia.utils.maven.plugin.contentgenerator.wise.bo.DocspaceBO.java
public Element getElement() { if (docspaceElement == null) { docspaceElement = new Element(StringUtils.lowerCase(docspaceName)); docspaceElement.setAttribute("fromEmail", fromEmail); docspaceElement.setAttribute("mixinTypes", "docmix:docspace jmix:accessControlled", ContentGeneratorCst.NS_JCR); docspaceElement.setAttribute("primaryType", "jnt:folder", ContentGeneratorCst.NS_JCR); Element translationEn = new Element("translation_en", ContentGeneratorCst.NS_J); translationEn.setAttribute("primaryType", "jnt:translation", ContentGeneratorCst.NS_JCR); translationEn.setAttribute("description", "Created by the Jahia Content Generator", ContentGeneratorCst.NS_JCR); translationEn.setAttribute("title", docspaceName, ContentGeneratorCst.NS_JCR); translationEn.setAttribute("language", "en", ContentGeneratorCst.NS_JCR); docspaceElement.addContent(translationEn); docspaceElement.addContent(generateDocspaceAcl()); if (CollectionUtils.isNotEmpty(polls)) { Element pollsElement = new Element("polls"); pollsElement.setAttribute("primaryType", "docnt:pollsContainer", ContentGeneratorCst.NS_JCR); for (Iterator<PollBO> iterator = polls.iterator(); iterator.hasNext();) { PollBO poll = iterator.next(); pollsElement.addContent(poll.getElement()); }//w ww . java 2 s . c om docspaceElement.addContent(pollsElement); } if (CollectionUtils.isNotEmpty(notes)) { Element notesElement = new Element("notes"); notesElement.setAttribute("primaryType", "docnt:notesContainer", ContentGeneratorCst.NS_JCR); for (Iterator<NoteBO> iterator = notes.iterator(); iterator.hasNext();) { NoteBO note = iterator.next(); notesElement.addContent(note.getElement()); } docspaceElement.addContent(notesElement); } if (CollectionUtils.isNotEmpty(tasks)) { Element tasksElement = new Element("tasks"); tasksElement.setAttribute("primaryType", "jnt:tasks", ContentGeneratorCst.NS_JCR); for (Iterator<TaskBO> iterator = tasks.iterator(); iterator.hasNext();) { TaskBO task = iterator.next(); tasksElement.addContent(task.getElement()); } docspaceElement.addContent(tasksElement); } if (CollectionUtils.isNotEmpty(folders)) { for (Iterator<FolderBO> iterator = folders.iterator(); iterator.hasNext();) { FolderBO folder = iterator.next(); docspaceElement.addContent(folder.getElement()); } } } return docspaceElement; }
From source file:org.jahia.utils.maven.plugin.contentgenerator.wise.FileAndFolderService.java
public void generateFolders(String docspaceName, ExportBO wiseExport) { docspaceName = StringUtils.lowerCase(docspaceName); // (N^L-1) / (N-1) * N double nbNodes = wiseExport.getNbFoldersPerLevel().doubleValue(); double depth = wiseExport.getFoldersDepth().doubleValue(); Double totalFolders = Math.pow(nbNodes, depth) - 1; totalFolders = totalFolders / (nbNodes - 1); totalFolders = totalFolders * nbNodes; Double totalFiles = totalFolders * wiseExport.getNbFilesPerFolder(); logger.info("Folders generation is starting, " + totalFolders.intValue() + " folders to create, containing a total of " + totalFiles.intValue() + " files."); String currentPath = initializeContentFolder(wiseExport.getOutputDir() + sep + "wise", wiseExport.getSiteKey(), docspaceName); String currentNodePath = "/" + "sites" + "/" + wiseExport.getSiteKey() + "/" + "files" + "/" + "docspaces" + "/" + docspaceName; // if there is not enough physical files available // we'll take them all and stop Integer nbFilesAvailable = wiseExport.getFileNames().size(); if (wiseExport.getNbFilesPerFolder().compareTo(nbFilesAvailable) > 0) { logger.warn(/*from ww w.j ava2 s. c o m*/ "You asked for " + wiseExport.getNbFilesPerFolder() + " files per folder, but there are only " + nbFilesAvailable + " files in the pool, and we can't use them twice."); wiseExport.setNbFilesPerFolder(nbFilesAvailable); } // create temporary folders to serialize files and folders objects created File tmpTopFoldersDir = new File(ExportBO.tmp + sep + ContentGeneratorCst.TMP_DIR_TOP_FOLDERS); tmpTopFoldersDir.mkdir(); File tmpFilesDir = new File(ExportBO.tmp + sep + ContentGeneratorCst.TMP_DIR_WISE_FILES); tmpFilesDir.mkdir(); // initialize date range difference for random creation date startTimestamp = wiseExport.getStartCreationDateRange().getTime(); long endTimestamp = wiseExport.getEndCreationDateRange().getTime(); timestampDifference = endTimestamp - startTimestamp; generateFolders(1, currentPath, currentNodePath, wiseExport); }
From source file:org.jamwiki.parser.jflex.ParserFunctionUtil.java
/** * Parse the {{lc:}} parser function.//w w w . ja v a 2 s. co m */ private static String parseLowerCase(ParserInput parserInput, String[] parserFunctionArgumentArray) { return StringUtils.lowerCase(parserFunctionArgumentArray[0]); }