Example usage for org.apache.commons.validator.routines UrlValidator UrlValidator

List of usage examples for org.apache.commons.validator.routines UrlValidator UrlValidator

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines UrlValidator UrlValidator.

Prototype

public UrlValidator(long options) 

Source Link

Document

Initialize a UrlValidator with the given validation options.

Usage

From source file:org.wattdepot.client.http.api.collector.MultiThreadedCollector.java

/**
 * @throws BadSensorUriException if the Sensor's URI isn't valid.
 * @throws IdNotFoundException if there is a problem with the Collector
 *         Process Definition./*from  w w  w  . ja v a 2s  .  c o  m*/
 */
private void validate() throws BadSensorUriException, IdNotFoundException {
    Sensor s = client.getSensor(definition.getSensorId());
    String[] schemes = { "http", "https" };
    UrlValidator urlValidator = new UrlValidator(schemes);
    if (!urlValidator.isValid(s.getUri())) {
        throw new BadSensorUriException(s.getUri() + " is not a valid URI.");
    }
}

From source file:org.wso2.developerstudio.eclipse.artifact.axis2.utils.WSDL2Utils.java

/**
* get WSDL version from WSDL file//from   w  ww  . ja  va 2  s  . c o m
* @param wsdlUrl
* @return
* @throws Exception
*/
public static int getWSDLVersion(String wsdlUrl) throws Exception {
    InputStream stream = null;
    if (new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS).isValid(wsdlUrl)) {
        stream = (new URL(wsdlUrl)).openStream();
    } else {
        stream = new FileInputStream(wsdlUrl);
    }
    OMElement documentElement = new StAXOMBuilder(stream).getDocumentElement();
    String localName = documentElement.getLocalName();
    if (localName.equals("definitions")) {
        return WSDL_VERSION_11;
    } else if (localName.equals("description")) {
        return WSDL_VERSION_20;
    }
    return 0;
}

From source file:org.wso2.developerstudio.eclipse.artifact.axis2serviceclient.ui.wizard.Axis2ClientConfigurationPage.java

/**
 * populate the service and the port from the WSDL this needs to be public
 * since the WSDLselection page may call this
 *//* ww w.ja  v a 2  s  .c  om*/
public void populateParamsFromWSDL() {
    try {
        String lname = model.getWsdlURI();
        int wsdlVersion = WSDL2Utils.getWSDLVersion(lname);
        if (wsdlVersion == WSDL2Utils.WSDL_VERSION_11) {
            isWSDL20 = false;
            if (!"".equals(lname.trim())) {
                if (reader == null) {
                    if (new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS).isValid(lname)) {
                        reader = WSDLUtils.readWSDL(new URI(lname).toURL());
                    } else {
                        reader = WSDLUtils.readWSDL((new File(lname)).toURI().toURL());
                    }
                }

                this.serviceQNameList = WSDLUtils.getServiceList(reader);
                if (!serviceQNameList.isEmpty()) {
                    serviceNameCombo.removeAll();
                    for (int i = 0; i < serviceQNameList.size(); i++) {
                        // add the local part of the
                        QName serviceQnameInstance = serviceQNameList.get(0);
                        serviceNameCombo.add(serviceQnameInstance.getLocalPart());
                    }
                    ;
                    // select the first one as the default
                    serviceNameCombo.select(0);

                    // load the ports
                    loadPortNames();

                } else {
                    // service name list being empty means we are switching to
                    // the interface mode
                    if (serviceNameCombo != null)
                        serviceNameCombo.removeAll();
                    if (portNameCombo != null)
                        portNameCombo.removeAll();

                }

                populatePackageName();
                loadNamespaces(WSDLUtils.getDefinitionNamespaceMap(reader));
            }
        } else if (wsdlVersion == WSDL2Utils.WSDL_VERSION_20) {
            isWSDL20 = true;
            populateParamsFromWSDL2(lname);
        }
        status = Status.OK_STATUS;
    } catch (Exception e) {
        status = StatusUtils
                .errorStatus(NLS.bind("Invalid wsdl file", new String[] { e.getLocalizedMessage() }), e);
    }
}

From source file:org.wso2.developerstudio.eclipse.artifact.axis2serviceclient.ui.wizard.Axis2SelectWSDLPage.java

public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);/*from  w w w. j a  v a 2  s.  co  m*/

    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setBounds(10, 10, 108, 17);
    lblNewLabel.setText("Select WSDL ");

    txtBrowseWorkspace = new Text(container, SWT.BORDER);
    txtBrowseWorkspace.setBounds(164, 49, 366, 27);

    btnBrowseWorkspace = new Button(container, SWT.NONE);
    btnBrowseWorkspace.setText("Browse...");
    btnBrowseWorkspace.setBounds(536, 45, 101, 35);

    if (txtBrowseWorkspace.getText() != null && !txtBrowseWorkspace.getText().equals("")) {
        btnBrowseWorkspace.setEnabled(false);

    } else {
        btnBrowseWorkspace.setEnabled(true);
    }

    btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            dialog = new ElementTreeSelectionDialog(btnBrowseWorkspace.getShell(), new WorkbenchLabelProvider(),
                    new BaseWorkbenchContentProvider());
            dialog.setTitle("Tree Selection");
            dialog.setMessage("Select the elements from the tree:");
            dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
            dialog.addFilter(new ViewerFilter() {

                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    if (element instanceof IProject) {
                        return true;
                    }
                    if (element instanceof IFolder) {
                        return true;
                    }
                    if (element instanceof IFile) {
                        IFile file = (IFile) element;
                        if ("wsdl".equals(file.getFileExtension())) {
                            return true;
                        }
                    }
                    return false;

                }
            });

            if (dialog.open() == Window.OK) {
                if (dialog.getFirstResult() instanceof IFile) {
                    IFile file = (IFile) dialog.getFirstResult();

                    if (file.exists()) {
                        wsdlFile = new File(file.getRawLocation().toString());
                    }

                    if (wsdlFile != null && wsdlFile.exists()) {
                        txtBrowseWorkspace.setText(wsdlFile.getName());
                        model.setWsdlURI(file.getRawLocation().toString());
                        setPageComplete(true);
                    }
                } else {
                    txtBrowseWorkspace.setText("");
                    wsdlFile = null;
                    model.setWsdlURI(null);

                    setPageComplete(false);
                }
            }
        }
    });

    Button btnWorkspace = new Button(container, SWT.RADIO);
    btnWorkspace.setText("Browse workspace");
    btnWorkspace.setBounds(10, 53, 152, 20);
    btnWorkspace.setSelection(true);
    setOptionType(OPTION_IMPORT_WS);
    btnWorkspace.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_IMPORT_WS);
            btnBrowseWorkspace.setEnabled(true);
            txtBrowseWorkspace.setText("");
            txtBrowseWorkspace.setEnabled(true);
            btnBrowseFileSystem.setEnabled(false);
            /*if (model.getWsdlURI() != null
                  && !model.getWsdlURI().equals("")) {
               text.setText(model.getWsdlURI());
               wsdlFile = new File(model.getWsdlURI());
               setPageComplete(true);
            } else {
               text.setText("");
               wsdlFile = null;
               setPageComplete(false);
            }*/
            // text_1.setText("");
            txtBrowseFileSystem.setEnabled(false);
            txtOnlineWSDLUri.setText("");
            txtOnlineWSDLUri.setEnabled(false);

            wsdlFile = null;
            model.setWsdlURI(null);

            setPageComplete(false);
        }
    });

    Button btnFilySystem = new Button(container, SWT.RADIO);
    btnFilySystem.setText("Browse file system");
    btnFilySystem.setBounds(10, 96, 152, 20);
    btnFilySystem.setSelection(false);

    txtBrowseFileSystem = new Text(container, SWT.BORDER);
    txtBrowseFileSystem.setBounds(164, 92, 366, 27);
    txtBrowseFileSystem.setEnabled(false);

    btnFilySystem.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_IMPORT_FS);
            btnBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setText("");
            txtBrowseWorkspace.setEnabled(false);
            btnBrowseFileSystem.setEnabled(true);
            txtBrowseFileSystem.setText("");
            txtBrowseFileSystem.setEnabled(true);
            setPageComplete(false);
            wsdlFile = null;
            model.setWsdlURI(null);

            txtOnlineWSDLUri.setText("");
            txtOnlineWSDLUri.setEnabled(false);
        }
    });

    btnBrowseFileSystem = new Button(container, SWT.NONE);
    btnBrowseFileSystem.setText("Browse...");
    btnBrowseFileSystem.setBounds(536, 86, 101, 35);
    btnBrowseFileSystem.setEnabled(false);
    btnBrowseFileSystem.addSelectionListener(new SelectionAdapter() {
        // TODO put this code in a utililty class
        public void widgetSelected(SelectionEvent e) {
            String fileName = null;
            FileDialog dlg = new FileDialog(getShell());
            dlg.setFilterExtensions(new String[] { "*.wsdl" });
            boolean done = false;

            while (!done) {
                // Open the File Dialog
                fileName = dlg.open();
                if (fileName == null) {
                    // User has cancelled, so quit and return
                    done = true;
                } else {
                    // User has selected a file; see if it already exists
                    wsdlFile = new File(fileName);
                    if (wsdlFile.exists()) {
                        // If they click Yes, we're done and we drop out. If
                        // they click No, we redisplay the File Dialog
                        done = true;
                        txtBrowseFileSystem.setText(fileName);
                        model.setWsdlURI(fileName);
                        setPageComplete(true);
                    } else {
                        // File does not exist, so drop out
                        done = false;
                    }
                }
            }
        }
    });

    Button btnOnlineWSDL = new Button(container, SWT.RADIO);
    btnOnlineWSDL.setText("WSDL URI");
    btnOnlineWSDL.setBounds(10, 139, 148, 20);
    btnOnlineWSDL.setSelection(false);

    txtOnlineWSDLUri = new Text(container, SWT.BORDER);
    txtOnlineWSDLUri.setBounds(164, 135, 366, 27);
    txtOnlineWSDLUri.setEnabled(false);

    btnOnlineWSDL.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_SOURCE_URL);
            btnBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setText("");
            btnBrowseFileSystem.setEnabled(false);
            txtBrowseFileSystem.setText("");
            txtBrowseFileSystem.setEnabled(false);

            txtOnlineWSDLUri.setEnabled(true);
            txtOnlineWSDLUri.setText("");

            wsdlFile = null;
            model.setWsdlURI(null);

            setPageComplete(false);
        }
    });

    txtBrowseWorkspace.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
            if (txtBrowseWorkspace.getText() != null && !txtBrowseWorkspace.getText().equals("")) {
                String fileName = txtBrowseWorkspace.getText();
                wsdlFile = new File(fileName);
                if (wsdlFile.exists()) {
                    model.setWsdlURI(fileName);
                    setPageComplete(true);
                } else {
                    wsdlFile = null;
                    model.setWsdlURI(null);
                    setPageComplete(false);
                }
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    txtBrowseFileSystem.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
            if (txtBrowseFileSystem.getText() != null && !txtBrowseFileSystem.getText().equals("")) {
                String fileName = txtBrowseFileSystem.getText();
                wsdlFile = new File(fileName);
                if (wsdlFile.exists()) {
                    model.setWsdlURI(fileName);
                    setPageComplete(true);
                } else {
                    wsdlFile = null;
                    model.setWsdlURI(null);
                    setPageComplete(false);
                }
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    txtOnlineWSDLUri.addListener(SWT.Modify, new Listener() {
        UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);

        public void handleEvent(Event arg0) {
            if (urlValidator.isValid(txtOnlineWSDLUri.getText())) {
                model.setWsdlURI(txtOnlineWSDLUri.getText());
                setPageComplete(true);
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    if (((getOptionType() == OPTION_IMPORT_WS) && txtBrowseWorkspace.getText() != null
            && !txtBrowseWorkspace.getText().equals(""))
            || ((getOptionType() == OPTION_IMPORT_FS) && txtBrowseFileSystem.getText() != null
                    && !txtBrowseFileSystem.getText().equals(""))
            || ((getOptionType() == OPTION_SOURCE_URL) && txtOnlineWSDLUri.getText() != null
                    && !txtOnlineWSDLUri.getText().equals(""))) {
        setPageComplete(true);
    }
}

From source file:org.wso2.developerstudio.eclipse.libraries.utils.WSDL2Utils.java

/**
* get WSDL version from WSDL file//w  w  w  .j a va2  s  .c  om
* @param wsdlUrl
* @return
* @throws Exception
*/
public static int getWSDLVersion(String wsdlUrl) throws Exception {
    InputStream stream = null;
    if (new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS).isValid(wsdlUrl)) {
        stream = (new URL(wsdlUrl)).openStream();
    } else {
        stream = new FileInputStream(wsdlUrl);
    }
    OMElement documentElement = new StAXOMBuilder(stream).getDocumentElement();
    String localName = documentElement.getLocalName();
    stream.close();
    if (localName.equals("definitions")) {
        return WSDL_VERSION_11;
    } else if (localName.equals("description")) {
        return WSDL_VERSION_20;
    }
    return 0;
}

From source file:org.wso2.developerstudio.eclipse.platform.ui.validator.CommonFieldValidator.java

public static void isValidUrl(String url, String field) throws FieldValidationException {
    if (url.contains(":") && !url.startsWith(":")) {
        if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("ftp:")) {
            UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
            if (!urlValidator.isValid(url)) {
                if (!isParameter(url, true)) {
                    throw new FieldValidationException(field + ": Invalid URL provided");
                }/*from   w  ww.  j  av  a2  s  .  co  m*/

            }
        }
    } else {
        if (url.startsWith(":")) {
            throw new FieldValidationException(field + ": Invalid URL provided");
        } else {
            if (!isParameter(url, false)) {
                throw new FieldValidationException(field + ": Invalid URL provided");
            }
        }
    }
}

From source file:org.wso2.developerstudio.eclipse.qos.project.ui.wizard.SelectWSDLPage.java

public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);/*from  ww  w  .j  a  v a  2 s  .  c o  m*/

    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setBounds(10, 10, 108, 17);
    lblNewLabel.setText("Select WSDL ");

    txtBrowseWorkspace = new Text(container, SWT.BORDER);
    txtBrowseWorkspace.setBounds(164, 49, 366, 27);

    btnBrowseWorkspace = new Button(container, SWT.NONE);
    btnBrowseWorkspace.setText("Browse...");
    btnBrowseWorkspace.setBounds(536, 45, 101, 35);

    if (txtBrowseWorkspace.getText() != null && !txtBrowseWorkspace.getText().equals("")) {
        btnBrowseWorkspace.setEnabled(false);

    } else {
        btnBrowseWorkspace.setEnabled(true);
    }

    btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            dialog = new ElementTreeSelectionDialog(btnBrowseWorkspace.getShell(), new WorkbenchLabelProvider(),
                    new BaseWorkbenchContentProvider());
            dialog.setTitle("Tree Selection");
            dialog.setMessage("Select the elements from the tree:");
            dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
            dialog.addFilter(new ViewerFilter() {

                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    if (element instanceof IProject) {
                        return true;
                    }
                    if (element instanceof IFolder) {
                        return true;
                    }
                    if (element instanceof IFile) {
                        IFile file = (IFile) element;
                        if ("wsdl".equals(file.getFileExtension())) {
                            return true;
                        }
                    }
                    return false;

                }
            });

            if (dialog.open() == Window.OK) {
                if (dialog.getFirstResult() instanceof IFile) {
                    IFile file = (IFile) dialog.getFirstResult();

                    if (file.exists()) {
                        wsdlFile = new File(file.getRawLocation().toString());
                    }

                    if (wsdlFile != null && wsdlFile.exists()) {
                        txtBrowseWorkspace.setText(wsdlFile.getName());
                        model.setWsdlURI(file.getRawLocation().toString());
                        setPageComplete(true);
                    }
                } else {
                    txtBrowseWorkspace.setText("");
                    wsdlFile = null;
                    model.setWsdlURI(null);

                    setPageComplete(false);
                }
            }
        }
    });

    Button btnWorkspace = new Button(container, SWT.RADIO);
    btnWorkspace.setText("Browse workspace");
    btnWorkspace.setBounds(10, 53, 152, 20);
    btnWorkspace.setSelection(true);
    setOptionType(OPTION_IMPORT_WS);
    btnWorkspace.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_IMPORT_WS);
            btnBrowseWorkspace.setEnabled(true);
            txtBrowseWorkspace.setText("");
            txtBrowseWorkspace.setEnabled(true);
            btnBrowseFileSystem.setEnabled(false);
            /*if (model.getWsdlURI() != null
                  && !model.getWsdlURI().equals("")) {
               text.setText(model.getWsdlURI());
               wsdlFile = new File(model.getWsdlURI());
               setPageComplete(true);
            } else {
               text.setText("");
               wsdlFile = null;
               setPageComplete(false);
            }*/
            // text_1.setText("");
            txtBrowseFileSystem.setEnabled(false);
            txtOnlineWSDLUri.setText("");
            txtOnlineWSDLUri.setEnabled(false);

            wsdlFile = null;
            model.setWsdlURI(null);

            setPageComplete(false);
        }
    });

    Button btnFilySystem = new Button(container, SWT.RADIO);
    btnFilySystem.setText("Browse file system");
    btnFilySystem.setBounds(10, 96, 152, 20);
    btnFilySystem.setSelection(false);

    txtBrowseFileSystem = new Text(container, SWT.BORDER);
    txtBrowseFileSystem.setBounds(164, 92, 366, 27);
    txtBrowseFileSystem.setEnabled(false);

    btnFilySystem.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_IMPORT_FS);
            btnBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setText("");
            txtBrowseWorkspace.setEnabled(false);
            btnBrowseFileSystem.setEnabled(true);
            txtBrowseFileSystem.setText("");
            txtBrowseFileSystem.setEnabled(true);
            setPageComplete(false);
            wsdlFile = null;
            model.setWsdlURI(null);

            txtOnlineWSDLUri.setText("");
            txtOnlineWSDLUri.setEnabled(false);
        }
    });

    btnBrowseFileSystem = new Button(container, SWT.NONE);
    btnBrowseFileSystem.setText("Browse...");
    btnBrowseFileSystem.setBounds(536, 86, 101, 35);
    btnBrowseFileSystem.setEnabled(false);
    btnBrowseFileSystem.addSelectionListener(new SelectionAdapter() {
        // TODO put this code in a utililty class
        public void widgetSelected(SelectionEvent e) {
            String fileName = null;
            FileDialog dlg = new FileDialog(getShell());
            dlg.setFilterExtensions(new String[] { "*.wsdl" });
            boolean done = false;

            while (!done) {
                // Open the File Dialog
                fileName = dlg.open();
                if (fileName == null) {
                    // User has cancelled, so quit and return
                    done = true;
                } else {
                    // User has selected a file; see if it already exists
                    wsdlFile = new File(fileName);
                    if (wsdlFile.exists()) {
                        // If they click Yes, we're done and we drop out. If
                        // they click No, we redisplay the File Dialog
                        done = true;
                        txtBrowseFileSystem.setText(fileName);
                        model.setWsdlURI(fileName);
                        setPageComplete(true);
                    } else {
                        // File does not exist, so drop out
                        done = false;
                    }
                }
            }
        }
    });

    Button btnOnlineWSDL = new Button(container, SWT.RADIO);
    btnOnlineWSDL.setText("WSDL URI");
    btnOnlineWSDL.setBounds(10, 139, 148, 20);
    btnOnlineWSDL.setSelection(false);

    txtOnlineWSDLUri = new Text(container, SWT.BORDER);
    txtOnlineWSDLUri.setBounds(164, 135, 366, 27);
    txtOnlineWSDLUri.setEnabled(false);

    btnOnlineWSDL.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setOptionType(OPTION_SOURCE_URL);
            btnBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setEnabled(false);
            txtBrowseWorkspace.setText("");
            btnBrowseFileSystem.setEnabled(false);
            txtBrowseFileSystem.setText("");
            txtBrowseFileSystem.setEnabled(false);

            txtOnlineWSDLUri.setEnabled(true);
            txtOnlineWSDLUri.setText("");

            wsdlFile = null;
            model.setWsdlURI(null);

            setPageComplete(false);
        }
    });

    txtBrowseWorkspace.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
            if (txtBrowseWorkspace.getText() != null && !txtBrowseWorkspace.getText().equals("")) {
                String fileName = txtBrowseWorkspace.getText();
                wsdlFile = new File(fileName);
                if (wsdlFile.exists()) {
                    model.setWsdlURI(fileName);
                    setPageComplete(true);
                } else {
                    wsdlFile = null;
                    model.setWsdlURI(null);
                    setPageComplete(false);
                }
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    txtBrowseFileSystem.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
            if (txtBrowseFileSystem.getText() != null && !txtBrowseFileSystem.getText().equals("")) {
                String fileName = txtBrowseFileSystem.getText();
                wsdlFile = new File(fileName);
                if (wsdlFile.exists()) {
                    model.setWsdlURI(fileName);
                    setPageComplete(true);
                } else {
                    wsdlFile = null;
                    model.setWsdlURI(null);
                    setPageComplete(false);
                }
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    txtOnlineWSDLUri.addListener(SWT.Modify, new Listener() {
        UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);

        public void handleEvent(Event arg0) {
            if (urlValidator.isValid(txtOnlineWSDLUri.getText())) {
                model.setWsdlURI(txtOnlineWSDLUri.getText());
                setPageComplete(true);
            } else {
                wsdlFile = null;
                model.setWsdlURI(null);
                setPageComplete(false);
            }
        }
    });

    if (((getOptionType() == OPTION_IMPORT_WS) && txtBrowseWorkspace.getText() != null
            && !txtBrowseWorkspace.getText().equals(""))
            || ((getOptionType() == OPTION_IMPORT_FS) && txtBrowseFileSystem.getText() != null
                    && !txtBrowseFileSystem.getText().equals(""))
            || ((getOptionType() == OPTION_SOURCE_URL) && txtOnlineWSDLUri.getText() != null
                    && !txtOnlineWSDLUri.getText().equals(""))) {
        setPageComplete(true);
    } else {
        setPageComplete(false);
    }
}

From source file:uk.co.develop4.security.utils.decoders.DecoderUtils.java

public static URL isUrl(String url) {
    String[] schemes = { "http", "https" };
    UrlValidator urlValidator = new UrlValidator(schemes);
    if (urlValidator.isValid(url)) {
        try {//from  w w w  . ja  v  a2 s.c  o  m
            URL u = new URL(url);
            return u;
        } catch (MalformedURLException ex) {
            // -- System.out.println("url is invalid: \"" + url + "\"");
        }
    } else {
        // -- System.out.println("url is invalid: \"" + url + "\"");
    }
    return null;
}

From source file:url.DomainPathFile.java

public void createDomainPathFile(String inputFile, String domainFile, String domainPathFile) {
    BufferedReader br = null;/*from  w  w  w .java  2s.  co m*/
    PrintWriter domainwriter = null, pathwriter = null;
    String line = "";

    UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES);
    try {

        br = new BufferedReader(new FileReader(inputFile));
        domainwriter = new PrintWriter(domainFile, "UTF-8");
        pathwriter = new PrintWriter(domainPathFile, "UTF-8");

        while ((line = br.readLine()) != null) {

            if (defaultValidator.isValid(line)) {
                java.net.URL host_path = new java.net.URL(line);
                String host = host_path.getHost();
                String path = host_path.getPath();
                domainwriter.println(host);
                pathwriter.println(host + path);
            }

        }

        domainwriter.close();
        pathwriter.close();
        System.out.println("Write to file-->" + domainFile + " File: " + domainPathFile);
    } catch (Exception e) {
        System.out.println(e);
    }
    System.out.println("Done");
}

From source file:url.DomainPathSeperation.java

public void getUrlDomainPath(String inputFile, String domainFile, String domainPathFile) {
    BufferedReader br = null;/*from w  w w.  j a  v a2  s .  c  om*/
    PrintWriter domainwriter = null, pathwriter = null;
    String line = "";

    UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES);
    try {

        br = new BufferedReader(new FileReader(inputFile));
        domainwriter = new PrintWriter(domainFile, "UTF-8");
        pathwriter = new PrintWriter(domainPathFile, "UTF-8");

        while ((line = br.readLine()) != null) {

            if (defaultValidator.isValid(line)) {
                URL host_path = new URL(line);
                String host = host_path.getHost();
                String path = host_path.getPath();
                domainwriter.println(host);
                pathwriter.println(host + path);
            }

        }

        domainwriter.close();
        pathwriter.close();
        System.out.println("Write to file-->" + domainFile + "domain+path File: " + domainPathFile);
    } catch (Exception e) {
        System.out.println(e);
    }
    System.out.println("Done");
}