All pastes #395213 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-14 21:32 UTC
rendered paste body
        PartyManager partyManager = Connector.getPartyManager();
        
        // Create test company security domain taxonomy
        
        // We call PartyManager to create a new organization - a company called "Mega Corp" -
        // and get back a unique identifier that we can use to identify the new company.
        m_acmeCorpUuid = 
        	partyManager.createOrganization(m_rootAuth,
                                            "Acme Corporation", // Name of the company
                                            "Realtime Delivery Service", // a description
                                            null,         // We're a top-level organization, so no parent
                                            "Company",       // The 'group type' of the organization
                                            null);        // no email address for the top organization
        
        cleanupPartyUuids.add(m_acmeCorpUuid);

        // Now let's create an engineering department within Mega Corp.
        m_engineeringUuid = 
        	partyManager.createOrganization(m_rootAuth,
                                            "Engineering",
                                            "Design and R&D",
                                            m_acmeCorpUuid,   // Mega Corp is our 'parent' organization
                                            "Department",
                                            "eng@acme.com"); // email address for Engineering

        cleanupPartyUuids.add(m_engineeringUuid);
        
        // Create a manufacturing department
        m_manufacturingUuid = 
        	partyManager.createOrganization(m_rootAuth,
                                            "Manufacturing",
                                            "The means of production",
                                            m_acmeCorpUuid,
                                            "Department",
                                            "manuf@acme.com");
        
        cleanupPartyUuids.add(m_manufacturingUuid);
        
        // One thing to note is that "Company" and "Department" are not just free-form strings.
        // They must correspond to the name of a GroupType database object. There are several pre-defined
        // GroupTypes, of which "Company" and "Department" are two.
        // The current set of GroupType objects can be found with the PartyManager method getGroupTypes().

        // Create a 'Work Group'
        m_safetyCommitteeUuid = partyManager.createWorkGroup(m_rootAuth,
                                                             "Site Safety Committee",
                                                             "No explosion to big",
                                                             m_acmeCorpUuid,
                                                             "Project Team",
                                                             "safety@acme.com" );
        
        cleanupPartyUuids.add(m_safetyCommitteeUuid);
        
        // Create a repository for the newly create root organization
        RepositoryManager repositoryManager = Connector.getRepositoryManager();
        String serverHostName = java.net.InetAddress.getLocalHost().getCanonicalHostName().toLowerCase();

        ServerInfo serverInfo = null;
        try
        {
          serverInfo = repositoryManager.getServer( m_rootAuth, serverHostName );
        }
        catch (Throwable t)
        {
          serverInfo = new com.clearstorysystems.ems.repository.ServerInfo();
          serverInfo.setName(serverHostName);
          serverInfo.setTmpDirPath(System.getProperty("java.io.tmpdir"));
          serverInfo.setUuid(repositoryManager.createServer(m_rootAuth, serverInfo));
        }

  		
        com.clearstorysystems.ems.repository.RepositoryInfo repositoryInfo =
          new com.clearstorysystems.ems.repository.RepositoryInfo();
        repositoryInfo.setServerUuid(serverInfo.getUuid());
        repositoryInfo.setName("ExampleRepository-"+System.currentTimeMillis());
        repositoryInfo.setRootPath(System.getProperty("java.io.tmpdir"));
        repositoryInfo.setIsReadOnly(Boolean.FALSE);
        repositoryInfo.setOwnerUuid(m_acmeCorpUuid);

        m_repositoryUuid = repositoryManager.createRepository(m_rootAuth, repositoryInfo);