CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileProjectLine
org\ogf\graap\wsag\server\persistence\impl\SimplePersistentAgreement.javaWSAG4J: Server125
org\ogf\graap\wsag\wsrf\persistence\WsDatabasePersistentAgreement.javaWSAG4J: WSRF-Stack Integration206
    }

    public String getName()
    {
        return agreement.getName();
    }

    public String getAgreementId()
    {
        return agreement.getAgreementId();
    }

    public AgreementContextType getContext()
    {
        return agreement.getContext();
    }

    public TermTreeType getTerms()
    {
        return agreement.getTerms();
    }

    public void terminate( TerminateInputType reason )
    {
        agreement.terminate( reason );
    }

    public AgreementStateType getState()
    {
        return agreement.getState();
    }

    public GuaranteeTermStateType[] getGuaranteeTermStates()
    {
        return agreement.getGuaranteeTermStates();
    }

    public ServiceTermStateType[] getServiceTermStates()
    {
        return agreement.getServiceTermStates();
    }

    public boolean validate()
    {
        return agreement.validate();
    }

    public void notifyReload( Map<String, XmlObject> executionCtx )
    {
        agreement.notifyReload( executionCtx );
    }

    public void setAgreementId( String agreementId )
    {
        agreement.setAgreementId( agreementId );
    }

    public void setContext( AgreementContextType context )
    {
        agreement.setContext( context );
    }

    public void setName( String name )
    {
        agreement.setName( name );
    }

    public void setTerms( TermTreeType terms )
    {
        agreement.setTerms( terms );
    }

    public void setState( AgreementStateType agreementState )
    {
        agreement.setState( agreementState );
    }

    public void setGuaranteeTermStates( GuaranteeTermStateType[] guaranteeTermStateList )
    {
        agreement.setGuaranteeTermStates( guaranteeTermStateList );
    }

    public void setServiceTermStates( ServiceTermStateType[] serviceTermStateList )
    {
        agreement.setServiceTermStates( serviceTermStateList );
    }

    public AgreementPropertiesType getXMLObject()
    {
        return agreement.getXMLObject();
    }

    public void setXmlObject( AgreementPropertiesType properties )
    {
        agreement.setXmlObject( properties );
    }

    public Map<String, XmlObject> getExecutionContext()
    {
        return agreement.getExecutionContext();
    }

    public Map<String, Object> getTransientExecutionContext()
    {
        return agreement.getTransientExecutionContext();
    }

    public Class<?> getImplementationClass()
    {
        return agreement.getImplementationClass();
    }

    public void addObserver( Observer o )
    {
        agreement.addObserver( o );
    }

    public void notifyObservers()
    {
        agreement.notifyObservers();
    }

    public void notifyObservers( Object arg )
    {
        agreement.notifyObservers( arg );
    }

    public boolean hasChanged()
    {
        return agreement.hasChanged();
    }

}
FileProjectLine
org\ogf\graap\wsag\api\security\KeystoreLoginModule.javaWSAG4J: API314
org\ogf\graap\wsag\client\wsrf\security\KeystoreLoginModule.javaWSAG4J: WSRF Client Implementation334
        userPrincipal = null;

        keystore = null;
        keystoreFile = null;
        keystorePassword = null;
        keystoreType = null;

        alias = null;
        privateKeyPassword = null;

        return true;
    }

    private synchronized KeyStore getKeystore() throws LoginException
    {
        if ( keystore == null )
        {
            loadKeyStore();
        }
        return keystore;
    }

    private void loadKeyStore() throws LoginException
    {
        try
        {
            String actualKSType = ( keystoreType == null ) ? KeyStore.getDefaultType() : keystoreType;

            keystore = KeyStore.getInstance( actualKSType );

            if ( keystoreFile == null )
            {
                throw new IOException( "No keystore specified by user." );
            }

            InputStream ksInput = WSAG4JConfiguration.findResource( keystoreFile );
            keystore.load( ksInput, keystorePassword.toCharArray() );

        }
        catch ( KeyStoreException e )
        {
            throw new LoginException( e.getMessage() );
        }
        catch ( IOException e )
        {
            throw new LoginException( e.getMessage() );
        }
        catch ( CertificateException e )
        {
            throw new LoginException( e.getMessage() );
        }
        catch ( NoSuchAlgorithmException e )
        {
            throw new LoginException( e.getMessage() );
        }

    }

    /**
     * Gets the list of certificates for a given alias.
     * <p/>
     * 
     * @param ksAlias
     *            Lookup certificate chain for this alias
     * 
     * @return Array of X509 certificates for this alias name, or null if this alias does not exist in the
     *         keystore
     * 
     * @throws KeyStoreException
     *             error accessing the keystore
     * 
     * @throws LoginException
     *             error logging into the keystore
     */
    private X509Certificate[] getCertificates( String ksAlias ) throws KeyStoreException, LoginException
    {
        Certificate[] certs = null;
        Certificate cert = null;

        KeyStore store = getKeystore();

        if ( store != null )
        {
            // There's a chance that there can only be a set of trust stores
            certs = store.getCertificateChain( ksAlias );
            if ( certs == null || certs.length == 0 )
            {
                // no cert chain, so lets check if getCertificate gives us a
                // result.
                cert = store.getCertificate( ksAlias );
            }
        }

        if ( cert != null )
        {
            certs = new Certificate[] { cert };
        }
        else if ( certs == null )
        {
            // At this pont we don't have certs or a cert
            return null;
        }

        X509Certificate[] x509certs = new X509Certificate[certs.length];
        for ( int i = 0; i < certs.length; i++ )
        {
            x509certs[i] = (X509Certificate) certs[i];
        }
        return x509certs;
    }
FileProjectLine
org\ogf\graap\wsag\it\samples\negotiation\AbstractSampleNegotiatorTest.javaWSAG4J: Integration Tests549
org\ogf\graap\wsag\samples\actions\SampleNegotiateAction.javaWSAG4J: Samples323
                if ( sdts[i].getName().equals( RESOURCES_SDT_NAME ) )
                {
                    resourcesSDT = sdts[i];
                    break;
                }
            }
        }

        String name = resourcesSDT.getName();
        String serviceName = resourcesSDT.getServiceName();

        JobDefinitionDocument resourcesDoc = JobDefinitionDocument.Factory.newInstance();
        resourcesDoc.addNewJobDefinition().addNewJobDescription().addNewResources();
        resourcesDoc.getJobDefinition().getJobDescription().getResources().set( jobResources );

        resourcesSDT.set( resourcesDoc );
        resourcesSDT.setName( name );
        resourcesSDT.setServiceName( serviceName );
    }

    private void setTimeConstraintSDT( SampleNegotiationOffer negotiationOffer,
                                       TimeConstraintType timeConstraint )
    {

        ServiceDescriptionTermType timeConstraintSDT = null;

        ServiceDescriptionTermType[] sdts =
            negotiationOffer.getTerms().getAll().getServiceDescriptionTermArray();

        if ( sdts != null )
        {
            for ( int i = 0; i < sdts.length; i++ )
            {
                if ( sdts[i].getName().equals( TIME_CONSTRAINT_SDT_NAME ) )
                {
                    timeConstraintSDT = sdts[i];
                    break;
                }
            }
        }

        String name = timeConstraintSDT.getName();
        String serviceName = timeConstraintSDT.getServiceName();

        TimeConstraintDocument timeConstraintDoc = TimeConstraintDocument.Factory.newInstance();
        timeConstraintDoc.addNewTimeConstraint();
        timeConstraintDoc.getTimeConstraint().set( timeConstraint );

        timeConstraintSDT.set( timeConstraintDoc );
        timeConstraintSDT.setName( name );
        timeConstraintSDT.setServiceName( serviceName );
    }
FileProjectLine
org\ogf\graap\wsag\server\rest\WSAG4JContextListener.javaWSAG4J: RESTful Service Implementation96
org\ogf\graap\wsag\wsrf\bootstrap\WSAG4JContextListener.javaWSAG4J: WSRF-Stack Integration103
        Thread runner = DatabaseManager.getTimer().getThread();
        DatabaseManager.getTimer().shutdown();

        //
        // wait for HSQLDB to finish outstanding work.
        //
        // HSQLDB has a default write delay of 60 seconds for scripts.
        // Therefore we wait a bit more than a minute at max for HSQLDB
        // shutdown.
        //
        int maxWaitingTime = MAX_DB_SHUTDOWN_RETRIES;

        while ( runner.isAlive() )
        {
            if ( maxWaitingTime == 0 )
            {
                break;
            }

            maxWaitingTime--;

            try
            {
                LOG.debug( "wait for HSQLDB to finish outstanding work..." );
                synchronized ( this )
                {
                    wait( DB_WAITING_TIME );
                }
            }
            catch ( InterruptedException e )
            {
                break;
            }
        }

        //
        // check if HSQLDB terminated normally
        //
        if ( runner.isAlive() )
        {
            LOG.warn( "HSQLDB failed to terminate normally. Send interupt." );
            runner.interrupt();
        }
        else
        {
            LOG.info( "HSQLDB shutdown complete." );
        }
        //
        // end of hsqldb specific block
        //

        LOG.debug( "cleanup database drivers..." );
        Introspector.flushCaches();
        for ( Enumeration<Driver> e = DriverManager.getDrivers(); e.hasMoreElements(); )
        {
            Driver driver = e.nextElement();
            if ( driver.getClass().getClassLoader() == getClass().getClassLoader() )
            {
                try
                {
                    LOG.debug( "deregister: " + driver.getClass().getName() );
                    DriverManager.deregisterDriver( driver );
                }
                catch ( Exception ex )
                {
                    LOG.warn( "failed to deregister driver.", ex );
                }
            }
        }

        LOG.info( "shutdown of WSAG4J service completed" );
    }
FileProjectLine
org\ogf\graap\wsag\api\exceptions\AgreementFactoryException.javaWSAG4J: API160
org\ogf\graap\wsag\api\exceptions\NegotiationException.javaWSAG4J: API128
        baseFault.getErrorCode().set( XmlString.Factory.newValue( getErrorCode() ) );

        baseFault.setTimestamp( timestamp );

        Description description = baseFault.addNewDescription();
        description.setLang( LOCAL_EN );
        description.setStringValue( MessageFormat.format( DESCRIPTION_MESSAGE, new Object[] {
            this.getClass().getName(), getMessage() } ) );

        StackTraceElement[] stackTrace = getStackTrace();
        for ( int i = 0; i < stackTrace.length; i++ )
        {
            description = baseFault.addNewDescription();
            description.setLang( LOCAL_EN );
            description.setStringValue( MessageFormat.format( STACKTRACE_MESSAGE,
                new Object[] { stackTrace[i] } ) );
        }

        if ( getCause() != null )
        {
            description = baseFault.addNewDescription();
            description.setLang( LOCAL_EN );
            description.setStringValue( MessageFormat.format( CAUSE_MESSAGE, new Object[] {
                getCause().getClass().getName(), getCause().getMessage() } ) );
        }

        return baseFault;
    }

    @Override
    public int getErrorCode()
    {
        return AGREEMENT_FACTORY_ERROR;
FileProjectLine
org\ogf\graap\wsag\api\security\KeystoreLoginModule.javaWSAG4J: API147
org\ogf\graap\wsag\client\wsrf\security\KeystoreLoginModule.javaWSAG4J: WSRF Client Implementation161
    public boolean login() throws LoginException
    {
        KeystoreCallback ksCallback = new KeystoreCallback();
        Callback[] callbacks = new Callback[] { ksCallback };

        // handle login callbacks
        try
        {
            cbHandler.handle( callbacks );
        }
        catch ( IOException e )
        {
            String message = "IO error during login";
            LoginException le = new LoginException( message );
            le.initCause( e );
            throw le;
        }
        catch ( UnsupportedCallbackException e )
        {
            String message = "Invalid callback handler. Callback not supported.";
            LoginException le = new LoginException( message );
            le.initCause( e );
            throw le;
        }

        keystorePassword = ksCallback.getKeystorePassword();

        truststorePassword = ksCallback.getTruststorePassword();

        privateKeyPassword = ksCallback.getPrivateKeyPassword();

        //
        // if an empty alias is supplied, we set the alias to null
        // this is for treating PKCS12 files, where certificates
        // do not have a alias
        //
        // if ("".equals(alias)) alias = null;

        if ( ( keystoreFile == null ) || ( keystorePassword == null ) || ( privateKeyPassword == null ) )
        {

            String message =
                "Missing required parameter. "
                    + "The KeystoreLoginModule requires the following parameters: "
                    + "[keystoreFilename, keystorePassword, alias, privateKeyPassword]";

            throw new LoginException( message );
        }

        loadKeyStore();

        login = true;

        return true;
    }
FileProjectLine
org\ogf\graap\wsag\api\security\KeystoreLoginModule.javaWSAG4J: API208
org\ogf\graap\wsag\client\wsrf\security\KeystoreLoginModule.javaWSAG4J: WSRF Client Implementation223
    public boolean commit() throws LoginException
    {
        if ( !login )
        {
            return false;
        }

        PrivateKey userKey;
        X500PrivateCredential userCredential;
        X509Certificate[] userCertificateChain;

        try
        {
            userCertificateChain = getCertificates( alias );
            userKey = (PrivateKey) keystore.getKey( alias, privateKeyPassword.toCharArray() );
        }
        catch ( KeyStoreException e )
        {
            // thrown by keystoreManager.getCertificateByAlias(defaultAlias)[0]
            String message = "Could not get default certificate from KeyStoreManager";
            LoginException le = new LoginException( message );
            le.initCause( e );
            throw le;
        }
        catch ( Exception e )
        {
            // thrown by keystoreManager.getKeyEntry(defaultAlias)
            String message = "Could not get private key from KeyStoreManager";
            LoginException le = new LoginException( message );
            le.initCause( e );
            throw le;
        }

        if ( userCertificateChain == null )
        {
            Object[] filler = new Object[] { alias };
            String message = MessageFormat.format( "No certificates found for user {0}", filler );
            throw new LoginException( message );
        }

        userCredential = new X500PrivateCredential( userCertificateChain[0], userKey );
FileProjectLine
org\ogf\graap\wsag\client\wsrf\impl\Axis2SoapClient.javaWSAG4J: WSRF Client Implementation851
org\ogf\graap\wsag\wsrf\WsrfEngine.javaWSAG4J: WSRF-Stack Integration583
    public static ConfigurationType findWSAG4JConfiguration( String fileName ) throws IOException
    {
        try
        {

            InputStream resourceInput = WSAG4JConfiguration.findResource( fileName );

            ConfigurationType result = null;

            if ( resourceInput != null )
            {
                try
                {
                    result = ConfigurationDocument.Factory.parse( resourceInput ).getConfiguration();
                }
                catch ( IOException e )
                {
                    String msgText = "Error reading the configuration file {0}. Error: {1}";
                    String message = LogMessage.format( msgText, fileName, e.getMessage() );

                    LOG.error( message );
                    throw new IOException( message );

                }
                catch ( XmlException e )
                {
                    String msgText = "Error reading the configuration file {0}. Description: {1}";
                    String message = LogMessage.format( msgText, fileName, e.getMessage() );

                    LOG.error( message );
                    throw new IOException( message );
                }
            }

            return result;
        }
        catch ( Exception ex )
        {
            String msgText = "Failed to load configuration file [{0}]. Message: {1}";
FileProjectLine
org\ogf\graap\wsag\it\AbstractPendingAgreementFactoryTest.javaWSAG4J: Integration Tests86
org\ogf\graap\wsag\it\AbstractPendingAgreementFactoryTest.javaWSAG4J: Integration Tests168
            LOG.info( "Entering TestCase: testCreatePendingAgreement" );

            AgreementFactoryClient[] factories = getAgreementFactoryClients();
            assertEquals( getDefaultFactoryCount(), factories.length );

            LOG.info( "Overview of the available factories and their templates." );
            for ( int i = 0; i < factories.length; i++ )
            {
                LOG.info( "+ " + factories[i].getResourceId() );

                AgreementTemplateType[] templates = factories[i].getTemplates();
                LOG.info( "   + Num of templates: " + templates.length );

                for ( int k = 0; k < templates.length; k++ )
                {
                    LOG.info( "      + " + templates[k].getName() );
                }
            }

            AgreementFactoryClient factory = factories[0];

            AgreementClient[] agreements;

            LOG.info( "Creating new Agreements" );
            AgreementTemplateType template = factory.getTemplate( "SAMPLE4-PENDING-AGREEMENT", "1" );
FileProjectLine
org\ogf\graap\wsag\doc\AbstractAgreementIntegrationSnippets.javaWSAG4J: Integration Tests144
org\ogf\graap\wsag\it\AbstractAgreementFactoryTest.javaWSAG4J: Integration Tests223
        AgreementFactoryClient[] factories = getAgreementFactoryClients();

        //
        // lookup factory with resource id "SAMPLE-INSTANCE-1"
        //
        // START SNIPPET: LookupFactoryWithID
        AgreementFactoryClient factory = null;
        for ( int i = 0; i < factories.length; i++ )
        {
            if ( "SAMPLE-INSTANCE-1".equals( factories[i].getResourceId() ) )
            {
                factory = factories[i];
                break;
            }
        }
        // END SNIPPET: LookupFactoryWithID
        //
        // retrieve template with name "SAMPLE1" and id "1" from the factory and print it on the console
        //
        // START SNIPPET: RetrieveTemplateWithID
        AgreementTemplateType template = factory.getTemplate( "SAMPLE1", "1" );
        // END SNIPPET: RetrieveTemplateWithID

        // START SNIPPET: CreateAgreement

        //
        // create the agreement offer based on the selected template
        //
        AgreementOffer offer = new AgreementOfferType( template );

        //
        // get the service description term from the offer
        //
        ServiceDescriptionTermType sdt = offer.getTerms().getAll().getServiceDescriptionTermArray( 0 );

        //
        // select the service description
        //
        // The JobDescriptionDocument is defined as a document element. We use the
        // JobDescriptionDocument QName to select the JobDescriptionDocument from the SDT.
        //
        JobDescriptionType job =
            (JobDescriptionType) sdt.selectChildren( JobDescriptionDocument.type.getDocumentElementName() )[0];

        //
        // changes to the job object are automatically reflected in the offer
        //
        job.getResources().addNewIndividualCPUCount().addNewExact().setDoubleValue( 4 );

        //
        // now create the agreement instance
        //
        AgreementClient agreement = factory.createAgreement( offer );
FileProjectLine
org\ogf\graap\wsag\server\persistence\impl\PersistentAgreementContainer.javaWSAG4J: Server532
org\ogf\graap\wsag\server\persistence\impl\PersistentAgreementContainer.javaWSAG4J: Server596
            Query query = em.createNamedQuery( "PersistentAgreementContainer.findAll" );

            Collection<PersistentAgreementContainer> containers = null;
            try
            {
                containers = query.getResultList();

                for ( Iterator<PersistentAgreementContainer> iterator = containers.iterator(); iterator.hasNext(); )
                {
                    PersistentAgreementContainer persistentAgreementContainer = iterator.next();

                    try
                    {
                        String xml = persistentAgreementContainer.persistedAgreementContextType;
                        persistentAgreementContainer.persistenceContext =
                            (PersistenceAgreementContextDocument) XmlObject.Factory.parse( xml );
                    }
                    catch ( XmlException ex )
                    {
                        LOG.error( "could not load persisted agreement context.", ex );
                        throw new AgreementFactoryException( "could not load persisted agreement context.",
                            ex );
                    }
                }

                return containers.toArray( new PersistentAgreementContainer[containers.size()] );

            }
            catch ( NoResultException ex )
            {
                //
                // not found, so we return null
                //
                return null;
            }
        }
        finally
        {
            em.close();
        }
    }
FileProjectLine
org\ogf\graap\wsag\api\types\AgreementDelegator.javaWSAG4J: API100
org\ogf\graap\wsag\client\api\local\LocalAgreementClient.javaWSAG4J: API67
    @Override
    public String getName()
    {
        return agreement.getName();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getAgreementId()
     */
    @Override
    public String getAgreementId()
    {
        return agreement.getAgreementId();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getContext()
     */
    @Override
    public AgreementContextType getContext()
    {
        return agreement.getContext();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getTerms()
     */
    @Override
    public TermTreeType getTerms()
    {
        return agreement.getTerms();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#terminate(org.ogf.schemas.graap.wsAgreement.TerminateInputType)
     */
    @Override
    public void terminate( TerminateInputType reason )
    {
        agreement.terminate( reason );
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getState()
     */
    @Override
    public AgreementStateType getState()
    {
        return agreement.getState();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getGuaranteeTermStates()
     */
    @Override
    public GuaranteeTermStateType[] getGuaranteeTermStates()
    {
        return agreement.getGuaranteeTermStates();
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.ogf.graap.wsag.api.Agreement#getServiceTermStates()
     */
    @Override
    public ServiceTermStateType[] getServiceTermStates()
    {
        return agreement.getServiceTermStates();
    }
FileProjectLine
org\ogf\graap\wsag\server\engine\WsagEngine.javaWSAG4J: Server450
org\ogf\graap\wsag\wsrf\WSAG4JPersistenceFacade.javaWSAG4J: WSRF-Stack Integration96
                PersistentAgreementFactory[] factories = getPersistenceLayer().list();
                for ( int j = 0; j < factories.length; j++ )
                {
                    if ( persistentFactories.containsKey( factories[j].getResourceId() ) )
                    {
                        String message1 =
                            "[duplicated resource id] "
                                + "the agreement factory resource id must be unique in a WSAG4J engine.";
                        LOG.error( message1 );

                        String message2 =
                            "[duplicated resource id] the factory with resource id ''{0}'' was not loaded.";
                        LOG.error( MessageFormat.format( message2,
                            new Object[] { factories[j].getResourceId() } ) );
                    }
                    else
                    {
                        persistentFactories.put( factories[j].getResourceId(), factories[j] );
                        factoriesOL.add( factories[j] );
                    }
                }
            }
            catch ( Exception e )
            {
                LOG.error( "error loading persistence layer", e );
            }
FileProjectLine
org\ogf\graap\wsag\api\security\KeystoreLoginModule.javaWSAG4J: API111
org\ogf\graap\wsag\client\wsrf\security\KeystoreLoginModule.javaWSAG4J: WSRF Client Implementation124
    @SuppressWarnings( "rawtypes" )
    public void initialize( Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options )
    {
        this.klmSubject = subject;
        this.cbHandler = callbackHandler;
        // this.sharedState = sharedState;
        this.klmOptions = options;

        initializeOptions();
    }

    private void initializeOptions()
    {

        keystoreFile = (String) klmOptions.get( "keyStoreURL" );
        keystoreType = (String) klmOptions.get( "keyStoreType" );
        alias = (String) klmOptions.get( "keyStoreAlias" );

        truststoreFile = (String) klmOptions.get( "trustStoreURL" );
        truststoreType = (String) klmOptions.get( "trustStoreType" );

        //
        // processing of the options
        //
        // keystoreFile = resolveKeystoreURL(keystoreFile);
        // truststoreFile = resolveKeystoreURL(truststoreFile);

        keystoreType = ( keystoreType == null ) ? "JKS" : keystoreType;
        truststoreType = ( truststoreType == null ) ? "JKS" : truststoreType;
    }
FileProjectLine
org\ogf\graap\wsag\client\api\impl\AbstractAgreementFactoryClient.javaWSAG4J: API127
org\ogf\graap\wsag\client\wsrf\WsrfAgreementFactoryClient.javaWSAG4J: WSRF Client Implementation242
    public AgreementTemplateType getTemplate( String name, String id )
        throws ResourceUnknownException, ResourceUnavailableException
    {
        if ( name == null )
        {
            return null;
        }

        id = ( id != null ) ? id : "";

        AgreementTemplateType[] templates = getTemplates();

        for ( int i = 0; i < templates.length; i++ )
        {
            if ( name.equalsIgnoreCase( templates[i].getName() ) )
            {

                String actualId =
                    ( templates[i].getTemplateId() != null ) ? templates[i].getTemplateId() : "";

                if ( id.equalsIgnoreCase( actualId ) )
                {
                    return templates[i];
                }
            }
        }

        return null;
    }
FileProjectLine
org\ogf\graap\wsag\server\engine\WsagEngine.javaWSAG4J: Server638
org\ogf\graap\wsag\wsrf\WsrfEngine.javaWSAG4J: WSRF-Stack Integration528
        PersistentAgreementFactory[] factories = getPersistenceLayer().list();
        for ( int i = 0; i < factories.length; i++ )
        {
            try
            {
                final String msgDoSave = "Save agreement factory ''{0}''.";
                LOG.debug( LogMessage.getMessage( msgDoSave, factories[i].getResourceId() ) );

                factories[i].save();

                final String msgSaved = "Agreement factory ''{0}'' saved.";
                LOG.debug( LogMessage.getMessage( msgSaved, factories[i].getResourceId() ) );
            }
            catch ( Exception e )
            {
                String message = "Failed to save agreement factory ''{0}''.";
                LOG.error( MessageFormat.format( message, new Object[] { factories[i].getResourceId() } ), e );
            }
        }
FileProjectLine
org\ogf\graap\wsag\testutils\WsagTestCase.javaWSAG4J: API60
org\ogf\graap\wsag\it\WsagTestCase.javaWSAG4J: Integration Tests63
    public WsagTestCase( String testName )
    {
        super( testName );
    }

    @Override
    protected void setUp() throws Exception
    {
        if ( log.isInfoEnabled() )
        {
            log.info( "" );
            log.info( "================================================================================" );
            log.info( "  Entering unit test: " + getName() );
            log.info( "--------------------------------------------------------------------------------" );
        }

        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception
    {
        super.tearDown();

        if ( log.isInfoEnabled() )
        {
            log.info( "--------------------------------------------------------------------------------" );
            log.info( "  Leaving unit test: " + getName() );
            log.info( "================================================================================" );
            log.info( "" );
        }
    }
}
FileProjectLine
org\ogf\graap\wsag\server\engine\WsagEngine.javaWSAG4J: Server542
org\ogf\graap\wsag\wsrf\WSAG4JPersistenceFacade.javaWSAG4J: WSRF-Stack Integration160
    }

    /**
     * @param factoryId
     *            removes the factory with the given id from the persistence layer
     * 
     * @throws Exception
     *             an error occurred while removing the factory
     * 
     * @see org.ogf.graap.wsag.server.persistence.IAgreementFactoryHome#remove(java.lang.String)
     */
    public void remove( String factoryId ) throws Exception
    {
        if ( persistentFactories.containsKey( factoryId ) )
        {
            factoriesOL.remove( persistentFactories.get( factoryId ) );
            persistentFactories.remove( factoryId );
        }
    }

    /**
     * Saves all factories.
     * 
     * @throws Exception
     *             indicates an error while saving the factories
     */
    public void save() throws Exception
    {
        PersistentAgreementFactory[] factories = list();
        for ( int i = 0; i < factories.length; i++ )
        {
            factories[i].save();
        }
    }

    /**
     * @param factories
     *            the factories to save
     * 
     * @throws Exception
     *             indicates an error while saving the factories
     * 
     * @see org.ogf.graap.wsag.server.persistence.IAgreementFactoryHome#saveAgreementFactories(org.ogf.graap.wsag.server.persistence.PersistentAgreementFactory[])
     */
    public void saveAgreementFactories( PersistentAgreementFactory[] factories ) throws Exception
    {
        for ( int i = 0; i < factories.length; i++ )
        {
            factories[i].save();
        }
    }

    /**
     * Shutdown of the WSAG4J engine instance.
     * 
     * @throws Exception
     *             indicates an error during engine shutdown
     */
    public void shutdown() throws Exception