Examples of ContentSourceType


Examples of org.rhq.core.domain.content.ContentSourceType

            query = em.createNamedQuery(ContentSourceType.QUERY_FIND_BY_NAME);
            query.setParameter("name", "testUpdateContentSourceCST");
            results = query.getResultList();

            if (results.size() > 0) {
                ContentSourceType deleteMe = (ContentSourceType) results.get(0);
                em.remove(deleteMe);
            }

            query = em.createNamedQuery(ContentSourceType.QUERY_FIND_BY_NAME);
            query.setParameter("name", "testUpdateContentSourceCST2");
            results = query.getResultList();

            if (results.size() > 0) {
                ContentSourceType deleteMe = (ContentSourceType) results.get(0);
                em.remove(deleteMe);
            }

            query = em.createNamedQuery(ContentSourceType.QUERY_FIND_BY_NAME);
            query.setParameter("name", "testConstraintViolationCST");
            results = query.getResultList();

            if (results.size() > 0) {
                ContentSourceType deleteMe = (ContentSourceType) results.get(0);
                em.remove(deleteMe);
            }

            getTransactionManager().commit();
        } catch (Exception e) {
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

            public void execute() throws Exception {

                String candidateRepoName = "candidate with source";

                //   Create a content source type and a content source
                ContentSourceType type = new ContentSourceType("testGetSyncResultsListCST");
                Set<ContentSourceType> types = new HashSet<ContentSourceType>();
                types.add(type);
                contentSourceMetadataManager.registerTypes(types); // this blows away any previous existing types
                ContentSource contentSource = new ContentSource("testGetSyncResultsListCS", type);
                contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

    public void deleteCandidatesForContentSource() throws Exception {
        executeInTransaction(new TransactionCallback() {

            public void execute() throws Exception {

                ContentSourceType contentSourceType = new ContentSourceType("testSourceType");
                Set<ContentSourceType> types = new HashSet<ContentSourceType>(1);
                types.add(contentSourceType);
                contentSourceMetadataManager.registerTypes(types);

                ContentSource source1 = new ContentSource("testSource1", contentSourceType);
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

            public void execute() throws Exception {

                String newName = "newRepo-" + RandomStringUtils.randomAlphanumeric(6);
                String oldName = "testRepo-" + RandomStringUtils.randomAlphanumeric(6);

                ContentSourceType contentSourceType = new ContentSourceType("testSourceType");

                Set<ContentSourceType> types = new HashSet<ContentSourceType>(1);
                types.add(contentSourceType);
                contentSourceMetadataManager.registerTypes(types);
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

        super.afterMethod();
    }

    public void testUpdateContentSourceTypes() throws Throwable {
        ContentSourceType type1;
        ContentSourceType type2;
        ContentSourceType type3;
        ContentSourceType type4;
        ConfigurationDefinition def;

        try {
            registerPlugin("./test/metadata/content-source-update-v1.xml");
            type1 = getContentSourceType("testCSPHT1");
            type2 = getContentSourceType("testCSPHT2");
            type3 = getContentSourceType("testCSPHT3");
            type4 = getContentSourceType("testCSPHT4");

            assert type1 != null;
            assert type2 != null;
            assert type3 == null;
            assert type4 != null;

            assert type1.getId() > 0;
            assert type1.getName().equals("testCSPHT1");
            assert type1.getDisplayName().equals("displayName1");
            assert type1.getDescription().equals("description1");
            assert type1.getContentSourceApiClass().equals("org.abc.ApiClass1");
            def = type1.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop1").getType() == PropertySimpleType.DIRECTORY;
            assert def.getPropertyDefinitionSimple("prop1").isRequired() == true;

            assert type2.getId() > 0;
            assert type2.getName().equals("testCSPHT2");
            assert type2.getDisplayName().equals("displayName2");
            assert type2.getDescription().equals("description2");
            assert type2.getContentSourceApiClass().equals("org.abc.ApiClass2");
            def = type2.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop2").getType() == PropertySimpleType.INTEGER;
            assert def.getPropertyDefinitionSimple("prop2").isRequired() == false;

            assert type4.getId() > 0;
            assert type4.getName().equals("testCSPHT4");
            assert type4.getDisplayName().equals("displayName4");
            assert type4.getDescription().equals("description4");
            assert type4.getContentSourceApiClass().equals("org.abc.ApiClass4");
            def = type4.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop4").getType() == PropertySimpleType.FILE;
            assert def.getPropertyDefinitionSimple("prop4").isRequired() == false;

            // now hot deploy a new version of that plugin
            registerPlugin("./test/metadata/content-source-update-v2.xml");
            getEntityManager().clear();
            type1 = getContentSourceType("testCSPHT1");
            type2 = getContentSourceType("testCSPHT2");
            type3 = getContentSourceType("testCSPHT3");
            type4 = getContentSourceType("testCSPHT4");

            assert type1 != null;
            assert type2 == null;
            assert type3 != null;
            assert type4 != null;

            assert type1.getId() > 0;
            assert type1.getName().equals("testCSPHT1");
            assert type1.getDisplayName().equals("displayName1");
            assert type1.getDescription().equals("description1");
            assert type1.getContentSourceApiClass().equals("org.abc.ApiClass1");
            def = type1.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop1").getType() == PropertySimpleType.DIRECTORY;
            assert def.getPropertyDefinitionSimple("prop1").isRequired() == true;

            assert type3.getId() > 0;
            assert type3.getName().equals("testCSPHT3");
            assert type3.getDisplayName().equals("displayName3");
            assert type3.getDescription().equals("description3");
            assert type3.getContentSourceApiClass().equals("org.abc.ApiClass3");
            def = type3.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop3").getType() == PropertySimpleType.STRING;
            assert def.getPropertyDefinitionSimple("prop3").isRequired() == true;

            assert type4.getId() > 0;
            assert type4.getName().equals("testCSPHT4");
            assert type4.getDisplayName().equals("displayName4changed");
            assert type4.getDescription().equals("description4changed");
            assert type4.getContentSourceApiClass().equals("org.abc.ApiClass4changed");
            def = type4.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 2;
            assert def.getPropertyDefinitionSimple("prop4_1").getType() == PropertySimpleType.INTEGER;
            assert def.getPropertyDefinitionSimple("prop4_1").isRequired() == false;
            assert def.getPropertyDefinitionSimple("prop4_2").getType() == PropertySimpleType.BOOLEAN;
            assert def.getPropertyDefinitionSimple("prop4_2").isRequired() == false;

            // Now try the other way round - our first set of asserts from before should again pass
            registerPlugin("./test/metadata/content-source-update-v1.xml");
            type1 = getContentSourceType("testCSPHT1");
            type2 = getContentSourceType("testCSPHT2");
            type3 = getContentSourceType("testCSPHT3");
            type4 = getContentSourceType("testCSPHT4");

            assert type1 != null;
            assert type2 != null;
            assert type3 == null;
            assert type4 != null;

            assert type1.getId() > 0;
            assert type1.getName().equals("testCSPHT1");
            assert type1.getDisplayName().equals("displayName1");
            assert type1.getDescription().equals("description1");
            assert type1.getContentSourceApiClass().equals("org.abc.ApiClass1");
            def = type1.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop1").getType() == PropertySimpleType.DIRECTORY;
            assert def.getPropertyDefinitionSimple("prop1").isRequired() == true;

            assert type2.getId() > 0;
            assert type2.getName().equals("testCSPHT2");
            assert type2.getDisplayName().equals("displayName2");
            assert type2.getDescription().equals("description2");
            assert type2.getContentSourceApiClass().equals("org.abc.ApiClass2");
            def = type2.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop2").getType() == PropertySimpleType.INTEGER;
            assert def.getPropertyDefinitionSimple("prop2").isRequired() == false;

            assert type4.getId() > 0;
            assert type4.getName().equals("testCSPHT4");
            assert type4.getDisplayName().equals("displayName4");
            assert type4.getDescription().equals("description4");
            assert type4.getContentSourceApiClass().equals("org.abc.ApiClass4");
            def = type4.getContentSourceConfigurationDefinition();
            assert def.getPropertyDefinitions().size() == 1;
            assert def.getPropertyDefinitionSimple("prop4").getType() == PropertySimpleType.FILE;
            assert def.getPropertyDefinitionSimple("prop4").isRequired() == false;
        } catch (Throwable t) {
            t.printStackTrace();
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

    }

    public ContentSourceType getContentSourceType(String name) {
        Query q = entityManager.createNamedQuery(ContentSourceType.QUERY_FIND_BY_NAME_WITH_CONFIG_DEF);
        q.setParameter("name", name);
        ContentSourceType type = null;
        try {
            type = (ContentSourceType) q.getSingleResult();
        } catch (NoResultException e) {
            type = null;
        }
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

    @SuppressWarnings("unchecked")
    private void validateContentSource(ContentSource cs) throws ContentSourceException {

        String name = cs.getName();
        ContentSourceType type = cs.getContentSourceType();

        if (name == null || name.trim().equals("")) {
            throw new ContentSourceException("ContentSource name attribute is required");
        }

        // If a content source with this name and type combination exists, throw an error as it's a violation
        // of the DB uniqueness constraints
        Query q = entityManager.createNamedQuery(ContentSource.QUERY_FIND_BY_NAME_AND_TYPENAME);
        q.setParameter("name", name);
        q.setParameter("typeName", type.getName());

        List<ContentSource> existingMatchingContentSources = q.getResultList();
        if (existingMatchingContentSources.size() > 0) {
            throw new ContentSourceException("Content source with name [" + name + "] and of type [" + type.getName()
                + "] already exists, please specify a different name.");
        }

    }
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

    }

    private void obfuscatePasswords(ContentSource contentSource) {
        ConfigurationDefinition configurationDefinition = contentSource.getContentSourceType().getContentSourceConfigurationDefinition();
        if (configurationDefinition == null) {
            ContentSourceType attachedContentSourceType = getContentSourceType(contentSource.getContentSourceType().getName());
            configurationDefinition = attachedContentSourceType.getContentSourceConfigurationDefinition();
        }
       
        PasswordObfuscationUtility.obfuscatePasswords(configurationDefinition, contentSource.getConfiguration());
    }
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

        ContentProvider adapter = null;
        String apiClassName = "?";
        String pluginName = "?";

        try {
            ContentSourceType type = contentSource.getContentSourceType();
            apiClassName = type.getContentSourceApiClass();
            pluginName = this.pluginManager.getMetadataManager().getPluginNameFromContentSourceType(type);

            ServerPluginEnvironment pluginEnv = this.pluginManager.getPluginEnvironment(pluginName);
            ClassLoader pluginClassloader = pluginEnv.getPluginClassLoader();
View Full Code Here

Examples of org.rhq.core.domain.content.ContentSourceType

                //       even if defined in another plugin (i.e plugin's content types are not scoped)
                //       Do we care?  This just means one plugin dev cannot name a content source type
                //       something that another plugin dev used already in another plugin.
                if (getContentSourceType(newType.getName()) == null) {
                    // create the new domain object represented by the XML
                    ContentSourceType contentSourceType = new ContentSourceType();
                    contentSourceType.setName(newType.getName());
                    contentSourceType.setDisplayName(newType.getDisplayName());
                    contentSourceType.setDescription(newType.getDescription());
                    contentSourceType.setPluginName(pluginDescriptor.getName());
                    contentSourceType.setDefaultLazyLoad(newType.isLazyLoad());
                    contentSourceType.setDefaultDownloadMode(DownloadMode.valueOf(newType.getDownloadMode()
                        .toUpperCase()));
                    contentSourceType.setDefaultSyncSchedule(newType.getSyncSchedule());
                    contentSourceType.setContentSourceApiClass(newType.getApiClass());

                    ConfigurationDefinition configDef = ConfigurationMetadataParser.parse(newType.getName(), newType
                        .getConfiguration());
                    contentSourceType.setContentSourceConfigurationDefinition(configDef);

                    // add the new domain object to the list of domain objects for this plugin
                    pluginTypes.put(contentSourceType.getName(), contentSourceType);
                } else {
                    throw new Exception("Cannot redefine an existing content source type:" + newType.getName());
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.