List of usage examples for org.apache.commons.lang StringUtils substring
public static String substring(String str, int start, int end)
Gets a substring from the specified String avoiding exceptions.
From source file:org.hyperic.hq.livedata.formatters.TopFormatter.java
public static String formatHtml(TopReport t, TOPN_SORT_TYPE sortType, int numberOfProcessesToShow) { StringBuilder buf = new StringBuilder(); buf.append("<div id='topn_result_cont'>\n"); buf.append("<div id='result' style='border: 1px solid #7BAFFF;'>") .append("<div class='fivepad' style='background:#efefef;'>").append("<b>Time</b>: ") .append(h(t.getUpTime())).append("<br/>"); buf.append("<b>CPU States</b>: ").append(h(t.getCpu().split(":")[1]).replace("{", "").replace("}", "")) .append("<br/>"); buf.append("<b>Mem</b>: ").append(h(t.getMem().split(":")[1]).replace("{", "").replace("}", "")) .append("<br/>"); buf.append("<b>Swap</b>: ").append(h(t.getSwap().split(":")[1]).replace("{", "").replace("}", "")) .append("<br/>"); buf.append("<b>Processes</b>: ").append(h(t.getProcStat().replace("{", "").replace("}", ""))) .append("<br/><br/>"); buf.append(//w ww. j a v a 2 s . c o m "</div>\n<table style='table-layout:auto' cellpadding='0' cellspacing='0' width='100%'><thead><tr><td>") .append(BUNDLE.format("formatter.top.proc.name")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.pid")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.user")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.stime")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.size")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.rss")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.cpu")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.mem")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.disk.total")).append("</td><td>") .append(BUNDLE.format("formatter.top.proc.args")).append("</td></tr></thead><tbody>"); int i = 0; for (ProcessReport pr : t.getProcessesSorted(sortType)) { if (i++ >= numberOfProcessesToShow) { break; } char[] st = new char[1]; st[0] = pr.getState(); String str = new String(buf); char stateStr = ((str.trim().length() == 0) ? '-' : pr.getState()); String cmd = h(pr.getBaseName()); StringBuilder argsBuilder = new StringBuilder(); for (String arg : pr.getArgs()) { argsBuilder.append(arg).append(","); } //remove the last comma if (argsBuilder.length() > 0) { argsBuilder.setLength(argsBuilder.length() - 1); } String args = h(argsBuilder.toString()); buf.append("<tr>").append("<td title='").append(cmd).append("' style='word-wrap:break-word;' >") .append(StringUtils.substring(cmd, 0, 25)).append("</td>").append("<td>").append(pr.getPid()) .append("</td>").append("<td>").append(pr.getOwner()).append("</td>").append("<td>") .append(pr.getStartTime()).append("</td>").append("<td>").append(pr.getSize()).append("</td>") .append("<td>").append(pr.getResident()).append("</td>").append("<td>").append(pr.getCpuPerc()) .append("</td>").append("<td>").append(pr.getMemPerc()).append("</td>").append("<td>") .append(pr.getFormatedTotalDiskBytes()).append("</td>").append("<td title='").append(args) .append("' style='word-wrap:break-word;' >").append(StringUtils.substring(args, 0, 60)) .append("</td></tr>"); } buf.append("</tbody></table></div></div>"); return buf.toString(); }
From source file:org.intermine.bio.dataconversion.zfin_markersConverter.java
private void processLinkData(Reader reader) throws Exception { Iterator lineIter = FormattedTextParser.parseDelimitedReader(reader, '|'); while (lineIter.hasNext()) { String[] line = (String[]) lineIter.next(); if (line.length < 3) { throw new RuntimeException("Line does not have enough elements: " + line.length + line[0]); }/*from w w w . j a v a 2 s. com*/ String linkPrimaryIdentifier = line[0]; String linkDb = line[1]; String accNum = line[2]; String dataPrimaryIdentifier = line[3]; String linkType = line[4]; if (!StringUtils.isEmpty(linkPrimaryIdentifier)) { Item externalLink = getLink(linkPrimaryIdentifier); if (!StringUtils.isEmpty(linkType)) { externalLink.setAttribute("linkType", linkType); } if (!StringUtils.isEmpty(linkDb)) { externalLink.setReference("externalDatabase", getLinkDb(linkDb)); } if (!StringUtils.isEmpty(accNum)) { externalLink.setAttribute("accessionNumber", accNum); if (StringUtils.substring(accNum, 0, 7).equals("OTTDART")) { Item transcript = getTscript(dataPrimaryIdentifier); transcript.setAttribute("VegaId", accNum); } if (StringUtils.substring(accNum, 0, 7).equals("ENSDART")) { Item transcript = getTscript(dataPrimaryIdentifier); transcript.setAttribute("secondaryIdentifier", accNum); } if (StringUtils.substring(accNum, 0, 7).equals("OTTDARG")) { Item gene = getGene(dataPrimaryIdentifier); gene.setAttribute("VegaId", accNum); } if (StringUtils.substring(accNum, 0, 7).equals("ENSDARG")) { Item gene = getGene(dataPrimaryIdentifier); gene.setAttribute("secondaryIdentifier", accNum); } } try { store(externalLink); } catch (ObjectStoreException e) { throw new SAXException(e); } if (!StringUtils.isEmpty(dataPrimaryIdentifier)) { Item referencedLinkItem2 = getTypedItem(dataPrimaryIdentifier); referencedLinkItem2.addToCollection("externalLinks", externalLink); if (linkDb.equals("UniProtKB")) { if (!StringUtils.isEmpty(accNum)) { Item protein = getProtein(accNum, dataPrimaryIdentifier); referencedLinkItem2.addToCollection("proteins", protein); } } } } } }
From source file:org.isatools.isatab.export.DataFilesDispatcher.java
/** * Remove those files that were copied into data file repositories, i.e.: directories built on the basis of * study accessions and their contents.//from w w w.java2 s. com */ @SuppressWarnings("static-access") public void undispatch(List<Study> studies) { final String placeOlder = DataSourceConfigFields.ACCESSION_PLACEHOLDER.getName(); StudyDAO studyDAO = DaoFactory.getInstance(dataLocationMgr.getEntityManager()).getStudyDAO(); try { if (studies == null || studies.size() == 0) { return; } for (Study study : studies) { String studyAccession = StringUtils.trimToNull(study.getAcc()); if (studyAccession == null) { log.error("Data file unloader, Cannot work with null accession"); continue; } for (String location : dataLocationMgr.getAllDataLocations()) { if (location == null) { continue; } // We need to remove what follows the study accession, cause the whole directory about the study must be // removed // int istrip = location.indexOf(placeOlder); String studyLoc = StringUtils.substring(location, 0, istrip + placeOlder.length()); studyLoc = dataLocationMgr.buildLocation(studyLoc, study); File targetDir = new File(studyLoc); if (targetDir.exists()) { log.trace("Deleting '" + studyLoc + "'..."); FileUtils.deleteDirectory(targetDir); log.trace("...done"); log.info("'" + studyLoc + "' deleted by the unloader"); } else { log.trace("Skipping the deletion of non-existent:" + studyLoc); } } } } catch (IOException ex) { throw new TabIOException( MessageFormat.format("ERROR while undeleting the submission files from file repositories: {0}", ex.getMessage(), ex)); } }
From source file:org.isatools.isatab.mapping.StudyWrapper.java
/** * TODO: move to the model?/*from w w w . j a v a 2 s.com*/ */ public static String getLabel(Study study) { String title = StringUtils.trimToEmpty(StringUtils.substring(study.getTitle(), 0, 15)); String acc = StringUtils.trimToEmpty(study.getAcc()); if (title.length() != 0) { if (acc.length() != 0) { return title + " (" + acc + ")"; } else { return title; } } else { return acc.length() != 0 ? acc : "?"; } }
From source file:org.jahia.ajax.gwt.helper.UIConfigHelper.java
/** * Get edit configuration// ww w . j a v a 2s . c o m * * @return * @throws GWTJahiaServiceException */ public GWTEditConfiguration getGWTEditConfiguration(String name, String contextPath, JahiaUser jahiaUser, Locale locale, Locale uiLocale, HttpServletRequest request, JCRSessionWrapper session) throws GWTJahiaServiceException { try { EditConfiguration config = (EditConfiguration) SpringContextSingleton.getBean(name); if (config != null) { GWTEditConfiguration gwtConfig = new GWTEditConfiguration(); gwtConfig.setName(config.getName()); String defaultLocation = config.getDefaultLocation(); if (defaultLocation.contains("$defaultSiteHome")) { JahiaSitesService siteService = JahiaSitesService.getInstance(); JahiaSite resolvedSite = !Url.isLocalhost(request.getServerName()) ? siteService.getSiteByServerName(request.getServerName(), session) : null; if (resolvedSite == null) { resolvedSite = JahiaSitesService.getInstance().getDefaultSite(session); if (resolvedSite != null && !((JCRSiteNode) resolvedSite).hasPermission(config.getRequiredPermission())) { resolvedSite = null; } if (resolvedSite == null) { List<JCRSiteNode> sites = JahiaSitesService.getInstance().getSitesNodeList(session); for (JCRSiteNode site : sites) { if (!"systemsite".equals(site.getName()) && (site.hasPermission(config.getRequiredPermission()))) { resolvedSite = site; break; } } } } if (resolvedSite != null) { JCRSiteNode siteNode = (JCRSiteNode) session .getNode(((JCRSiteNode) resolvedSite).getPath()); if (siteNode.getHome() != null) { defaultLocation = defaultLocation.replace("$defaultSiteHome", siteNode.getHome().getPath()); } else { defaultLocation = null; } } else { defaultLocation = null; } } else if (defaultLocation.contains("$user")) { defaultLocation = defaultLocation.replace("$user", jahiaUser.getLocalPath()); } gwtConfig.setDefaultLocation(defaultLocation); JCRNodeWrapper contextNode = null; JCRSiteNode site = null; if (contextPath == null) { int nodeNameIndex = StringUtils.indexOf(defaultLocation, ".", StringUtils.lastIndexOf(defaultLocation, "/")); contextPath = StringUtils.substring(defaultLocation, 0, nodeNameIndex); if (defaultLocation != null && session.nodeExists(contextPath)) { contextNode = session.getNode(contextPath); site = contextNode.getResolveSite(); } } else { if (session.nodeExists(contextPath)) { contextNode = session.getNode(contextPath); site = contextNode.getResolveSite(); } } if (config.getForcedSite() != null) { site = (JCRSiteNode) session.getNode(config.getForcedSite()); } if (site == null) { contextNode = session.getNode("/sites/systemsite"); site = contextNode.getResolveSite(); } // check locale final List<Locale> languagesAsLocales = site.getLanguagesAsLocales(); if (languagesAsLocales != null && !languagesAsLocales.contains(locale)) { final String defaultLanguage = site.getDefaultLanguage(); if (StringUtils.isNotEmpty(defaultLanguage)) { locale = LanguageCodeConverters.languageCodeToLocale(defaultLanguage); } } gwtConfig.setTopToolbar(createGWTToolbar(contextNode, site, jahiaUser, locale, uiLocale, request, config.getTopToolbar())); gwtConfig.setSidePanelToolbar(createGWTToolbar(contextNode, site, jahiaUser, locale, uiLocale, request, config.getSidePanelToolbar())); gwtConfig.setMainModuleToolbar(createGWTToolbar(contextNode, site, jahiaUser, locale, uiLocale, request, config.getMainModuleToolbar())); gwtConfig.setContextMenu(createGWTToolbar(contextNode, site, jahiaUser, locale, uiLocale, request, config.getContextMenu())); gwtConfig.setTabs(createGWTSidePanelTabList(contextNode, site, jahiaUser, locale, uiLocale, request, config.getTabs())); gwtConfig.setEngineConfigurations(createGWTEngineConfigurations(contextNode, site, jahiaUser, locale, uiLocale, request, config.getEngineConfigurations())); gwtConfig.setSitesLocation(config.getSitesLocation()); gwtConfig.setEnableDragAndDrop(config.isEnableDragAndDrop()); gwtConfig.setDefaultUrlMapping(config.getDefaultUrlMapping()); gwtConfig.setComponentsPaths(config.getComponentsPaths()); gwtConfig.setEditableTypes(config.getEditableTypes()); gwtConfig.setNonEditableTypes(config.getNonEditableTypes()); gwtConfig.setSkipMainModuleTypesDomParsing(config.getSkipMainModuleTypesDomParsing()); gwtConfig.setVisibleTypes(config.getVisibleTypes()); gwtConfig.setNonVisibleTypes(config.getNonVisibleTypes()); gwtConfig.setExcludedNodeTypes(config.getExcludedNodeTypes()); List<String> configsList = new ArrayList<String>(); // configsList will define the list of modes that share the same configuration to avoid reloading the main resource // when switching from edit to preview or live or any mode that has the same default location. // An exception has been added for system site that is used for dashboard or administration. for (EditConfiguration configuration : SpringContextSingleton.getInstance().getContext() .getBeansOfType(EditConfiguration.class).values()) { if (StringUtils.equals(configuration.getSitesLocation(), (config.getSitesLocation())) && !StringUtils.equals(config.getSitesLocation(), "/sites/systemsite")) { configsList.add(configuration.getName()); } } gwtConfig.setSamePathConfigsList(configsList); gwtConfig.setSiteNode(navigation.getGWTJahiaNode(site, GWTJahiaNode.DEFAULT_SITE_FIELDS, uiLocale)); if (config.isLoadSitesList()) { List<GWTJahiaNode> sites = navigation.retrieveRoot(Arrays.asList(config.getSitesLocation()), Arrays.asList("jnt:virtualsite"), null, null, GWTJahiaNode.DEFAULT_SITEMAP_FIELDS, null, null, site, session, uiLocale, false, false, null, null); String permission = ((EditConfiguration) SpringContextSingleton.getBean(name)) .getRequiredPermission(); Map<String, GWTJahiaNode> sitesMap = new HashMap<String, GWTJahiaNode>(); for (GWTJahiaNode aSite : sites) { if (session.getNodeByUUID(aSite.getUUID()).hasPermission(permission)) { sitesMap.put(aSite.getSiteUUID(), aSite); } } GWTJahiaNode systemSite = navigation.getGWTJahiaNode(session.getNode("/sites/systemsite"), GWTJahiaNode.DEFAULT_SITEMAP_FIELDS); if (!sitesMap.containsKey(systemSite.getUUID())) { sitesMap.put(systemSite.getUUID(), systemSite); } gwtConfig.setSitesMap(sitesMap); } gwtConfig.setPermissions(JahiaPrivilegeRegistry.getRegisteredPrivilegeNames()); gwtConfig.setChannels(channelHelper.getChannels()); gwtConfig.setUseFullPublicationInfoInMainAreaModules( config.isUseFullPublicationInfoInMainAreaModules()); gwtConfig.setSupportChannelsDisplay(config.isSupportChannelsDisplay()); return gwtConfig; } else { throw new GWTJahiaServiceException(Messages .getInternal("label.gwt.error.bean.editconfig.not.found.in.spring.config.file", uiLocale)); } } catch (RepositoryException e) { logger.error(e.getMessage(), e); throw new GWTJahiaServiceException(Messages.getInternalWithArguments("label.gwt.error.config.not.found", uiLocale, name, e.getLocalizedMessage())); } }
From source file:org.jahia.services.content.JCRSessionWrapper.java
private boolean checkCyclicReference(String path, String reference) { try {// www. j a v a 2 s . c om int lastIndexOfDeref = StringUtils.lastIndexOf(path, DEREF_SEPARATOR); while (lastIndexOfDeref != -1 || StringUtils.startsWith(path, reference + "/") || StringUtils.equals(path, reference)) { if (lastIndexOfDeref != -1) { path = StringUtils.substring(path, 0, lastIndexOfDeref); JCRNodeWrapper referencedNode = (JCRNodeWrapper) getNode(path).getProperty(Constants.NODE) .getNode(); if (StringUtils.equals(referencedNode.getPath(), reference)) { return true; } } else { return true; } lastIndexOfDeref = StringUtils.lastIndexOf(path, DEREF_SEPARATOR); } } catch (RepositoryException e) { logger.debug("unable to check cyclic reference between node {} and its reference {}", new String[] { path, reference }, e); // do nothing } return false; }
From source file:org.jahia.services.render.filter.StaticAssetsFilter.java
@Override public String execute(String previousOut, RenderContext renderContext, org.jahia.services.render.Resource resource, RenderChain chain) throws Exception { String out = previousOut;//from w w w . j a va 2 s . co m Source source = new Source(previousOut); Map<String, Map<String, Map<String, Map<String, String>>>> assetsByTarget = new LinkedHashMap<>(); List<Element> esiResourceElements = source.getAllElements("jahia:resource"); Set<String> keys = new HashSet<>(); for (Element esiResourceElement : esiResourceElements) { StartTag esiResourceStartTag = esiResourceElement.getStartTag(); Map<String, Map<String, Map<String, String>>> assets; String targetTag = esiResourceStartTag.getAttributeValue(TARGET_TAG); if (targetTag == null) { targetTag = "HEAD"; } else { targetTag = targetTag.toUpperCase(); } if (!assetsByTarget.containsKey(targetTag)) { assets = LazySortedMap.decorate(TransformedSortedMap.decorate( new TreeMap<String, Map<String, Map<String, String>>>(ASSET_COMPARATOR), LOW_CASE_TRANSFORMER, NOPTransformer.INSTANCE), new AssetsMapFactory()); assetsByTarget.put(targetTag, assets); } else { assets = assetsByTarget.get(targetTag); } String type = esiResourceStartTag.getAttributeValue("type"); String path = StringUtils.equals(type, "inline") ? StringUtils.substring(out, esiResourceStartTag.getEnd(), esiResourceElement.getEndTag().getBegin()) : URLDecoder.decode(esiResourceStartTag.getAttributeValue("path"), "UTF-8"); Boolean insert = Boolean.parseBoolean(esiResourceStartTag.getAttributeValue("insert")); String key = esiResourceStartTag.getAttributeValue("key"); // get options Map<String, String> optionsMap = getOptionMaps(esiResourceStartTag); Map<String, Map<String, String>> stringMap = assets.get(type); if (stringMap == null) { Map<String, Map<String, String>> assetMap = new LinkedHashMap<>(); stringMap = assets.put(type, assetMap); } if (insert) { Map<String, Map<String, String>> my = new LinkedHashMap<>(); my.put(path, optionsMap); my.putAll(stringMap); stringMap = my; } else { if ("".equals(key) || !keys.contains(key)) { Map<String, Map<String, String>> my = new LinkedHashMap<>(); my.put(path, optionsMap); stringMap.putAll(my); keys.add(key); } } assets.put(type, stringMap); } OutputDocument outputDocument = new OutputDocument(source); if (renderContext.isAjaxRequest()) { String templateContent = getAjaxResolvedTemplate(); if (templateContent != null) { for (Map.Entry<String, Map<String, Map<String, Map<String, String>>>> entry : assetsByTarget .entrySet()) { renderContext.getRequest().setAttribute(STATIC_ASSETS, entry.getValue()); Element element = source.getFirstElement(TARGET_TAG); final EndTag tag = element != null ? element.getEndTag() : null; ScriptEngine scriptEngine = scriptEngineUtils.scriptEngine(ajaxTemplateExtension); ScriptContext scriptContext = new AssetsScriptContext(); final Bindings bindings = scriptEngine.createBindings(); bindings.put(TARGET_TAG, entry.getKey()); bindings.put("renderContext", renderContext); bindings.put("resource", resource); scriptContext.setBindings(bindings, ScriptContext.GLOBAL_SCOPE); // The following binding is necessary for Javascript, which doesn't offer a console by default. bindings.put("out", new PrintWriter(scriptContext.getWriter())); scriptEngine.eval(templateContent, scriptContext); StringWriter writer = (StringWriter) scriptContext.getWriter(); final String staticsAsset = writer.toString(); if (StringUtils.isNotBlank(staticsAsset)) { if (tag != null) { outputDocument.replace(tag.getBegin(), tag.getBegin() + 1, "\n" + staticsAsset + "\n<"); out = outputDocument.toString(); } else { out = staticsAsset + "\n" + previousOut; } } } } } else if (resource.getContextConfiguration().equals("page")) { if (renderContext.isEditMode()) { if (renderContext.getServletPath().endsWith("frame")) { boolean doParse = true; if (renderContext.getEditModeConfig().getSkipMainModuleTypesDomParsing() != null) { for (String nt : renderContext.getEditModeConfig().getSkipMainModuleTypesDomParsing()) { doParse = !resource.getNode().isNodeType(nt); if (!doParse) { break; } } } List<Element> bodyElementList = source.getAllElements(HTMLElementName.BODY); if (bodyElementList.size() > 0) { Element bodyElement = bodyElementList.get(bodyElementList.size() - 1); EndTag bodyEndTag = bodyElement.getEndTag(); outputDocument.replace(bodyEndTag.getBegin(), bodyEndTag.getBegin() + 1, "</div><"); bodyElement = bodyElementList.get(0); StartTag bodyStartTag = bodyElement.getStartTag(); outputDocument.replace(bodyStartTag.getEnd(), bodyStartTag.getEnd(), "\n" + "<div jahiatype=\"mainmodule\"" + " path=\"" + resource.getNode().getPath() + "\" locale=\"" + resource.getLocale() + "\"" + " template=\"" + (resource.getTemplate() != null && !resource.getTemplate().equals("default") ? resource.getTemplate() : "") + "\"" + " nodetypes=\"" + ConstraintsHelper.getConstraints(renderContext.getMainResource().getNode()) + "\"" + ">"); if (doParse) { outputDocument.replace(bodyStartTag.getEnd() - 1, bodyStartTag.getEnd(), " jahia-parse-html=\"true\">"); } } } } if (!assetsByTarget.containsKey("HEAD")) { addResources(renderContext, resource, source, outputDocument, "HEAD", new HashMap<String, Map<String, Map<String, String>>>()); } for (Map.Entry<String, Map<String, Map<String, Map<String, String>>>> entry : assetsByTarget .entrySet()) { String targetTag = entry.getKey(); Map<String, Map<String, Map<String, String>>> assets = entry.getValue(); addResources(renderContext, resource, source, outputDocument, targetTag, assets); } out = outputDocument.toString(); } // Clean all jahia:resource tags source = new Source(out); outputDocument = new OutputDocument(source); for (Element el : source.getAllElements("jahia:resource")) { outputDocument.replace(el, ""); } String s = outputDocument.toString(); s = removeTempTags(s); return s.trim(); }
From source file:org.jahia.services.render.URLResolver.java
/** * Initializes an instance of this class. This constructor is mainly used when * resolving URLs of incoming requests./* w ww.java2 s. c o m*/ * * @param pathInfo the path info (usually obtained with @link javax.servlet.http.HttpServletRequest.getPathInfo()) * @param serverName the server name (usually obtained with @link javax.servlet.http.HttpServletRequest.getServerName()) * @param request the current HTTP servlet request object */ protected URLResolver(String pathInfo, String serverName, String workspace, HttpServletRequest request, Ehcache nodePathCache, Ehcache siteInfoCache) { super(); this.nodePathCache = nodePathCache; this.siteInfoCache = siteInfoCache; this.workspace = workspace; this.urlPathInfo = normalizeUrlPathInfo(pathInfo); if (!JahiaUserManagerService.isGuest(JCRSessionFactory.getInstance().getCurrentUser())) { Date date = getVersionDate(request); String versionLabel = getVersionLabel(request); setVersionDate(date); setVersionLabel(versionLabel); } if (urlPathInfo != null) { servletPart = StringUtils.substring(getUrlPathInfo(), 1, StringUtils.indexOf(getUrlPathInfo(), "/", 1)); path = StringUtils.substring(getUrlPathInfo(), servletPart.length() + 2, getUrlPathInfo().length()); } if (!resolveUrlMapping(serverName, request)) { init(); if (!Url.isLocalhost(serverName) && isMappable() && SettingsBean.getInstance().isPermanentMoveForVanityURL()) { try { if (siteKeyByServerName != null && siteKeyByServerName.equals(getNode().getResolveSite().getSiteKey())) { VanityUrl defaultVanityUrl = getVanityUrlService() .getVanityUrlForWorkspaceAndLocale(getNode(), this.workspace, locale, siteKey); if (defaultVanityUrl != null && defaultVanityUrl.isActive()) { redirect(request, defaultVanityUrl); } } } catch (PathNotFoundException e) { logger.debug("Path not found : " + urlPathInfo); } catch (AccessDeniedException e) { logger.debug("User has no access to the resource, so there will not be a redirection"); } catch (RepositoryException e) { logger.warn("Error when trying to check whether there is a vanity URL mapping", e); } } } }
From source file:org.jboss.windup.decorator.archive.ManifestVersionDecorator.java
private String extractNameFromArchiveName(String archiveName) { String name = archiveName;//from w ww . j av a 2s . c o m name = StringUtils.substringBefore(name, "."); // now, if there are numbers... strip the numbers from the end. StringBuilder nameBuilder = new StringBuilder(); String[] nameArray = StringUtils.split(name, "-"); for (String nameFrag : nameArray) { if (StringUtils.isNotBlank(nameFrag)) { // check to see if the fragment starts with alpha. if (!StringUtils.isNumeric(StringUtils.substring(nameFrag, 0, 1))) { nameBuilder.append(nameFrag).append("-"); } } } name = nameBuilder.toString(); if (StringUtils.endsWith(name, "-")) { name = StringUtils.substringBeforeLast(name, "-"); } return name; }
From source file:org.jboss.windup.util.NewLineUtil.java
public static int countNewLine(String html, int charPosition) { String subString = StringUtils.substring(html, 0, charPosition + 1); String[] lines = subString.split("\r\n|\r|\n"); return lines.length; }