Example usage for com.liferay.portal.kernel.util Validator isDomain

List of usage examples for com.liferay.portal.kernel.util Validator isDomain

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Validator isDomain.

Prototype

public static boolean isDomain(String domainName) 

Source Link

Document

Returns true if the string is a valid domain name.

Usage

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public void validateRemote(long groupId, String remoteAddress, int remotePort, String remotePathContext,
        boolean secureConnection, long remoteGroupId) throws PortalException {

    RemoteOptionsException roe = null;//  w  w  w .j  a v  a  2 s .c om

    if (!Validator.isDomain(remoteAddress) && !Validator.isIPAddress(remoteAddress)) {

        roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_ADDRESS);

        roe.setRemoteAddress(remoteAddress);

        throw roe;
    }

    if ((remotePort < 1) || (remotePort > 65535)) {
        roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PORT);

        roe.setRemotePort(remotePort);

        throw roe;
    }

    if (Validator.isNotNull(remotePathContext) && (!remotePathContext.startsWith(StringPool.FORWARD_SLASH)
            || remotePathContext.endsWith(StringPool.FORWARD_SLASH))) {

        roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PATH_CONTEXT);

        roe.setRemotePathContext(remotePathContext);

        throw roe;
    }

    validateRemoteGroup(groupId, remoteGroupId, remoteAddress, remotePort, remotePathContext, secureConnection);
}

From source file:de.uhh.l2g.plugins.service.impl.HostLocalServiceImpl.java

License:Open Source License

protected void validate(String name, String streamer) throws PortalException {

    //only default host db entries name field is allowed to be empty
    if (Validator.isNull(name)) {
        throw new HostNameException();
    }/*from  ww w.ja  v a2s  . co  m*/

    if (Validator.isNull(streamer) || !Validator.isDomain(streamer) || !Validator.isHostName(streamer)) {
        throw new HostStreamerException();
    }

}

From source file:org.gnenc.internet.mycourses.portlet.MyCoursesAdminPortlet.java

License:Open Source License

@SuppressWarnings({ "unchecked", "rawtypes" })
public static boolean validateSite(Site site, List errors) {
    boolean valid = true;

    if (Validator.isNull(site.getSiteName())) {
        errors.add("site-name-required");
        valid = false;//w w  w . j a v  a2s .  co  m

    }

    if (Validator.isNull(site.getUrl())) {
        errors.add("site-url-required");
        valid = false;

    } else if (Validator.isDomain(site.getUrl())) {
        errors.add("site-invalid-url");
        valid = false;

    }

    if (Validator.isNull(site.getEmailDomain())) {
        errors.add("site-email-domain-required");
        valid = false;

    } else if (Validator.isChar(site.getEmailDomain())) {
        errors.add("site-invalid-email-domain");
        valid = false;

    }

    if (Validator.isNull(site.getDbServer())) {
        errors.add("site-db-server-required");
        valid = false;

    } else {
        // Validate URL

    }

    if (Validator.isNull(site.getDbName())) {
        errors.add("site-db-name-required");
        valid = false;

    }

    if (Validator.isNull(site.getDbUser())) {
        errors.add("site-db-user-required");
        valid = false;

    }

    if (Validator.isNull(site.getDbPass())) {
        errors.add("site-db-pass-required");
        valid = false;

    }
    return valid;

}