List of usage examples for org.apache.commons.lang3 StringUtils endsWith
public static boolean endsWith(final CharSequence str, final CharSequence suffix)
Check if a CharSequence ends with a specified suffix.
null s are handled without exceptions.
From source file:com.dominion.salud.pedicom.configuration.PEDICOMInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.scan("com.dominion.salud.pedicom.configuration"); ctx.setServletContext(servletContext); PEDICOMConstantes._NOMBRE_CONFIG = servletContext.getInitParameter("NOMBRE_CONFIG"); System.setProperty("pedicom.conf.home", findConfigurationAndLogger(ctx)); ctx.refresh();//from w w w.j a v a 2 s .c om // Spring Dispatcher ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dispatcher.setInitParameter("contextClass", ctx.getClass().getName()); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); dispatcher.addMapping("/controller/*"); servletContext.addListener(new ContextLoaderListener(ctx)); // Configuracion general PEDICOMConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator) ? servletContext.getRealPath("/") : servletContext.getRealPath("/") + File.separator; PEDICOMConstantes._CONF_HOME = ctx.getEnvironment().getProperty("pedicom.conf.home"); PEDICOMConstantes._TEMP = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "temp" + File.separator; PEDICOMConstantes._VERSION = ResourceBundle.getBundle("version").getString("version"); PEDICOMConstantes._LOGS = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs"; PEDICOMConstantes._CONTEXT_NAME = servletContext.getServletContextName(); PEDICOMConstantes._CONTEXT_PATH = servletContext.getContextPath(); PEDICOMConstantes._CONTEXT_SERVER = servletContext.getServerInfo(); PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("pedicom.enable.technical.information")) ? Boolean.parseBoolean(ResourceBundle.getBundle("application") .getString("pedicom.enable.technical.information")) : false; PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = StringUtils .isNotBlank(ResourceBundle.getBundle("application").getString("pedicom_scheduler_send_mail_cron")) ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application") .getString("pedicom_scheduler_send_mail_cron") : PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON; PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("pedicom_scheduler_update_existencias_cron")) ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application") .getString("pedicom_scheduler_update_existencias_cron") : PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON; // Configuracion de LOGS DEL MODULO if (StringUtils.isBlank( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())) { ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")) .setFile(PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs" + File.separator + "mpr-desktop.log"); } PEDICOMConstantes._LOGS = new File( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile()) .getParent(); Environment env = ctx.getEnvironment(); XmlUnmarshaler xml = new XmlUnmarshaler(); Datos datos = (Datos) xml.unmarshal(); logger.info(" Datasources"); for (Datasources dat : datos.getDatasources()) { if (dat.getNombreDatasource().equals("Central")) { PEDICOMConstantes.EXISTENCIAS_EXISTE = true; } logger.info(" codCentro: " + dat.getCodCentro()); logger.info(" nombreDatasource: " + dat.getNombreDatasource()); logger.info(" driverClassName: " + dat.getDriverClassName()); logger.info(" jndi: " + dat.getJndi()); logger.info(" url: " + dat.getUrl()); logger.info(" username: " + dat.getUsername()); logger.info(" usernameEmail: " + dat.getUsernameEmail()); logger.info(" passwordEmail: " + dat.getPasswordEmail()); logger.info(" from: " + dat.getFrom()); logger.info(" host: " + dat.getHost()); logger.info(" port: " + dat.getPort()); logger.info(" TLS: " + dat.getTLS()); logger.info(" SSL: " + dat.getSSL()); } // ctx.refresh(); // PropertyConfigurator.configureAndWatch("log4j"); logger.info(" Configuracion general del sistema"); logger.info(" pedicom.home: " + PEDICOMConstantes._HOME); logger.info(" pedicom.conf.home: " + PEDICOMConstantes._CONF_HOME); logger.info(" pedicom.temp: " + PEDICOMConstantes._TEMP); logger.info(" pedicom.version: " + PEDICOMConstantes._VERSION); logger.info(" pedicom.logs: " + PEDICOMConstantes._LOGS); logger.info(" pedicom.context.name: " + PEDICOMConstantes._CONTEXT_NAME); logger.info(" pedicom.context.path: " + PEDICOMConstantes._CONTEXT_PATH); logger.info(" pedicom.context.server: " + PEDICOMConstantes._CONTEXT_SERVER); logger.info(" Parametrizacion del sistema"); logger.info(" pedicom.enable.technical.information: " + PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION); logger.info( " pedicom_scheduler_send_mail_cron: " + PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON); logger.info(" pedicom_scheduler_update_existencias_cron: " + PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON); logger.info(" Modulo configurado correctamente"); logger.info("MODULO INICIADO CORRECTAMENTE"); }
From source file:com.cognifide.qa.bb.utils.YamlReader.java
private static InputStream readFileFromTestResource(String path) { String fullPath = StringUtils.endsWith(path, YAML) ? path : path + YAML; return YamlReader.class.getClassLoader().getResourceAsStream(fullPath); }
From source file:eu.openanalytics.rsb.config.BootstrapConfigurationServletContextListener.java
private void copyUiFragments(final ServletContext servletContext) { final File fragmentsSourceDirectory = new File(ConfigurationFactory.RSB_CONFIGURATION_DIRECTORY, "fragments"); if (!fragmentsSourceDirectory.isDirectory()) { return;/* ww w. j av a2s . c om*/ } final String fragmentsDestinationPath = servletContext.getRealPath("/fragments"); if (StringUtils.isBlank(fragmentsDestinationPath)) { return; } final File fragmentsDestinationDirectory = new File(fragmentsDestinationPath); final File[] sourceFragments = fragmentsSourceDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { return StringUtils.endsWith(name, ".html"); } }); if (sourceFragments == null) { return; } for (final File sourceFragment : sourceFragments) { final File destinationFragment = new File(fragmentsDestinationDirectory, sourceFragment.getName()); try { FileCopyUtils.copy(sourceFragment, destinationFragment); LOGGER.info("Installed UI fragment: " + sourceFragment.getName()); } catch (final IOException ioe) { LOGGER.error("Failed to copy UI fragment from: " + sourceFragment + " to: " + destinationFragment, ioe); } } }
From source file:com.frank.search.solr.server.support.SolrClientUtils.java
/** * Append core to given baseUrl/*from w w w .j ava 2s . co m*/ * * @param baseUrl * @param core * @return */ public static String appendCoreToBaseUrl(String baseUrl, String core) { Assert.notNull(baseUrl); if (!org.springframework.util.StringUtils.hasText(core)) { return baseUrl; } String url = baseUrl; if (!StringUtils.endsWith(baseUrl, SLASH)) { url = url + SLASH; } url = url + core; return url; }
From source file:com.aboutdata.web.controller.member.SettingsController.java
/** * post ?/*from www .j a v a2 s . c o m*/ * * @param email * @param password * @param confirmPassword * @param model * @return */ @RequestMapping(value = "/account", method = RequestMethod.POST) public String updateAccount(String email, String password, String confirmPassword, ModelMap model) { Member member = memberService.getCurrent(); if (!StringUtils.isEmpty(email)) { member.setEmail(email); } if (!StringUtils.isEmpty(password) && StringUtils.endsWith(password, confirmPassword)) { member.setPassword(SecurityPasswordUtils.getPassphrase(member.getSalt(), password)); } else { logger.debug("update password({}) not equals comfirmPassword({}) ", password, confirmPassword); } memberService.update(member); model.addAttribute("member", member); return "redirect:/member/settings/account"; }
From source file:com.cognifide.aet.runner.distribution.RunnerMessageListener.java
private void processTestSuite(Message wrapperMessage, TaskMessage message) { Suite suite = (Suite) message.getData(); try {// w ww . j a v a 2 s . c o m boolean isMaintenanceMessage = StringUtils.endsWith(wrapperMessage.getJMSDestination().toString(), maintenanceDestinationName); testRunProcessor.process(suite, wrapperMessage.getJMSReplyTo(), isMaintenanceMessage); } catch (JMSException e) { LOGGER.error("Error wile processing RUN {}: ", suite.getCorrelationId(), e); sendFatalMessage(wrapperMessage, e.getMessage()); } catch (StorageException e) { LOGGER.error("Failed to process test suite", e); sendFatalMessage(wrapperMessage, e.getMessage()); } }
From source file:com.adguard.filter.rules.ContentType.java
/** * Detects content type using request url * * @param url Url//ww w . j a v a 2 s . c o m * @return Content type detected */ public static ContentType detectContentType(URL url) { String path = url.getPath(); for (Map.Entry<String, ContentType> entry : FILE_EXTENSION_CONTENT_TYPE.entrySet()) { if (StringUtils.endsWith(path, entry.getKey())) { return entry.getValue(); } } return ContentType.OTHER; }
From source file:ch.cyberduck.core.openstack.SwiftObjectListService.java
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try {//from w w w .ja va 2 s . c o m final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; do { final Path container = containerService.getContainer(directory); list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for (StorageObject object : list) { final PathAttributes attributes = new PathAttributes(); attributes.setOwner(container.attributes().getOwner()); attributes.setRegion(container.attributes().getRegion()); if (StringUtils.isNotBlank(object.getMd5sum())) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.parse(object.getMd5sum())); } attributes.setSize(object.getSize()); final String lastModified = object.getLastModified(); if (lastModified != null) { try { attributes.setModificationDate(dateParser.parse(lastModified).getTime()); } catch (InvalidDateException e) { log.warn(String.format("%s is not ISO 8601 format %s", lastModified, e.getMessage())); } } final EnumSet<AbstractPath.Type> types = "application/directory".equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if (StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if (children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attributes))) { // There is already a real placeholder file with application/directory MIME type. Only // add virtual directory if the placeholder object is missing continue; } } children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attributes)); marker = object.getName(); } listener.chunk(directory, children); } while (list.size() == limit); return children; } catch (GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch (IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } }
From source file:com.nridge.core.base.field.data.DataBeanBag.java
private static DataField reflectMethod(Object anObject, BeanField aBeanField, Method aMethod) throws NSException, IllegalAccessException, InvocationTargetException { String fieldValue;//from www . j ava 2 s. c o m DataField dataField; com.nridge.core.base.field.Field.Type fieldType; if (anObject == null) throw new NSException("Object is null"); String fieldName = aBeanField.name(); if (StringUtils.isEmpty(fieldName)) throw new NSException("Field name not identified in annotation."); String fieldTitle = aBeanField.title(); if (StringUtils.isEmpty(fieldTitle)) fieldTitle = com.nridge.core.base.field.Field.nameToTitle(fieldName); String fieldTypeString = aBeanField.type(); if (StringUtils.isEmpty(fieldTypeString)) { Class<?> methodReturnType = aMethod.getReturnType(); if ((StringUtils.endsWith(methodReturnType.getName(), "Integer")) || (StringUtils.endsWith(methodReturnType.getName(), "int"))) { fieldType = com.nridge.core.base.field.Field.Type.Integer; fieldValue = aMethod.invoke(anObject).toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } else if ((StringUtils.endsWith(methodReturnType.getName(), "Float")) || (StringUtils.endsWith(methodReturnType.getName(), "float"))) { fieldType = com.nridge.core.base.field.Field.Type.Float; fieldValue = aMethod.invoke(anObject).toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } else if ((StringUtils.endsWith(methodReturnType.getName(), "Double")) || (StringUtils.endsWith(methodReturnType.getName(), "double"))) { fieldType = com.nridge.core.base.field.Field.Type.Double; fieldValue = aMethod.invoke(anObject).toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } else if ((StringUtils.endsWith(methodReturnType.getName(), "Boolean")) || (StringUtils.endsWith(methodReturnType.getName(), "boolean"))) { fieldType = com.nridge.core.base.field.Field.Type.Boolean; fieldValue = aMethod.invoke(anObject).toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } else if (StringUtils.endsWith(methodReturnType.getName(), "Date")) { fieldType = com.nridge.core.base.field.Field.Type.Date; Date fieldDate = (Date) aMethod.invoke(anObject); fieldValue = com.nridge.core.base.field.Field.dateValueFormatted(fieldDate, null); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } else { fieldType = com.nridge.core.base.field.Field.Type.Text; Object methodReturnObject = aMethod.invoke(anObject); if (methodReturnObject instanceof String[]) { String[] fieldValues = (String[]) methodReturnObject; dataField = new DataField(fieldType, fieldName, fieldTitle); dataField.setMultiValueFlag(true); dataField.setValues(fieldValues); } else if (methodReturnObject instanceof Collection) { ArrayList<String> fieldValues = (ArrayList<String>) methodReturnObject; dataField = new DataField(fieldType, fieldName, fieldTitle); dataField.setMultiValueFlag(true); dataField.setValues(fieldValues); } else { fieldValue = aMethod.invoke(anObject).toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } } } else { fieldType = com.nridge.core.base.field.Field.stringToType(fieldTypeString); Object methodReturnObject = aMethod.invoke(anObject); if (methodReturnObject instanceof String[]) { String[] fieldValues = (String[]) methodReturnObject; dataField = new DataField(fieldType, fieldName, fieldTitle); dataField.setMultiValueFlag(true); dataField.setValues(fieldValues); } else if (methodReturnObject instanceof Collection) { ArrayList<String> fieldValues = (ArrayList<String>) methodReturnObject; dataField = new DataField(fieldType, fieldName, fieldTitle); dataField.setMultiValueFlag(true); dataField.setValues(fieldValues); } else { fieldValue = methodReturnObject.toString(); dataField = new DataField(fieldType, fieldName, fieldTitle, fieldValue); } } return dataField; }
From source file:com.nesscomputing.migratory.migration.sql.SqlScript.java
/** * Turns these lines in a series of statements. *//* w ww .j a v a 2s .co m*/ List<SqlStatement> linesToStatements(List<String> lines) { final List<SqlStatement> statements = Lists.newArrayList(); final StringBuilder statementSql = new StringBuilder(); int count = 0; String delimiter = DEFAULT_STATEMENT_DELIMITER; for (final String line : lines) { if (StringUtils.isBlank(line)) { continue; } if (statementSql.length() > 0) { statementSql.append(" "); } statementSql.append(line); final String oldDelimiter = delimiter; delimiter = changeDelimiterIfNecessary(statementSql.toString(), line, delimiter); if (!StringUtils.equals(delimiter, oldDelimiter) && isDelimiterChangeExplicit()) { statementSql.setLength(0); continue; // for } if (StringUtils.endsWith(line, delimiter)) { // Trim off the delimiter at the end. statementSql.setLength(statementSql.length() - delimiter.length()); statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString()))); LOG.debug("Found statement: %s", statementSql); if (!isDelimiterChangeExplicit()) { delimiter = DEFAULT_STATEMENT_DELIMITER; } statementSql.setLength(0); } } // Catch any statements not followed by delimiter. if (statementSql.length() > 0) { statements.add(new SqlStatement(count++, StringUtils.trimToEmpty(statementSql.toString()))); } return statements; }