List of usage examples for org.apache.commons.lang3 StringUtils split
public static String[] split(final String str, final String separatorChars)
Splits the provided text into an array, separators specified.
From source file:com.anrisoftware.sscontrol.profile.service.ProfilePropertiesImpl.java
@Override public List<String> getList(String key) { if (!containsKey(key)) { return null; }/*ww w .j a v a2 s . com*/ String value = get(key).toString(); return Arrays.asList(StringUtils.split(value, ",")); }
From source file:com.sonicle.webtop.core.sdk.ServiceVersion.java
public String getMaintainance() { if (isUndefined()) return null; String[] tokens = StringUtils.split(this.version, "."); return (tokens.length == 3) ? tokens[2] : "0"; }
From source file:com.enlight.game.entity.User.java
@Transient @JsonIgnore//w w w.ja v a 2 s.c o m public List<String> getStoreIds() { // ???List. return ImmutableList.copyOf(StringUtils.split(storeId, ",")); }
From source file:com.mirth.connect.server.api.MirthServlet.java
protected void initLogin() { if (isUserLoggedIn()) { currentUserId = Integer.parseInt(request.getSession().getAttribute(SESSION_USER).toString()); context = new ServerEventContext(currentUserId); try {/*from w w w . ja v a2 s .c o m*/ userHasChannelRestrictions = authorizationController.doesUserHaveChannelRestrictions(currentUserId); if (userHasChannelRestrictions) { authorizedChannelIds = authorizationController.getAuthorizedChannelIds(currentUserId); } } catch (ControllerException e) { throw new MirthApiException(e); } } else if (configurationController.isBypasswordEnabled() && isRequestLocal()) { /* * If user isn't logged in, then only allow the request if it originated locally and the * bypassword is given. */ boolean authorized = false; try { String authHeader = request.getHeader("Authorization"); if (StringUtils.isNotBlank(authHeader)) { authHeader = new String( Base64.decodeBase64(StringUtils.removeStartIgnoreCase(authHeader, "Basic ").trim()), "US-ASCII"); String[] authParts = StringUtils.split(authHeader, ':'); if (authParts.length >= 2) { if (StringUtils.equals(authParts[0], BYPASS_USERNAME) && configurationController.checkBypassword(authParts[1])) { authorized = true; } } } } catch (Exception e) { } if (authorized) { context = ServerEventContext.SYSTEM_USER_EVENT_CONTEXT; currentUserId = context.getUserId(); bypassUser = true; } else { throw new MirthApiException(Status.UNAUTHORIZED); } } else { throw new MirthApiException(Status.UNAUTHORIZED); } }
From source file:ke.co.tawi.babblesms.server.utils.export.topups.AllTopupsExportUtil.java
/** * Creates a Microsoft Excel Workbook containing Topup activity provided in * a CSV text file. The format of the created file will be Office Open XML * (OOXML).//w w w.jav a 2 s . c o m * <p> * It expects the CSV to have the following columns from left to right:<br * /> * topup.uuid, topup.msisdn, topup.amount, network.name, topupStatus.status, * topup.topupTime * <p> * This method has been created to allow for large Excel files to be created * without overwhelming memory. * * * @param topupCSVFile a valid CSV text file. It should contain the full * path and name of the file e.g. "/tmp/export/topups.csv" * @param delimiter the delimiter used in the CSV file * @param excelFile the Microsoft Excel file to be created. It should * contain the full path and name of the file e.g. "/tmp/export/topups.xlsx" * @return whether the creation of the Excel file was successful or not */ public static boolean createExcelExport(final String topupCSVFile, final String delimiter, final String excelFile) { boolean success = true; int rowCount = 0; // To keep track of the row that we are on Row row; Map<String, CellStyle> styles; SXSSFWorkbook wb = new SXSSFWorkbook(5000); // keep 5000 rows in memory, exceeding rows will be flushed to disk // Each line of the file is approximated to be 200 bytes in size, // therefore 5000 lines are approximately 1 MB in memory // wb.setCompressTempFiles(true); // temporary files will be gzipped on disk Sheet sheet = wb.createSheet("Airtime Topup"); styles = createStyles(wb); PrintSetup printSetupTopup = sheet.getPrintSetup(); printSetupTopup.setLandscape(true); sheet.setFitToPage(true); // Set up the heading to be seen in the Excel sheet row = sheet.createRow(rowCount); Cell titleCell; row.setHeightInPoints(45); titleCell = row.createCell(0); titleCell.setCellValue("Airtime Topups"); sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1")); titleCell.setCellStyle(styles.get("title")); rowCount++; row = sheet.createRow(rowCount); row.setHeightInPoints(12.75f); for (int i = 0; i < TOPUP_TITLES.length; i++) { Cell cell = row.createCell(i); cell.setCellValue(TOPUP_TITLES[i]); cell.setCellStyle(styles.get("header")); } rowCount++; FileUtils.deleteQuietly(new File(excelFile)); FileOutputStream out; try { FileUtils.touch(new File(excelFile)); // Read the CSV file and populate the Excel sheet with it LineIterator lineIter = FileUtils.lineIterator(new File(topupCSVFile)); String line; String[] lineTokens; int size; while (lineIter.hasNext()) { row = sheet.createRow(rowCount); line = lineIter.next(); lineTokens = StringUtils.split(line, delimiter); size = lineTokens.length; for (int cellnum = 0; cellnum < size; cellnum++) { Cell cell = row.createCell(cellnum); cell.setCellValue(lineTokens[cellnum]); } rowCount++; } out = new FileOutputStream(excelFile); wb.write(out); out.close(); } catch (FileNotFoundException e) { logger.error("FileNotFoundException while trying to create Excel file '" + excelFile + "' from CSV file '" + topupCSVFile + "'."); logger.error(ExceptionUtils.getStackTrace(e)); success = false; } catch (IOException e) { logger.error("IOException while trying to create Excel file '" + excelFile + "' from CSV file '" + topupCSVFile + "'."); logger.error(ExceptionUtils.getStackTrace(e)); success = false; } wb.dispose(); // dispose of temporary files backup of this workbook on disk return success; }
From source file:info.magnolia.ui.contentapp.detail.DetailLocation.java
protected String getParameter(String parameter, int position) { String arguments[] = StringUtils.split(parameter, ':'); if (position <= arguments.length - 1) { return arguments[position]; }//from w w w . j av a 2 s. co m return ""; }
From source file:com.adobe.acs.samples.workflow.impl.SampleGraniteWorkflowProcess.java
/** * The method called by the AEM Workflow Engine to perform Workflow work. * * @param workItem the work item representing the resource moving through the Workflow * @param workflowSession the workflow session * @param args arguments for this Workflow Process defined on the Workflow Model (PROCESS_ARGS, argSingle, argMulti) * @throws WorkflowException when the Workflow Process step cannot complete. This will cause the WF to retry. *//* w w w . j a v a 2 s.c o m*/ @Override public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException { /* Get the Workflow Payload */ // Get the Workflow data (the data that is being passed through for this work item) final WorkflowData workflowData = workItem.getWorkflowData(); final String type = workflowData.getPayloadType(); // Check if the payload is a path in the JCR; The other (less common) type is JCR_UUID if (!StringUtils.equals(type, "JCR_PATH")) { return; } // Get the path to the JCR resource from the payload final String path = workflowData.getPayload().toString(); /* Get Workflow Process Arguments */ // These args are specified on the Workflow Model using this WF Process. /* Process Args */ // These are free-form textfields; the values of these may need to be parsed based on // expected in put formats String processArgs = args.get("PROCESS_ARGS", "default value"); String[] proccesArgsVals = StringUtils.split(processArgs, ","); /* Single and MultiValue args */ // Some WF Process steps support Single and MultiValue args; these are can access via named properties // Custom WF inputs stored under ./metaData/argSingle and ./metadata/argMulti String singleValue = args.get("argSingle", "not set"); String[] multiValue = args.get("argMulti", new String[] { "not set" }); log.debug("Single Value: {}", singleValue); log.debug("Multi Value: {}", Arrays.toString(multiValue)); /* Get data set in prior Workflow Steps */ String previouslySetData = this.getPersistedData(workItem, "set-in-previous-workflow-step", String.class); /* Do work on the Payload; Remember to use Sling APIs as much as possible */ ResourceResolver resourceResolver = null; try { // Get the ResourceResolver from workflow session resourceResolver = getResourceResolver(workflowSession.adaptTo(Session.class)); // Get the resource the payload points to; Keep in mind the payload can be any resource including // a AEM WF Package which must be processes specially. Resource resource = resourceResolver.getResource(path); // Do work .... // Save data for use in a subsequent Workflow step persistData(workItem, workflowSession, "set-for-next-workflow-step", "whatever data you want"); } catch (Exception e) { // If an error occurs that prevents the Workflow from completing/continuing - Throw a WorkflowException // and the WF engine will retry the Workflow later (based on the AEM Workflow Engine configuration). log.error("Unable to complete processing the Workflow Process step", e); throw new WorkflowException("Unable to complete processing the Workflow Process step", e); } }
From source file:info.magnolia.ui.form.field.definition.FieldDefinitionKeyGenerator.java
@Override protected void keysFor(List<String> list, FieldDefinition field, AnnotatedElement el) { Object parent = getParentViaCast(field); String fieldName = field.getName().replace(':', '-'); if (parent != null && isChooseDialog(parent.getClass())) { // handle choose dialog final AppDescriptor app = (AppDescriptor) getRoot(field); addKey(list, app.getName(), "chooseDialog", "fields", fieldName, fieldOrGetterName(el)); } else {/*from w ww .j av a 2s .c om*/ final Deque<String> parentNames = new LinkedList<String>(); while (parent != null && !(parent instanceof TabDefinition)) { String parentName = getParentName(parent); if (parentName != null) { parentNames.addFirst(parentName); } parent = getParentViaCast(parent); } final String property = fieldOrGetterName(el); final String parentKeyPart = StringUtils.join(parentNames, '.').replace(':', '-'); if (parent instanceof TabDefinition) { TabDefinition tab = (TabDefinition) parent; final String tabName = tab.getName(); final FormDefinition formDef = getParentViaCast(tab); final String dialogID = getParentId(formDef); // in case of a field in field if (parentNames.size() > 0) { // <dialogId>.<tabName>.<parentFieldNames_separated_by_dots>.<fieldName>.<property> // <dialogId>.<tabName>.<parentFieldNames_separated_by_dots>.<fieldName> (in case of property==label) addKey(list, dialogID, tabName, parentKeyPart, fieldName, property); } // <dialogId>.<tabName>.<fieldName>.<property> // <dialogId>.<tabName>.<fieldName> (in case of property==label) addKey(list, dialogID, tabName, fieldName, property); // <tabName>.<fieldName> (in case of property==label) addKey(list, tabName, fieldName, property); // <dialogId>.<fieldName>.<property> // <dialogId>.<fieldName> (in case property==label) addKey(list, dialogID, fieldName, property); String[] parts = StringUtils.split(dialogID, "."); if (parts.length > 1) { String dialogIDNoModuleName = parts[parts.length - 1]; addKey(list, dialogIDNoModuleName, fieldName, property); addKey(list, dialogIDNoModuleName, tabName, fieldName, property); } } else { // In case we didn't encounter parent tab definition - we simply generated a key based on dot-separated parent names addKey(list, parentKeyPart, fieldName, property); } } }
From source file:com.mirth.connect.plugins.datatypes.hl7v2.ER7Reader.java
public void parse(InputSource source) throws SAXException, IOException { String message = getMessageFromSource(source); ContentHandler contentHandler = getContentHandler(); contentHandler.startDocument();// w w w . j ava 2 s. co m // first tokenize the segments if ((message == null) || (message.length() < 6)) { throw new SAXException("Unable to parse message. It is NULL or too short. " + message); } // usually | String fieldSeparator = DEFAULT_FIELD_SEPARATOR; String componentSeparator = DEFAULT_COMPONENT_SEPARATOR; String repetitionSeparator = DEFAULT_REPETITION_SEPARATOR; String escapeCharacter = DEFAULT_ESCAPE_CHARACTER; String subcomponentSeparator = DEFAULT_SUBCOMPONENT_TERMINATOR; // if we have a header, grab the actual separators from the message String firstSegment = message.substring(0, 3); if (firstSegment.equalsIgnoreCase("MSH") || firstSegment.equalsIgnoreCase("FHS") || firstSegment.equalsIgnoreCase("BHS")) { fieldSeparator = new String(new char[] { message.charAt(3) }); int nextDelimiter = message.indexOf(message.charAt(3), 4); if (nextDelimiter == -1) { // If the message is just MSH|^~\&, we still want to extract the encoding characters nextDelimiter = message.length(); } if (nextDelimiter > 4) { // usually ^ componentSeparator = new String(new char[] { message.charAt(4) }); } if (nextDelimiter > 5) { // usually ~ repetitionSeparator = new String(new char[] { message.charAt(5) }); } if (nextDelimiter > 6) { // usually \ escapeCharacter = new String(new char[] { message.charAt(6) }); } if (nextDelimiter > 7) { // usually & subcomponentSeparator = new String(new char[] { message.charAt(7) }); } } // replace the special case of ^~& with ^~\& (MIRTH-1544) if (message.length() >= 8 && "^~&|".equals(message.substring(4, 8))) { escapeCharacter = "\\"; subcomponentSeparator = "&"; repetitionSeparator = "~"; componentSeparator = "^"; } // tokenize the segments first String[] segments = StringUtils.split(message, segmentDelimiter); String documentHead = handleSegments("", contentHandler, fieldSeparator, componentSeparator, subcomponentSeparator, repetitionSeparator, escapeCharacter, segments); contentHandler.endElement("", documentHead, ""); contentHandler.endDocument(); }
From source file:com.greenpepper.maven.plugin.Repository.java
/** * <p>newInstance.</p>/*from www . j ava 2s .co m*/ * * @return a {@link com.greenpepper.repository.DocumentRepository} object. * @throws java.lang.Exception if any. */ public DocumentRepository newInstance() throws Exception { Class<?> klass = Class.forName(type); if (!DocumentRepository.class.isAssignableFrom(klass)) throw new IllegalArgumentException("Not a " + DocumentRepository.class.getName() + ": " + type); Constructor<?> constructor = klass.getConstructor(String[].class); return (DocumentRepository) constructor.newInstance(new Object[] { StringUtils.split(root, ';') }); }