List of usage examples for org.apache.commons.validator.routines UrlValidator UrlValidator
public UrlValidator(long options)
From source file:com.webcrawler.manager.impl.URLManagerImpl.java
public URLManagerImpl() { urlValidator = new UrlValidator(schemes); }
From source file:com.vmware.identity.openidconnect.common.CommonUtils.java
public static boolean isValidUri(URI uri) { Validate.notNull(uri, "uri"); String[] schemes = { "https" }; UrlValidator urlValidator = new UrlValidator(schemes); return urlValidator.isValid(uri.toString()); }
From source file:com.liferay.ide.project.core.workspace.BundleUrlValidationService.java
@Override protected Status compute() { Status retval = Status.createOkStatus(); BaseLiferayWorkspaceOp op = _op();//from ww w . jav a2s . co m String bundleUrl = op.getBundleUrl().content(); UrlValidator urlValidator = new UrlValidator( UrlValidator.ALLOW_LOCAL_URLS | UrlValidator.ALLOW_ALL_SCHEMES); if ((bundleUrl != null) && !urlValidator.isValid(bundleUrl)) { retval = Status.createWarningStatus("The bundle URL may not be a vaild URL."); } return retval; }
From source file:fr.esrf.icat.manager.core.handlers.NewServerHandler.java
@Execute public void execute(final Shell shell) { boolean notok = true; final UrlValidator validator = new UrlValidator(new String[] { "http", "https" }); while (notok) { InputDialog dlg = new InputDialog(shell, "New ICAT server", "Enter the URL of the new ICAT server\nYou can set either the service, wsdl or server URL", "", new IInputValidator() { @Override/*from w w w . j a v a2 s . c om*/ public String isValid(String newText) { if (null == newText || newText.isEmpty()) { return "Please provide an URL"; } if (!validator.isValid(newText)) { return "Invalid URL"; } return null; } }); if (dlg.open() == Window.OK) { final String s = dlg.getValue(); final Matcher matcher = URL_PATTERN.matcher(s); if (matcher.find()) { final String serverURL = matcher.group(1) + "/"; if (validator.isValid(serverURL)) { ICATDataService.getInstance().addServer(new ICATServer(serverURL)); notok = false; } else { MessageDialog.openError(shell, "Invalid server", serverURL + " appears to be invalid"); } } else { MessageDialog.openError(shell, "Invalid URL", s + " appears to be invalid"); } } else { notok = false; } } }
From source file:it.polimi.modaclouds.monitoring.appleveldc.Config.java
private Config() throws ConfigurationException { validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); ddaIP = getOptionalEnvVar(Env.MODACLOUDS_MONITORING_DDA_ENDPOINT_IP, ddaIP); ddaPort = getOptionalEnvVar(Env.MODACLOUDS_MONITORING_DDA_ENDPOINT_PORT, ddaPort); kbIP = getOptionalEnvVar(Env.MODACLOUDS_KNOWLEDGEBASE_ENDPOINT_IP, kbIP); kbPort = getOptionalEnvVar(Env.MODACLOUDS_KNOWLEDGEBASE_ENDPOINT_PORT, kbPort); kbPath = getOptionalEnvVar(Env.MODACLOUDS_KNOWLEDGEBASE_DATASET_PATH, kbPath); String kbSyncPeriodString = getOptionalEnvVar(Env.MODACLOUDS_KNOWLEDGEBASE_SYNC_PERIOD, Integer.toString(kbSyncPeriod)); String startSyncingWithKBString = getOptionalEnvVar(Env.MODACLOUDS_START_SYNC_WITH_KB, Boolean.toString(startSyncingWithKB)); appId = getMandatoryEnvVar(Env.MODACLOUDS_MONITORED_APP_ID); ddaUrl = "http://" + ddaIP + ":" + ddaPort; kbUrl = "http://" + kbIP + ":" + kbPort + kbPath; if (!validator.isValid(ddaUrl)) throw new ConfigurationException(ddaUrl + " is not a valid URL"); if (!validator.isValid(kbUrl)) throw new ConfigurationException(kbUrl + " is not a valid URL"); try {//from ww w . ja v a2 s. c o m kbSyncPeriod = Integer.parseInt(kbSyncPeriodString); startSyncingWithKB = Boolean.parseBoolean(startSyncingWithKBString); } catch (NumberFormatException e) { throw new ConfigurationException( kbSyncPeriodString + " is not a valid value for " + Env.MODACLOUDS_KNOWLEDGEBASE_SYNC_PERIOD); } }
From source file:checkwebsite.Mainframe.java
public boolean checkURL(String url) { String[] schemes = { "http", "https" }; // DEFAULT schemes = "http", "https", "ftp" UrlValidator urlValidator = new UrlValidator(schemes); return urlValidator.isValid(url); }
From source file:com.alefissak.web.AlefissakListener.java
/** * Verify if the parameter is a valid URL * //from w w w . ja v a2 s . com * @param configUri * @return true if configUri is a valid URL */ private boolean isURL(String configUri) { UrlValidator urlValidator = new UrlValidator(new String[] { "http", "https" }); return urlValidator.isValid(configUri); }
From source file:de.fhg.fokus.odp.portal.managedatasets.validator.EmailOrURLValidator.java
@Override public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if (((String) value).isEmpty()) { throwValidatorException();/*from w w w .java2 s.com*/ } else { String[] schemes = { "http", "https", "ftp", "ftps" }; UrlValidator urlValidator = new UrlValidator(schemes); // UrlValidator urlValidator = new UrlValidator(); if (urlValidator.isValid((String) value)) { return; } else if (EmailValidator.getInstance().isValid((String) value)) { return; } else { throwValidatorException(); } } }
From source file:com.intel.podm.services.detection.filesystem.ServiceListFileRecordsParser.java
private boolean containsValidUrl(String[] recordParts) { UrlValidator urlValidator = new UrlValidator(ALLOW_LOCAL_URLS); return urlValidator.isValid(recordParts[SERVICE_LIST_URL_POSITION]); }
From source file:com.fluxit.camel.component.n4.N4Component.java
private void validateRequiredProperties(N4Endpoint endpoint) throws Exception { // valido que la URI del provider exista if (ObjectHelper.isEmpty(endpoint.getN4EndpointURI())) { throw new IllegalArgumentException("La propiedad n4EndpointURI no puede ser nula"); } else {/*from w ww.java 2 s . com*/ UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); if (!urlValidator.isValid(endpoint.getN4EndpointURI())) { throw new IllegalArgumentException( "La URL del provider no es valida, corregir la propiedad n4EndpointURI"); } } // valido que exista uno y solo un mtodo de transformacin de entrada if (endpoint.getUriMapInput() == null && endpoint.getUriXSLTInput() == null) { LOG.error("No se seteo ningn mtodo de transformacin de entrada"); throw new IllegalArgumentException("Se debe setear un mtodo de transformacion de entrada"); } else if (endpoint.getUriMapInput() != null && endpoint.getUriXSLTInput() != null) { LOG.error("Se setearon ambas transformaciones de entrada, se debe usar solo una"); throw new IllegalArgumentException("Solo puede existir un mtodo de transformacion de entrada"); } if (endpoint.getClassSerialization() != null) { LOG.debug("Instanciando el contexto de JAXB"); JAXBContext jaxbContext = JAXBContext.newInstance(Class.forName(endpoint.getClassSerialization())); endpoint.setJaxbContext(jaxbContext); } }