Package com.opensymphony.xwork.validator

Examples of com.opensymphony.xwork.validator.ValidatorContext


    public void validate( Object obj )
        throws ValidationException
    {

        String method = (String) getFieldValue( "method", obj );
        ValidatorContext ctxt = getValidatorContext();

        if ( method.equals( "rsync" ) )
        {
            String rsyncHost = (String) getFieldValue( "rsyncHost", obj );
            if ( rsyncHost == null || rsyncHost.equals( "" ) )
            {
                ctxt.addActionError( "Rsync host is required." );
            }

            String rsyncDirectory = (String) getFieldValue( "rsyncDirectory", obj );
            if ( rsyncDirectory == null || rsyncDirectory.equals( "" ) )
            {
                ctxt.addActionError( "Rsync directory is required." );
            }

            String rsyncMethod = (String) getFieldValue( "rsyncMethod", obj );
            if ( rsyncMethod == null || rsyncMethod.equals( "" ) )
            {
                ctxt.addActionError( "Rsync method is required." );
            }
            else
            {
                if ( !rsyncMethod.equals( "anonymous" ) && !rsyncMethod.equals( "ssh" ) )
                {
                    ctxt.addActionError( "Invalid rsync method" );
                }
            }

            String username = (String) getFieldValue( "username", obj );
            if ( username == null || username.equals( "" ) )
            {
                ctxt.addActionError( "Username is required." );
            }

        }
        else if ( method.equals( "svn" ) )
        {
            String svnUrl = (String) getFieldValue( "svnUrl", obj );
            if ( svnUrl == null || svnUrl.equals( "" ) )
            {
                ctxt.addActionError( "SVN url is required." );
            }

            String username = (String) getFieldValue( "username", obj );
            if ( username == null || username.equals( "" ) )
            {
                ctxt.addActionError( "Username is required." );
            }
        }
        else if ( method.equals( "cvs" ) )
        {
            String cvsRoot = (String) getFieldValue( "cvsRoot", obj );
            if ( cvsRoot == null || cvsRoot.equals( "" ) )
            {
                ctxt.addActionError( "CVS root is required." );
            }
        }
        else if ( method.equals( "file" ) )
        {
            String directory = (String) getFieldValue( "directory", obj );
            if ( directory == null || directory.equals( "" ) )
            {
                ctxt.addActionError( "Directory is required." );
            }
        }

        if ( ctxt.hasActionErrors() )
        {
            return;
        }
    }
View Full Code Here


        String cron = (String) getFieldValue( "cron", obj );

        org.codehaus.plexus.scheduler.CronExpressionValidator cronExpressionValidator =
            new org.codehaus.plexus.scheduler.CronExpressionValidator();

        ValidatorContext ctxt = getValidatorContext();
        if ( !cronExpressionValidator.validate( String.valueOf( cron ) ) )
        {
            ctxt.addActionError( "Invalid cron expression value(s)" );
            return;
        }
    }
View Full Code Here

        String snapshotsPolicy = (String) getFieldValue( "snapshotsPolicy", obj );
        String releasesPolicy = (String) getFieldValue( "releasesPolicy", obj );
        Integer snapshotsInterval = (Integer) getFieldValue( "snapshotsInterval", obj );
        Integer releasesInterval = (Integer) getFieldValue( "releasesInterval", obj );

        ValidatorContext ctxt = getValidatorContext();

        if ( !snapshotsPolicy.equals( "interval" ) )
        {
            if ( snapshotsInterval.intValue() != 0 )
            {
                ctxt.addActionError( "Snapshots Interval must be set to zero." );
            }
        }

        if ( !releasesPolicy.equals( "interval" ) )
        {
            if ( releasesInterval.intValue() != 0 )
            {
                ctxt.addActionError( "Releases Interval must be set to zero." );
            }
        }

        if ( ctxt.hasActionErrors() )
        {
            return;
        }
    }
View Full Code Here

            dayOfWeek + " " + year ).trim();

        org.codehaus.plexus.scheduler.CronExpressionValidator validator =
            new org.codehaus.plexus.scheduler.CronExpressionValidator();

        ValidatorContext ctxt = getValidatorContext();

        if ( !validator.validate( cronExpression ) )
        {
            ctxt.addActionError( "Invalid cron expression value(s)" );
            return;
        }
    }
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork.validator.ValidatorContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.