List of usage examples for org.apache.commons.lang StringUtils substringAfter
public static String substringAfter(String str, String separator)
Gets the substring after the first occurrence of a separator.
From source file:com.cloudera.hive.udf.functions.ParseKeyValueTuple.java
/** * Processes the input string into a KeyValue Map utilizing the fieldDelimiter and keyValSeparator.</br> * Only considers valid pairs(has keyValSeparator) with non-empty/null keys that are in keyNames. * <p>/* w w w . j a v a 2 s . c o m*/ * Note: The key is the string before the first occurrence of keyValSeparator and the value is everything after.</br> * Note: If a key occurs twice the last value seen will be represented. * * @param inputString the string to be processed * @param fieldDelimiter separator between KeyValue pairs * @param keyValSeparator separator between key and value * @param keyNames used to filter values inserted * @return the key value map for keyNames */ private Map<String, String> getKeyValMap(final String inputString, final String fieldDelimiter, final String keyValSeparator, final List<String> keyNames) { final Set<String> uniqueKeyNames = new HashSet<String>(keyNames); // Optimize in the case of duplicate key names final Map<String, String> keyValMap = new HashMap<String, String>(uniqueKeyNames.size()); //Initialized with the expected size final Iterable<String> splitIterable = Splitter.on(fieldDelimiter).omitEmptyStrings().split(inputString); //Iterator to prevent excessive allocation int count = 0; // Counter to break out when we have seen all of the uniqueKeyNames for (final String keyValPair : splitIterable) { final String key = StringUtils.substringBefore(keyValPair, keyValSeparator); final String value = StringUtils.substringAfter(keyValPair, keyValSeparator); // Only consider valid pairs with non-empty/null keys that are in uniqueKeyNames if (StringUtils.contains(keyValPair, keyValSeparator) && !StringUtils.isEmpty(key) && uniqueKeyNames.contains(key)) { final String prev = keyValMap.put(key, value); if (prev == null) { count++; } else if (!mapWarned) { // Otherwise a key was replaced LOG.warn( "At least 1 inputString had a duplicate key for a keyName. The second value will be represented. Additional warnings for a duplicate key will be suppressed."); mapWarned = true; } if (count >= uniqueKeyNames.size()) { break; // We have seen all of the keyNames needed } } } return keyValMap; }
From source file:eionet.util.SecurityUtil.java
/** * Returns the list of countries the logged in user represents detected from the roles assigned for the user in LDAP. * The country code is last 2 digits on role name. The country codes are detected only for the parent roles given as method * argument./*from w w w .j a v a 2 s.co m*/ * * @param dduser Logged in user object. * @param parentRoles List of parent roles, where country code will be detected as last 2 digits. * @return List of ISO2 country codes in upper codes. Null if user object or parentRoles are null. */ public static List<String> getUserCountriesFromRoles(DDUser dduser, String[] parentRoles) { if (dduser == null || dduser.getUserRoles() == null || parentRoles == null) { return null; } List<String> countries = new ArrayList<String>(); for (String role : dduser.getUserRoles()) { for (String parentRole : parentRoles) { if (!parentRole.endsWith("-")) { parentRole = parentRole.concat("-"); } if (role.startsWith(parentRole)) { String roleSuffix = StringUtils.substringAfter(role, parentRole).toUpperCase(); if (roleSuffix.length() == 2 && !countries.contains(roleSuffix)) { countries.add(roleSuffix); } } } } return countries; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MSSQLLoginComposite.java
@Override public boolean connection() { if (!isValidate()) return false; String dbUrl = ""; String strHost = textHost.getText(); if (StringUtils.contains(strHost, "\\")) { String strIp = StringUtils.substringBefore(strHost, "\\"); String strInstance = StringUtils.substringAfter(strHost, "\\"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else if (StringUtils.contains(strHost, "/")) { String strIp = StringUtils.substringBefore(strHost, "/"); String strInstance = StringUtils.substringAfter(strHost, "/"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else {//from w ww . ja va 2 s .c om dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); } if (logger.isDebugEnabled()) logger.debug("[db url]" + dbUrl); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.MSSQL_DEFAULT.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { int intVersion = 0; try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); // ? . DBInfoDAO dbInfo = (DBInfoDAO) sqlClient.queryForObject("findDBInfo"); //$NON-NLS-1$ intVersion = Integer.parseInt(StringUtils.substringBefore(dbInfo.getProductversion(), ".")); } catch (Exception e) { logger.error("MSSQL Connection", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_8, //$NON-NLS-1$ errStatus); return false; } try { if (intVersion <= 8) { userDB.setTypes(DBDefine.MSSQL_8_LE_DEFAULT.getDBToString()); } TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("MSSQL", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_10, //$NON-NLS-1$ errStatus); } } return true; }
From source file:hydrograph.ui.expression.editor.composites.CategoriesDialogSourceComposite.java
private void createDelButton(Composite headerComposite) { deleteButton = new Button(headerComposite, SWT.NONE); deleteButton.setBounds(0, 0, 75, 25); deleteButton.setToolTipText(Messages.EXTERNAL_JAR_DIALOG_DELETE_BUTTON_TOOLTIP); try {//from w w w . j a va 2s. co m deleteButton.setImage(ImagePathConstant.DELETE_BUTTON.getImageFromRegistry()); } catch (Exception exception) { LOGGER.error("Exception occurred while attaching image to button", exception); deleteButton.setText("Delete"); } deleteButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (comboJarList.getSelectionIndex() > -1) { String jarName = comboJarList.getItem(comboJarList.getSelectionIndex()); if (userIsSure(jarName)) { try { removeJarFromBuildPath(jarName); comboJarList.remove(jarName); sourcePackageList.removeAll(); refresh(jarName); enableOrDisableAddLabelsOnComboSelection(); } catch (CoreException e1) { LOGGER.error( "Exception occurred while removing jar file" + jarName + "from build Path"); } } } } private boolean userIsSure(String jarName) { MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setMessage("Do you really want to remove " + jarName + " file?\nCannot be undone."); messageBox.setText("Remove Resource"); int response = messageBox.open(); if (response == SWT.YES) return true; return false; } private void refresh(String jarName) { boolean isAnyItemRemovedFromTargetList = false; String[] items = targetComposite.getTargetList().getItems(); targetComposite.getTargetList().removeAll(); for (String item : items) { String jarFileName = StringUtils.trim(StringUtils.substringAfter(item, Constants.DASH)); if (!StringUtils.equalsIgnoreCase(jarFileName, jarName)) { targetComposite.getTargetList().add(item); } else isAnyItemRemovedFromTargetList = true; } if (isAnyItemRemovedFromTargetList) { addCategoreisDialog.createPropertyFileForSavingData(); } } private void removeJarFromBuildPath(String jarName) throws CoreException { LOGGER.debug("Removing jar file" + jarName + "from build Path"); IJavaProject javaProject = JavaCore .create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject()); IFile jarFile = javaProject.getProject().getFolder(PathConstant.PROJECT_LIB_FOLDER) .getFile(jarName); IClasspathEntry[] oldClasspathEntry = javaProject.getRawClasspath(); IClasspathEntry[] newClasspathEntry = new IClasspathEntry[oldClasspathEntry.length - 1]; if (jarFile.exists()) { int index = 0; for (IClasspathEntry classpathEntry : oldClasspathEntry) { if (classpathEntry.getPath().equals(jarFile.getFullPath())) { continue; } newClasspathEntry[index] = classpathEntry; index++; } javaProject.setRawClasspath(newClasspathEntry, new NullProgressMonitor()); jarFile.delete(true, new NullProgressMonitor()); } javaProject.close(); } @Override public void widgetDefaultSelected(SelectionEvent e) {/* Do-Nothing */ } }); }
From source file:com.doculibre.constellio.wicket.panels.results.DefaultSearchResultPanel.java
public DefaultSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) { super(id);// w ww . ja v a 2 s. c o m RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils .getSearchInterfaceConfigServices(); String collectionName = dataProvider.getSimpleSearch().getCollectionName(); RecordCollection collection = collectionServices.get(collectionName); Record record = recordServices.get(doc); if (record != null) { SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices.get(); IndexField uniqueKeyField = collection.getUniqueKeyIndexField(); IndexField defaultSearchField = collection.getDefaultSearchIndexField(); IndexField urlField = collection.getUrlIndexField(); IndexField titleField = collection.getTitleIndexField(); if (urlField == null) { urlField = uniqueKeyField; } if (titleField == null) { titleField = urlField; } final String recordURL = record.getUrl(); final String displayURL; if (record.getDisplayUrl().startsWith("/get?file=")) { HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest(); displayURL = ContextUrlUtils.getContextUrl(req) + record.getDisplayUrl(); } else { displayURL = record.getDisplayUrl(); } String title = record.getDisplayTitle(); final String protocol = StringUtils.substringBefore(displayURL, ":"); boolean linkEnabled = isLinkEnabled(protocol); // rcupration des champs highlight partir de la cl unique // du document, dans le cas de Nutch c'est l'URL QueryResponse response = dataProvider.getQueryResponse(); Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL); String titleHighlight = getTitleFromHighlight(titleField.getName(), fieldsHighlighting); if (titleHighlight != null) { title = titleHighlight; } String excerpt = null; String description = getDescription(record); String summary = getSummary(record); if (StringUtils.isNotBlank(description) && searchInterfaceConfig.isDescriptionAsExcerpt()) { excerpt = description; } else { excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting); if (excerpt == null) { excerpt = description; } } toggleSummaryLink = new WebMarkupContainer("toggleSummaryLink"); add(toggleSummaryLink); toggleSummaryLink.setVisible(StringUtils.isNotBlank(summary)); toggleSummaryLink.add(new AttributeModifier("onclick", new LoadableDetachableModel() { @Override protected Object load() { return "toggleSearchResultSummary('" + summaryLabel.getMarkupId() + "')"; } })); summaryLabel = new Label("summary", summary); add(summaryLabel); summaryLabel.setOutputMarkupId(true); summaryLabel.setVisible(StringUtils.isNotBlank(summary)); ExternalLink titleLink; if (displayURL.startsWith("file://")) { HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest(); String newDisplayURL = ContextUrlUtils.getContextUrl(req) + "app/getSmbFile?" + SmbServletPage.RECORD_ID + "=" + record.getId() + "&" + SmbServletPage.COLLECTION + "=" + collectionName; titleLink = new ExternalLink("titleLink", newDisplayURL); } else { titleLink = new ExternalLink("titleLink", displayURL); } final RecordModel recordModel = new RecordModel(record); AttributeModifier computeClickAttributeModifier = new AttributeModifier("onmousedown", true, new LoadableDetachableModel() { @Override protected Object load() { Record record = recordModel.getObject(); SimpleSearch simpleSearch = dataProvider.getSimpleSearch(); WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest httpRequest = webRequest.getHttpServletRequest(); return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch, record); } }); titleLink.add(computeClickAttributeModifier); titleLink.setEnabled(linkEnabled); boolean resultsInNewWindow; PageParameters params = RequestCycle.get().getPageParameters(); if (params != null && params.getString(POPUP_LINK) != null) { resultsInNewWindow = params.getBoolean(POPUP_LINK); } else { resultsInNewWindow = searchInterfaceConfig.isResultsInNewWindow(); } titleLink.add(new SimpleAttributeModifier("target", resultsInNewWindow ? "_blank" : "_self")); // Add title title = StringUtils.remove(title, "\n"); title = StringUtils.remove(title, "\r"); if (StringUtils.isEmpty(title)) { title = StringUtils.defaultString(displayURL); title = StringUtils.substringAfterLast(title, "/"); title = StringUtils.substringBefore(title, "?"); try { title = URLDecoder.decode(title, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (title.length() > 120) { title = title.substring(0, 120) + " ..."; } } Label titleLabel = new Label("title", title); titleLink.add(titleLabel.setEscapeModelStrings(false)); add(titleLink); Label excerptLabel = new Label("excerpt", excerpt); add(excerptLabel.setEscapeModelStrings(false)); // add(new ExternalLink("url", url, // url).add(computeClickAttributeModifier).setEnabled(linkEnabled)); if (displayURL.startsWith("file://")) { // Creates a Windows path for file URLs String urlLabel = StringUtils.substringAfter(displayURL, "file:"); urlLabel = StringUtils.stripStart(urlLabel, "/"); urlLabel = "\\\\" + StringUtils.replace(urlLabel, "/", "\\"); try { urlLabel = URLDecoder.decode(urlLabel, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } add(new Label("url", urlLabel)); } else { add(new Label("url", displayURL)); } final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>( collection); add(new ListView("searchResultFields", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = collectionModel.getObject(); return collection.getSearchResultFields(); } /** * Detaches from the current request. Implement this method with * custom behavior, such as setting the model object to null. */ protected void onDetach() { recordModel.detach(); collectionModel.detach(); } }) { @Override protected void populateItem(ListItem item) { SearchResultField searchResultField = (SearchResultField) item.getModelObject(); IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices(); Record record = recordModel.getObject(); IndexField indexField = searchResultField.getIndexField(); Locale locale = getLocale(); String indexFieldTitle = indexField.getTitle(locale); if (StringUtils.isBlank(indexFieldTitle)) { indexFieldTitle = indexField.getName(); } StringBuffer fieldValueSb = new StringBuffer(); List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField); Map<String, String> defaultLabelledValues = indexFieldServices .getDefaultLabelledValues(indexField, locale); for (Object fieldValue : fieldValues) { if (fieldValueSb.length() > 0) { fieldValueSb.append("\n"); } String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale); if (fieldValueLabel == null) { fieldValueLabel = defaultLabelledValues.get("" + fieldValue); } if (fieldValueLabel == null) { fieldValueLabel = "" + fieldValue; } fieldValueSb.append(fieldValueLabel); } item.add(new Label("indexField", indexFieldTitle)); item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString())); item.setVisible(fieldValueSb.length() > 0); } @SuppressWarnings("unchecked") @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject(); visible = !searchResultFields.isEmpty(); } return visible; } }); // md5 ConstellioSession session = ConstellioSession.get(); ConstellioUser user = session.getUser(); // TODO Provide access to unauthenticated users ? String md5 = ""; if (user != null) { IntelliGIDServiceInfo intelligidServiceInfo = ConstellioSpringUtils.getIntelliGIDServiceInfo(); if (intelligidServiceInfo != null) { Collection<Object> md5Coll = doc.getFieldValues(IndexField.MD5); if (md5Coll != null) { for (Object md5Obj : md5Coll) { try { String md5Str = new String(Hex.encodeHex(Base64.decodeBase64(md5Obj.toString()))); InputStream is = HttpClientHelper .get(intelligidServiceInfo.getIntelligidUrl() + "/connector/checksum", "md5=" + URLEncoder.encode(md5Str, "ISO-8859-1"), "username=" + URLEncoder.encode(user.getUsername(), "ISO-8859-1"), "password=" + URLEncoder.encode(Base64.encodeBase64String( ConstellioSession.get().getPassword().getBytes())), "ISO-8859-1"); try { Document xmlDocument = new SAXReader().read(is); Element root = xmlDocument.getRootElement(); for (Iterator<Element> it = root.elementIterator("fichier"); it.hasNext();) { Element fichier = it.next(); String url = fichier.attributeValue("url"); md5 += "<a href=\"" + url + "\">" + url + "</a> "; } } finally { IOUtils.closeQuietly(is); } } catch (Exception e) { e.printStackTrace(); } } } } } Label md5Label = new Label("md5", md5) { public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { visible = StringUtils.isNotBlank(this.getModelObjectAsString()); } return visible; } }; md5Label.setEscapeModelStrings(false); add(md5Label); add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch())); } else { setVisible(false); } }
From source file:de.hybris.platform.commercefacades.customer.impl.DefaultCustomerFacadeTest.java
@Test public void testRegisterGuest() throws DuplicateUidException { final String email = "test@test.com"; final CustomerData guestCustomerData = new CustomerData(); guestCustomerData.setCurrency(defaultCurrencyData); guestCustomerData.setLanguage(defaultLanguageData); final CustomerModel guestCustomer = new CustomerModel(); given(mockModelService.create(CustomerModel.class)).willReturn(guestCustomer); given(customerConverter.convert(guestCustomer)).willReturn(guestCustomerData); given(Boolean.valueOf(cartService.hasSessionCart())).willReturn(Boolean.TRUE); defaultCustomerFacade.createGuestUserForAnonymousCheckout(email, "Guest"); Assert.assertEquals(StringUtils.substringAfter(guestCustomer.getUid(), "|"), email); }
From source file:edu.cornell.kfs.coa.document.validation.impl.AccountReversionRule.java
/** * Validates that the sub fund group code on the reversion account is valid as defined by the allowed values in * SELECTION_4 system parameter./*from ww w . j a v a 2 s . c om*/ * * @param acctReversion * @return true if valid, false otherwise */ protected boolean validateAccountSubFundGroup(AccountReversion acctReversion) { boolean valid = true; String subFundGroups = SpringContext.getBean(ParameterService.class) .getParameterValueAsString(Reversion.class, CUKFSConstants.Reversion.SELECTION_4); String propertyName = StringUtils.substringBefore(subFundGroups, "="); List<String> ruleValues = Arrays.asList(StringUtils.substringAfter(subFundGroups, "=").split(";")); if (ObjectUtils.isNotNull(ruleValues) && ruleValues.size() > 0) { GlobalVariables.getMessageMap().addToErrorPath("document.newMaintainableObject"); if (ObjectUtils.isNotNull(acctReversion.getAccount())) { String accountSubFundGroupCode = acctReversion.getAccount().getSubFundGroupCode(); if (ruleValues.contains(accountSubFundGroupCode)) { valid = false; GlobalVariables.getMessageMap().putError(CUKFSPropertyConstants.ACCT_REVERSION_ACCT_NUMBER, RiceKeyConstants.ERROR_DOCUMENT_INVALID_VALUE_DENIED_VALUES_PARAMETER, new String[] { getDataDictionaryService().getAttributeLabel(SubFundGroup.class, KFSPropertyConstants.SUB_FUND_GROUP_CODE), accountSubFundGroupCode, getParameterAsStringForMessage(CUKFSConstants.Reversion.SELECTION_4), getParameterValuesForMessage(ruleValues), getDataDictionaryService().getAttributeLabel(AccountReversion.class, CUKFSPropertyConstants.ACCT_REVERSION_ACCT_NUMBER) }); } } if (ObjectUtils.isNotNull(acctReversion.getBudgetReversionAccount())) { String budgetAccountSubFundGroupCode = acctReversion.getBudgetReversionAccount() .getSubFundGroupCode(); if (ruleValues.contains(budgetAccountSubFundGroupCode)) { valid = false; GlobalVariables.getMessageMap().putError( CUKFSPropertyConstants.ACCT_REVERSION_BUDGET_REVERSION_ACCT_NUMBER, RiceKeyConstants.ERROR_DOCUMENT_INVALID_VALUE_DENIED_VALUES_PARAMETER, new String[] { getDataDictionaryService().getAttributeLabel(SubFundGroup.class, KFSPropertyConstants.SUB_FUND_GROUP_CODE), budgetAccountSubFundGroupCode, getParameterAsStringForMessage(CUKFSConstants.Reversion.SELECTION_4), getParameterValuesForMessage(ruleValues), getDataDictionaryService().getAttributeLabel(AccountReversion.class, CUKFSPropertyConstants.ACCT_REVERSION_BUDGET_REVERSION_ACCT_NUMBER) }); } } if (ObjectUtils.isNotNull(acctReversion.getCashReversionAccount())) { String cashAccountSubFundGroupCode = acctReversion.getCashReversionAccount().getSubFundGroupCode(); if (ruleValues.contains(cashAccountSubFundGroupCode)) { valid = false; GlobalVariables.getMessageMap().putError( CUKFSPropertyConstants.ACCT_REVERSION_CASH_REVERSION_ACCT_NUMBER, RiceKeyConstants.ERROR_DOCUMENT_INVALID_VALUE_ALLOWED_VALUES_PARAMETER, new String[] { getDataDictionaryService().getAttributeLabel(SubFundGroup.class, KFSPropertyConstants.SUB_FUND_GROUP_CODE), cashAccountSubFundGroupCode, getParameterAsStringForMessage(CUKFSConstants.Reversion.SELECTION_4), getParameterValuesForMessage(ruleValues), getDataDictionaryService().getAttributeLabel(AccountReversion.class, CUKFSPropertyConstants.ACCT_REVERSION_CASH_REVERSION_ACCT_NUMBER) }); } } GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject"); } return valid; }
From source file:bbcdataservice.BBCDataService.java
private ArrayList<Channel> getRegionChannels(final String channelId, final String channelName, final String webSite, final int category, final ProgressMonitor progress) { final ArrayList<Channel> channels = new ArrayList<Channel>(); try {/*from w w w .j av a 2 s . c o m*/ File regionsFile = new File(mWorkingDir, "regions"); IOUtilities.download(new URL(PROGRAMMES_URL + webSite), regionsFile); StreamUtilities.bufferedReader(regionsFile, new BufferedReaderProcessor() { public void process(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.contains(webSite)) { line = StringUtils.substringAfter(line, "a href"); String regionId = StringUtils.substringBetween(line, "schedules/", "\""); if ("today".equalsIgnoreCase(regionId) || "tomorrow".equalsIgnoreCase(regionId) || "yesterday".equalsIgnoreCase(regionId)) { continue; } if (StringUtils.isNotEmpty(regionId) && !regionId.contains("/")) { String regionName = StringUtils.substringBetween(line, ">", "</a"); regionName = HTMLTextHelper.convertHtmlToText(regionName); if ("Schedule".equalsIgnoreCase(regionName) || "View full schedule".equalsIgnoreCase(regionName)) { continue; } String webSite = StringUtils.substringBetween(line, "=\"", "\""); boolean found = false; for (Channel channel : channels) { if (channel.getWebpage().equalsIgnoreCase(PROGRAMMES_URL + webSite)) { found = true; break; } } if (!found) { String localName = channelName + " (" + regionName + ")"; String localId = channelId + "." + regionId; if (StringUtils.isNotEmpty(localName) && StringUtils.isNotEmpty(localId)) { progress.setMessage( mLocalizer.msg("search.channel", "Found channel: {0}", localName)); Channel channel = new Channel(BBCDataService.this, localName, localId, TIME_ZONE, COUNTRY, COPYRIGHT, PROGRAMMES_URL + webSite, CHANNEL_GROUP, null, category); channels.add(channel); } } } } } } }); regionsFile.delete(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return channels; }
From source file:io.ecarf.core.utils.LogParser.java
/** * - Processing file: /tmp/wordnet_links.nt.gz.kryo.gz, dictionary items: 49382611, memory usage: 14.336268931627274GB, timer: 290.0 ms * /tmp/wikipedia_links_en.nt.gz.kryo.gz, dictionary items: 44, memory usage: 0.013648882508277893GB, timer: 2.636 s * START: Downloading file: interlanguage_links_chapters_en.nt.gz.kryo.gz, memory usage: 0.0GB * @param line//from w w w . j ava 2s . c o m * @param after * @return */ private double[] extractAndGetMemoryDictionaryItems(String line) { double memory = 0; double items = 0; String memoryStr = null; if (line.contains(TIMER_PREFIX)) { memoryStr = StringUtils.substringBetween(line, MEM_USE, TIMER_PREFIX); if (line.contains(DIC_ITEMS)) { String itemsStr = StringUtils.trim(StringUtils.substringBetween(line, DIC_ITEMS, MEM_USE)); items = Double.parseDouble(itemsStr); } } else { memoryStr = StringUtils.substringAfter(line, MEM_USE); } if (memoryStr != null) { memoryStr = StringUtils.remove(memoryStr, "GB"); memoryStr = StringUtils.strip(memoryStr); } memory = Double.parseDouble(memoryStr); double[] values = new double[] { memory, items }; return values; }
From source file:de.fme.topx.component.TopXSearchComponent.java
/** * reads the display path, the sitename and sitepath for correct linking in * ui/*w w w.j av a2 s. com*/ * * @param nodeRef * @param newNode */ private void setPathAttributes(NodeRef nodeRef, Node newNode) { Path path = getNodeService().getPath(nodeRef); String displayPath = path.toDisplayPath(nodeService, permissionService); newNode.setDisplayPath(displayPath); String pathCutted = StringUtils.substringAfter(StringUtils.substringAfter(displayPath, "/"), "/"); if (pathCutted.startsWith("Sites/")) { String siteName = StringUtils.substringBetween(displayPath, "Sites/", "/"); newNode.setSiteName(siteName); String documentPath = StringUtils.substringAfter(displayPath, "Sites/" + siteName + "/documentLibrary/"); String sitePath = StringUtils.substringBeforeLast(documentPath, "/"); newNode.setSitePath(sitePath); } String parentNodeRef = getPrimaryParent(nodeRef); newNode.setParentNodeRef(parentNodeRef); }