List of usage examples for org.apache.commons.lang StringUtils removeStart
public static String removeStart(String str, String remove)
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
From source file:gobblin.config.store.hdfs.SimpleHadoopFilesystemConfigStore.java
/** * Retrieves the name of a dataset from a given {@link ConfigKeyPath}, relative to the store root. *///w ww . j av a 2 s .co m private static String getDatasetFromConfigKey(ConfigKeyPath configKey) { return StringUtils.removeStart(configKey.getAbsolutePathString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER); }
From source file:mvm.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer.java
private Set<String> unrollWildcard(String string, boolean reverse) throws IOException { Scanner termTableScan = getScanner(ConfigUtils.getFreeTextTermTablename(conf)); Set<String> unrolledTerms = new HashSet<String>(); Text queryTerm;/*from w w w. j a va 2 s .c o m*/ if (reverse) { String t = StringUtils.removeStart(string, "*").toLowerCase(); queryTerm = ColumnPrefixes.getRevTermListColFam(t); } else { String t = StringUtils.removeEnd(string, "*").toLowerCase(); queryTerm = ColumnPrefixes.getTermListColFam(t); } // perform query and read results termTableScan.setRange(Range.prefix(queryTerm)); for (Entry<Key, Value> e : termTableScan) { String term = ColumnPrefixes.removePrefix(e.getKey().getRow()).toString(); if (reverse) { unrolledTerms.add(StringUtils.reverse(term)); } else { unrolledTerms.add(term); } } if (unrolledTerms.isEmpty()) { // put in a placeholder term that will never be in the index. unrolledTerms.add("\1\1\1"); } return unrolledTerms; }
From source file:com.gemstone.gemfire.management.internal.cli.GfshParser.java
private int completeParameters(CommandTarget commandTarget, int cursorStart, String remainingBuffer, int cursor, List<Completion> completionCandidates) { int desiredCursorPosition = cursorStart; // Factor for remainingBuffer boolean sizeReduced = false; // We need to work modify the flow according to the CliException // generated. For that we will need a reference to the Exception // CliException reference CliCommandOptionException coe = null; OptionSet userOptionSet = null;/* w w w . ja va 2 s. co m*/ try { // We need to remove the space which separates command from the // parameters if (remainingBuffer.length() > 0) { remainingBuffer = remainingBuffer.substring(1); sizeReduced = true; } userOptionSet = commandTarget.getOptionParser().parse(remainingBuffer); } catch (CliException ce) { if (ce instanceof CliCommandOptionException) { coe = (CliCommandOptionException) ce; coe.setCommandTarget(commandTarget); userOptionSet = coe.getOptionSet(); } } // Contains mandatory options which have not been specified List<Option> mandatoryOptions = new ArrayList<Option>(); // Contains non-mandatory options which have not been specified List<Option> unspecifiedOptions = new ArrayList<Option>(); // First we need a list to create a list of all the options specified Map<String, Option> optionsPresentMap = new LinkedHashMap<String, Option>(); if (userOptionSet != null) { // Start with the arguments String argumentSeparator = " "; for (Argument argument : commandTarget.getOptionParser().getArguments()) { if (completionCandidates.size() == 0) { boolean warning = false; if (userOptionSet.hasArgument(argument)) { boolean incrementCursor = true; // Here we need to get all the possible values for this // argument if (getAllPossibleValuesForParameter(completionCandidates, argument, userOptionSet.getValue(argument), commandTarget.getGfshMethodTarget())) { // Check whether the list of completionCandidates is // not empty if (completionCandidates.size() > 0) { // First check whether the argument value // matches with any // of the completionCandidates if (perfectMatch(completionCandidates, userOptionSet.getValue(argument))) { // Remove all the completionCandidates completionCandidates.clear(); } else { modifyCompletionCandidates(completionCandidates, argumentSeparator, userOptionSet.getValue(argument)); // For this case also we should not // increment the // cursorPosition if (completionCandidates.size() > 0) { incrementCursor = false; } } } } else { // The completion candidates should be cleared if the Converter has // populated it with some values completionCandidates.clear(); } if (incrementCursor) { desiredCursorPosition += userOptionSet.getValue(argument).length() + argumentSeparator.length(); } } else { if (argument.isRequired()) { // Here the converter will come in handy // to get suggestion for arguments if (getAllPossibleValuesForParameter(completionCandidates, argument, null, commandTarget.getGfshMethodTarget())) { if (completionCandidates.size() == 0) { // Enable warning if nothing is returned warning = true; } } else { // The completion candidates should be cleared if the Converter has // populated it with some values completionCandidates.clear(); warning = true; } } else { boolean checkForPossibleValues = true; // This means that the argument is not mandatory // Now here we need to check whether user wants to // enter an option. if (endsWithOptionSpecifiers(userOptionSet.getUserInput()) || hasOptionSpecified(userOptionSet.getUserInput())) { // This means options have started, and we // cannot have arguments after options // So, we just skip checking for possible // values checkForPossibleValues = false; } // Just try getting the PossibleValues without // aiming if (checkForPossibleValues) { getAllPossibleValuesForParameter(completionCandidates, argument, null, commandTarget.getGfshMethodTarget()); } } if (completionCandidates.size() > 0) { modifyCompletionCandidates(completionCandidates, argumentSeparator, (String[]) null); } } if (warning) { String argMessage = argument.getArgumentName() + ((argument.getHelp() != null && !argument.getHelp().equals("")) ? ": " + argument.getHelp() : ""); logWarning(CliStrings.format(CliStrings.GFSHPARSER__MSG__REQUIRED_ARGUMENT_0, argMessage)); return desiredCursorPosition + userOptionSet.getNoOfSpacesRemoved(); } } argumentSeparator = SyntaxConstants.ARGUMENT_SEPARATOR; } if (completionCandidates.size() > 0) { return desiredCursorPosition + userOptionSet.getNoOfSpacesRemoved(); } // Now process options boolean warningValueRequired = false; Option warningOption = null; for (Option option : commandTarget.getOptionParser().getOptions()) { if (userOptionSet.hasOption(option)) { // We are supporting option synonyms, // so we need to check that here for (String string : userOptionSet.getSplit()) { if (string.startsWith(SyntaxConstants.LONG_OPTION_SPECIFIER)) { // Remove option prefix string = StringUtils.removeStart(string, SyntaxConstants.LONG_OPTION_SPECIFIER); // Remove value specifier string = StringUtils.removeEnd(string, SyntaxConstants.OPTION_VALUE_SPECIFIER); if (!string.equals("")) { if (option.getLongOption().equals(string)) { // This means that user has entered the whole option and // Increment desiredCursorPostion by the length of the // option and the option specifier, including space desiredCursorPosition += /* space */1 + SyntaxConstants.LONG_OPTION_SPECIFIER.length() + option.getLongOption().length(); break; } else { // This is only possible if the user has // entered one of the synonyms of the options // which wasn't displayed initially for (String optionSynonym : option.getSynonyms()) { if (optionSynonym.equals(string)) { // This means that what the user has // entered is actually a // synonym for the option desiredCursorPosition += /* space */1 + SyntaxConstants.LONG_OPTION_SPECIFIER.length() + optionSynonym.length(); break; } } } } } } optionsPresentMap.put(option.getLongOption(), option); // For option value if (userOptionSet.hasValue(option)) { String value = userOptionSet.getValue(option); boolean valueActuallySpecified = false; String valueSeparator = SyntaxConstants.VALUE_SEPARATOR; if (option.getValueSeparator() != null) { valueSeparator = option.getValueSeparator(); } // JOpt doesn't maintain trailing comma (separator), hence reading it from buffer. boolean bufferEndsWithValueSeparator = remainingBuffer.endsWith(valueSeparator); // Check whether the value assigned to the option is // actually part of the split array or has been // assigned using the specifiedDefaultValue attribute // userOptionElement can be option name or value of that option. // E.g. "--opt=val" has elements "opt" & "val" for (String userOptionElement : userOptionSet.getSplit()) { if (userOptionElement.equals(value) || (userOptionElement).equals(value + valueSeparator)) { valueActuallySpecified = true; } } if (!valueActuallySpecified) { continue; } boolean incrementCursor = true; boolean considerLastValue = false; int lengthToBeAdded = 0; int lastIndexOf = 0; // This should only be invoked if we don't have any // completionCandidates beforeHand if (completionCandidates.size() == 0) { // Here also we might need to invoke converter to // get values apt for the option if (!endsWithOptionSpecifiers(userOptionSet.getUserInput()) && getAllPossibleValuesForParameter(completionCandidates, option, value, commandTarget.getGfshMethodTarget())) { // If the value returned by getAllPossibleValues // is the same as that entered by the // user we need to remove it from the // completionCandidates and move forward String prefix = ""; String[] split = ParserUtils.splitValues(value, valueSeparator); if (completionCandidates.size() > 0) { if (PreprocessorUtils.isSyntaxValid(value) && bufferEndsWithValueSeparator) { // This means that the user wants to // enter more values, prefix = valueSeparator; } else if (perfectMatch(completionCandidates, split)) { // If the user does not want to enter // more values, and it matches one // of the values then we do not // need to suggest anything for // this option completionCandidates.clear(); considerLastValue = true; } else if (ParserUtils.contains(value, valueSeparator)) { prefix = valueSeparator; } else { incrementCursor = false; if (value.startsWith(" ")) { prefix = " "; } else if (value.startsWith("\n")) { prefix = "\n"; } else { prefix = SyntaxConstants.OPTION_VALUE_SPECIFIER; } } } modifyCompletionCandidates(completionCandidates, prefix, bufferEndsWithValueSeparator, split); if (completionCandidates.size() == 0) { incrementCursor = true; considerLastValue = true; } } else { // The completion candidates should be cleared if the Converter has // populated it with some values completionCandidates.clear(); considerLastValue = true; } } else { // Make everything true considerLastValue = true; } // FIX for: 46265 // if bufferEndsWithValueSeparator, append a valueSeparator to get the real lastIndexOd // e.g. Let's say remainingBuffer is: cmd --opt1=val1,val2, // value would be: cmd --opt1=val1,val2 ---> not there's no comma in the end. // This doesn't give us the real last index of valueSeparator, hence add extra valueSeparator. lastIndexOf = ParserUtils.lastIndexOf( bufferEndsWithValueSeparator ? value + valueSeparator : value, valueSeparator); lengthToBeAdded = value.substring(0, (lastIndexOf > 0 ? lastIndexOf : value.length())) .length(); // Increment desiredCursorPosition if (incrementCursor) { desiredCursorPosition += /* value specifier length */SyntaxConstants.OPTION_VALUE_SPECIFIER .length() + lengthToBeAdded + ((considerLastValue) ? value.length() - lengthToBeAdded : 0); if (value.endsWith(" ") && considerLastValue) { desiredCursorPosition--; } } if (completionCandidates.size() == 0) { if (!PreprocessorUtils.isSyntaxValid(value)) { return desiredCursorPosition + userOptionSet.getNoOfSpacesRemoved(); } else { // Check whether the value ends with // VALUE_SEPARATOR, // if yes then we need to return if (value.endsWith(valueSeparator)) { return desiredCursorPosition + userOptionSet.getNoOfSpacesRemoved(); } } } } else { // Here the converter is useful to invoke // auto-suggestion, get Values from Converter if (completionCandidates.size() == 0) { if (getAllPossibleValuesForParameter(completionCandidates, option, null, commandTarget.getGfshMethodTarget())) { if (completionCandidates.size() == 0) { warningValueRequired = true; } else { modifyCompletionCandidates(completionCandidates, SyntaxConstants.OPTION_VALUE_SPECIFIER, new String[] { null }); } } else { // The completion candidates should be cleared if the Converter // has populated it with some values completionCandidates.clear(); warningValueRequired = true; } } } } else { // As we have reached here, the OptionParser was not able to // detect anything which proves that the option is present // So, we check with what the user provided and add only // that to the list of options to prompt for for (String userOptString : userOptionSet.getSplit()) { // Now to determine whether what the user specified was // an option, we need to check whether it starts // with an option specifier if (userOptString.startsWith(SyntaxConstants.LONG_OPTION_SPECIFIER)) { // Now remove the option specifier part userOptString = StringUtils.removeStart(userOptString, SyntaxConstants.LONG_OPTION_SPECIFIER); if (option.getLongOption().startsWith(userOptString) && !userOptString.equals("") && !option.getLongOption().equals(userOptString) && !optionsPresentMap.containsKey(userOptString)) { completionCandidates.add(new Completion( " " + SyntaxConstants.LONG_OPTION_SPECIFIER + option.getLongOption(), option.getLongOption(), "", 0)); } else { for (String optionSynonym : option.getSynonyms()) { if (optionSynonym.startsWith(userOptString) && !userOptString.equals("") && !optionSynonym.equals(userOptString)) { completionCandidates.add(new Completion( " " + SyntaxConstants.LONG_OPTION_SPECIFIER + optionSynonym, optionSynonym, "", 0)); break; } } } } } if (completionCandidates.size() == 0) { if (option.isRequired()) { mandatoryOptions.add(option); } else { unspecifiedOptions.add(option); } } } if (warningValueRequired/* || warningMultipleValuesNotSupported */) { warningOption = option; warningValueRequired = false; } } // Display warning if something not specified if (warningOption != null) { String optionMsg = warningOption.getLongOption() + ((warningOption.getHelp() != null && !warningOption.getHelp().equals("")) ? ": " + warningOption.getHelp() : ""); logWarning(CliStrings.format(CliStrings.GFSHPARSER__MSG__VALUE_REQUIRED_FOR_OPTION_0, optionMsg)); desiredCursorPosition += userOptionSet.getNoOfSpacesRemoved(); completionCandidates.add(new Completion(SyntaxConstants.OPTION_VALUE_SPECIFIER, "", null, 0)); return desiredCursorPosition; } } // Calculate the cursor position int newCursor = desiredCursorPosition + ((userOptionSet != null) ? userOptionSet.getNoOfSpacesRemoved() : 0); String subString = remainingBuffer; if (newCursor != cursorStart) { subString = remainingBuffer.substring(newCursor + (sizeReduced ? -1 : 0) - cursorStart).trim(); } // Exception handling if (coe != null && newCursor < cursor && completionCandidates.size() == 0 && !(PreprocessorUtils.containsOnlyWhiteSpaces(subString) || ((subString.endsWith(SyntaxConstants.LONG_OPTION_SPECIFIER) && subString.startsWith(SyntaxConstants.LONG_OPTION_SPECIFIER)) || (subString.startsWith(SyntaxConstants.SHORT_OPTION_SPECIFIER) && subString.endsWith(SyntaxConstants.SHORT_OPTION_SPECIFIER))))) { ExceptionHandler.handleException(coe); return cursor; } // If nothing has been specified for auto-completion then we need to suggest options if (completionCandidates.size() == 0) { if (mandatoryOptions.size() > 0) { for (Option option : mandatoryOptions) { completionCandidates.add( new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + option.getLongOption(), option.getLongOption(), "", 0)); } } else { // As all the mandatory options have been specified we can prompt the // user for optional options. unspecifiedOptions = getUnspecifiedOptionsWithMode(unspecifiedOptions, commandTarget, optionsPresentMap); for (Option option : unspecifiedOptions) { completionCandidates.add( new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + option.getLongOption(), option.getLongOption(), "", 0)); } } } return newCursor; }
From source file:adalid.core.AbstractArtifact.java
private String path(Artifact a) { String p;/*from w w w . j ava 2 s . c om*/ if (a.getDeclaringField() == null || a.getDeclaringArtifact() == null) { // p = "_" + a.getAlias(); p = XS1.getNamedClass(a).getSimpleName() + "." + "this"; } else { p = path(a.getDeclaringArtifact()) + "." + a.getDeclaringField().getName(); if (a.getDeclaringField().getType().isArray()) { p += "[" + a.getDeclaringFieldIndex() + "]"; } p = StringUtils.removeStart(p, "."); } return p; }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractMessageWrappingController.java
private RESTResource getHeading(Map<Object, Object> parameterMap, String resourceUrl) { RESTResource resource = new RESTResource(); for (Entry<Object, Object> param : parameterMap.entrySet()) { Parameter headingParam = new Parameter(); headingParam.setArg(param.getKey().toString()); headingParam.setVal(getParamValue(param.getValue())); resource.addParameter(headingParam); }// ww w . j a va 2 s.c om resource.setAccessDate(new Date()); String urlRoot = this.serverContext.getServerRootWithAppName(); if (!urlRoot.endsWith("/")) { urlRoot = urlRoot + "/"; } resource.setResourceRoot(urlRoot); String resourceRelativeURI = StringUtils.removeStart(resourceUrl, "/"); resource.setResourceURI(resourceRelativeURI); return resource; }
From source file:au.edu.anu.portal.portlets.basiclti.BasicLTIPortlet.java
/** * Processes the init params to get the adapter class map. This method iterates over every init-param, selects the appropriate adapter ones, * fetches the param value and then strips the 'adapter-class-' prefix from the param name for storage in the map. * @param config PortletConfig//w w w . j a v a 2s . c o m * @return Map of adapter names and classes */ private Map<String, String> initAdapters(PortletConfig config) { Map<String, String> m = new HashMap<String, String>(); String ADAPTER_CLASS_PREFIX = "adapter-class-"; //get it into a usable form List<String> paramNames = Collections.list((Enumeration<String>) config.getInitParameterNames()); //iterate over, select the appropriate ones, retrieve the param value then strip param name for storage. for (String paramName : paramNames) { if (StringUtils.startsWith(paramName, ADAPTER_CLASS_PREFIX)) { String adapterName = StringUtils.removeStart(paramName, ADAPTER_CLASS_PREFIX); String adapterClass = config.getInitParameter(paramName); m.put(adapterName, adapterClass); log.info("Registered adapter: " + adapterName + " with class: " + adapterClass); } } log.info("Autowired: " + m.size() + " adapters"); return m; }
From source file:adalid.commons.velocity.Writer.java
private void writePlatform(WriterContext basicWriterContext, File platformPropertiesFile) { logger.info("propertiesFile=" + platformPropertiesFile.getPath()); try {/*from w w w. j av a2s.c om*/ VelocityContext platformContext = basicWriterContext.getVelocityContextClone(); String platform = StringUtils.removeEndIgnoreCase(platformPropertiesFile.getName(), PROPERTIES_SUFFIX); platformContext.put(VC_PLATFORM, platform); TLB.setProgrammers(basicWriterContext.programmers); TLB.setWrapperClasses(basicWriterContext.wrapperClasses); putProperties(platformContext, platformPropertiesFile); Properties properties = mergeProperties(platformContext, platformPropertiesFile); putStrings(platformContext, properties); ExtendedProperties mergeExtendedProperties = mergeExtendedProperties(platformContext, platformPropertiesFile); createDirectories(mergeExtendedProperties); deletePreviouslyGeneratedFiles(mergeExtendedProperties); WriterContext platformWriterContext = newWriterContext(platformContext); File platformsFolder = platformPropertiesFile.getParentFile(); ExtendedProperties platformExtendedProperties = PropertiesHandler .getExtendedProperties(platformPropertiesFile); String[] pathnames = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH); String[] pathfilters = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH_FILTER); Map<String, File> folders = new LinkedHashMap<>(); if (pathnames == null || pathnames.length == 0) { } else { for (File folder : bootstrappingPlatformsFolders) { folders.putAll(FilUtils.directoriesMap(folder, pathnames, folder)); } } if (pathfilters != null && pathfilters.length > 0) { String[] keyArray = folders.keySet().toArray(new String[folders.keySet().size()]); String slashedFilter, slashedPath; for (String pathfilter : pathfilters) { slashedFilter = pathfilter.replace(FILE_SEPARATOR, SLASH); for (String key : keyArray) { slashedPath = key.replace(FILE_SEPARATOR, SLASH) + SLASH; if (StringUtils.containsIgnoreCase(slashedPath, slashedFilter)) { folders.remove(key); logger.debug(pathfilter + " excludes " + key); } } } } File[] templateFiles; Properties templateProperties; String disabled; String disabledMissing; String pattern; String template; String message; String platformsFolderPath = platformsFolder.getPath(); // + FILE_SEPARATOR; for (File folder : folders.values()) { log(_detailLevel, "write", "path=" + StringUtils.removeStart(folder.getPath(), platformsFolderPath)); templateFiles = folder.listFiles(propertiesFileFilter); Arrays.sort(templateFiles); for (File templatePropertiesFile : templateFiles) { if (reject(templatePropertiesFile, pathfilters)) { continue; } templateProperties = PropertiesHandler.loadProperties(templatePropertiesFile); disabled = templateProperties.getProperty(TP_DISABLED, Boolean.FALSE.toString()); disabledMissing = templateProperties.getProperty(TP_DISABLED_MISSING); templates++; if (BitUtils.valueOf(disabled)) { disabledTemplates++; template = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); pattern = "template \"{0}\" ignored, check property \"{1}\" at file \"{2}\""; message = MessageFormat.format(pattern, template, TP_DISABLED, templatePropertiesFile); log(_alertLevel, message); warnings++; } else if (missing(disabledMissing)) { disabledTemplates++; template = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); pattern = "template \"{0}\" ignored because {3} is missing, check property \"{1}\" at file \"{2}\""; message = MessageFormat.format(pattern, template, TP_DISABLED_MISSING, templatePropertiesFile, disabledMissing); log(_alertLevel, message); warnings++; } else { writeTemplate(platformWriterContext, templatePropertiesFile); } } } platforms++; } catch (Throwable throwable) { error(throwable); } printSummary(); }
From source file:info.magnolia.jcr.util.NodeUtil.java
/** * Creates a node under the specified parent and relative path, then returns it. Should the node already exist, the * method will simply return it./*from w w w . jav a 2 s.c o m*/ */ public static Node createPath(Node parent, String relPath, String primaryNodeTypeName, boolean save) throws RepositoryException, PathNotFoundException, AccessDeniedException { // remove leading / String currentPath = StringUtils.removeStart(relPath, "/"); if (StringUtils.isEmpty(currentPath)) { return parent; } Node root = parent; String[] names = currentPath.split("/"); for (int i = 0; i < names.length; i++) { String name = names[i]; if (root.hasNode(name)) { root = root.getNode(name); } else { final Node newNode = root.addNode(name, primaryNodeTypeName); if (save) { root.getSession().save(); } root = newNode; } } return root; }
From source file:ch.cyberduck.core.ftp.FTPPath.java
protected boolean parseListResponse(final AttributedList<Path> children, final FTPFileEntryParser parser, final List<String> replies) { if (null == replies) { // This is an empty directory return false; }//from w ww . java 2s .co m boolean success = false; for (String line : replies) { final FTPFile f = parser.parseFTPEntry(line); if (null == f) { continue; } final String name = f.getName(); if (!success) { // Workaround for #2410. STAT only returns ls of directory itself // Workaround for #2434. STAT of symbolic link directory only lists the directory itself. if (this.getAbsolute().equals(name)) { log.warn(String.format("Skip %s", f.getName())); continue; } if (name.contains(String.valueOf(DELIMITER))) { if (!name.startsWith(this.getAbsolute() + Path.DELIMITER)) { // Workaround for #2434. log.warn("Skip listing entry with delimiter:" + name); continue; } } } success = true; if (name.equals(".") || name.equals("..")) { if (log.isDebugEnabled()) { log.debug(String.format("Skip %s", f.getName())); } continue; } final Path parsed = new FTPPath(this.getSession(), this.getAbsolute(), StringUtils.removeStart(name, this.getAbsolute() + Path.DELIMITER), f.getType() == FTPFile.DIRECTORY_TYPE ? DIRECTORY_TYPE : FILE_TYPE); parsed.setParent(this); switch (f.getType()) { case FTPFile.SYMBOLIC_LINK_TYPE: parsed.setSymlinkTarget(f.getLink()); parsed.attributes().setType(SYMBOLIC_LINK_TYPE | FILE_TYPE); break; } if (parsed.attributes().isFile()) { parsed.attributes().setSize(f.getSize()); } parsed.attributes().setOwner(f.getUser()); parsed.attributes().setGroup(f.getGroup()); if (this.getSession().isPermissionSupported(parser)) { parsed.attributes() .setPermission( new Permission(new boolean[][] { { f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION), f.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION), f.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION) }, { f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION), f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION), f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION) }, { f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION), f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION), f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION) } })); } final Calendar timestamp = f.getTimestamp(); if (timestamp != null) { parsed.attributes().setModificationDate(timestamp.getTimeInMillis()); } children.add(parsed); } return success; }
From source file:com.funambol.foundation.util.MediaUtils.java
/** * The dates in the EXIF have the format yyyy:MM:dd HH:mm:ss that should * be converted in the UTC format. Since the exif specification does not * declare that this is a date in local time, no timezone will be applied * during convertion in UTC format./*from w w w. j a va 2 s .c om*/ * * @param date the exif string date to convert * @return the date in UTC format (yyyyMMdd'T'HHmmss'Z') or null */ private String fixExifDate(String tagValueDesc) { try { tagValueDesc = StringUtils.removeStart(tagValueDesc, "'"); tagValueDesc = StringUtils.removeEnd(tagValueDesc, "'"); return TimeUtils.convertDateFromTo(tagValueDesc, TimeUtils.PATTERN_EXIF_DATE, TimeUtils.PATTERN_UTC); } catch (ParseException e) { // don't set the creation date of the FDO } return null; }