org.alfresco.service.ServiceRegistry Java Examples

The following examples show how to use org.alfresco.service.ServiceRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetMethodRegressionTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext();
    ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    davHelper = (WebDAVHelper) applicationContext.getBean(WebDAVHelper.BEAN_NAME);
    auditRegistry = (AuditModelRegistryImpl) applicationContext.getBean(AUDIT_REGISTRY_BEAN_NAME);

    auditService = registry.getAuditService();
    fileFolderService = registry.getFileFolderService();
    transactionService = registry.getTransactionService();

    testingMethod = new GetMethod();
    mockResponse = new MockHttpServletResponse();

    restartTransaction(TransactionActionEnum.ACTION_NONE);
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    companyHomeNodeRef = registry.getNodeLocatorService().getNode(CompanyHomeNodeLocator.NAME, null, null);
    rootTestFolder = fileFolderService.create(companyHomeNodeRef, ROOT_TEST_FOLDER_NAME, ContentModel.TYPE_FOLDER).getNodeRef();
}
 
Example #2
Source File: ExporterComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void before() throws Exception
{
    nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
    exporterService = (ExporterService)applicationContext.getBean("exporterComponent");
    importerService = (ImporterService)applicationContext.getBean("importerComponent");
    fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService");
    categoryService = (CategoryService) applicationContext.getBean("categoryService");     
    transactionService = (TransactionService) applicationContext.getBean("transactionService");
    permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService");

    this.authenticationService = (MutableAuthenticationService) applicationContext.getBean("AuthenticationService");
    this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    contentLocaleToRestore = I18NUtil.getContentLocale();
    localeToRestore = I18NUtil.getLocale();
}
 
Example #3
Source File: AuditableAspectTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    // Set the services
    this.transactionService = serviceRegistry.getTransactionService();
    this.nodeService = serviceRegistry.getNodeService();
    this.contentService = serviceRegistry.getContentService();
    this.behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
    
    AuthenticationUtil.setRunAsUserSystem();
    
    // Create the store and get the root node reference
    this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(storeRef);
}
 
Example #4
Source File: SOLRWebScriptTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    ctx = getServer().getApplicationContext();

    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    nodeService = serviceRegistry.getNodeService();
    fileFolderService = serviceRegistry.getFileFolderService();
    namespaceService = serviceRegistry.getNamespaceService();
    txnHelper = transactionService.getRetryingTransactionHelper();
    nodeDAO = (NodeDAO)ctx.getBean("nodeDAO");
    solrTrackingComponent = (SOLRTrackingComponent) ctx.getBean("solrTrackingComponent");

    admin = AuthenticationUtil.getAdminUserName();

    AuthenticationUtil.setFullyAuthenticatedUser(admin);
    
    storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + ".1." + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
}
 
Example #5
Source File: ProcessesImplTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);

    processes = (Processes) applicationContext.getBean(PROCESSES_BEAN_NAME);

    ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    workflowService = registry.getWorkflowService();
    personService = registry.getPersonService();

    transaction = registry.getTransactionService().getUserTransaction();
    transaction.begin();

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    AuthenticationUtil.setRunAsUser(AuthenticationUtil.getAdminUserName());

    NodeRef adminUserNodeRef = personService.getPerson(AuthenticationUtil.getAdminUserName());

    WorkflowDefinition workflowDefinition = findAppropriateWorkflowDefinitionId();

    for (int i = 0; i < ACTIVE_WORKFLOWS_INITIAL_AMOUNT; i++)
    {
        startWorkflow(workflowDefinition, adminUserNodeRef);
    }
}
 
Example #6
Source File: FileImporterTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setUp()
{
    ctx = ApplicationContextHelper.getApplicationContext();
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

    nodeService = serviceRegistry.getNodeService();
    searchService = serviceRegistry.getSearchService();
    dictionaryService = serviceRegistry.getDictionaryService();
    contentService = serviceRegistry.getContentService();
    authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    permissionService = serviceRegistry.getPermissionService();
    mimetypeService = serviceRegistry.getMimetypeService();
    namespaceService = serviceRegistry.getNamespaceService();
    transactionService = serviceRegistry.getTransactionService();

    authenticationComponent.setSystemUserAsCurrentUser();
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
}
 
Example #7
Source File: AbstractMimeMessage.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void buildMessage(FileInfo fileInfo, ServiceRegistry serviceRegistry) throws MessagingException
{
    checkParameter(serviceRegistry, "ServiceRegistry");
    this.content = null;
    this.serviceRegistry = serviceRegistry;
    this.imapService = serviceRegistry.getImapService();
    this.messageFileInfo = fileInfo;
    this.isMessageInSitesLibrary = imapService.getNodeSiteContainer(messageFileInfo.getNodeRef()) != null ? true : false;
    RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
    txHelper.setMaxRetries(MAX_RETRIES);
    txHelper.setReadOnly(false);
    txHelper.doInTransaction(new RetryingTransactionCallback<Object>() {
        public Object execute() throws Throwable
        {
            buildMessageInternal();
            return null;
        }
    }, false);
    
}
 
Example #8
Source File: ScriptNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param nodeRef   The NodeRef this Node wrapper represents
 * @param services  The ServiceRegistry the Node can use to access services
 * @param scope     Root scope for this Node
 */
public ScriptNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
{
    if (nodeRef == null)
    {
        throw new IllegalArgumentException("NodeRef must be supplied.");
    }
    
    if (services == null)
    {
        throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
    }
    
    this.nodeRef = nodeRef;
    this.id = nodeRef.getId();
    this.services = services;
    this.nodeService = services.getNodeService();
    this.fileFolderService = services.getFileFolderService();
    this.retryingTransactionHelper = services.getTransactionService().getRetryingTransactionHelper();
    this.scope = scope;
    renditionService2 = services.getRenditionService2();
    renditionDefinitionRegistry2 = renditionService2.getRenditionDefinitionRegistry2();
    synchronousTransformClient = services.getSynchronousTransformClient();
}
 
Example #9
Source File: AbstractContentTransformerTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Ensures that the temp locations are cleaned out before the tests start
 */
@Override
protected void setUp() throws Exception
{
    // Grab a suitably configured context
    ctx = MiscContextTestSuite.getMinimalContext();

    // Grab other useful beans
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    mimetypeService = serviceRegistry.getMimetypeService();
    transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");

    // perform a little cleaning up
    long now = System.currentTimeMillis();
    TempFileProvider.TempFileCleanerJob.removeFiles(now);
}
 
Example #10
Source File: TemplateNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param nodeRef       The NodeRef this Node wrapper represents
 * @param services      The ServiceRegistry the TemplateNode can use to access services
 * @param resolver      Image resolver to use to retrieve icons
 */
public TemplateNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver)
{
    if (nodeRef == null)
    {
        throw new IllegalArgumentException("NodeRef must be supplied.");
    }
  
    if (services == null)
    {
        throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
    }
    
    this.nodeRef = nodeRef;
    this.id = nodeRef.getId();
    this.services = services;
    this.imageResolver = resolver;
    
    this.properties = new QNameMap<String, Serializable>(this);
}
 
Example #11
Source File: ConfigurableServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void before() throws Exception
{
	this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
	this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
	this.configurableService = (ConfigurableService)this.applicationContext.getBean("configurableService");
	
	this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
       this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
       
       // Create the node used for tests
       this.nodeRef = this.nodeService.createNode(
               this.rootNodeRef,
			ContentModel.ASSOC_CHILDREN,
               ContentModel.ASSOC_CHILDREN,
               ContentModel.TYPE_CONTAINER).getChildRef();
}
 
Example #12
Source File: ActivitiScriptNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Serializable convertValueForScript(ServiceRegistry serviceRegistry, Scriptable theScope, QName qname, Serializable value)
{
    // ALF-14863: If script-node is used outside of Script-call (eg. Activiti evaluating an expression that contains variables of type ScriptNode)
    // a scope should be created solely for this conversion. The scope will ALWAYS be set when value-conversion is called from the
    // ScriptProcessor
    ensureScopePresent();
    if (theScope == null)
    {
        theScope = scope;
    }

    if (value instanceof NodeRef)
    {
        return new ActivitiScriptNode(((NodeRef)value), serviceRegistry);
    }
    else if (value instanceof Date)
    {
        return value;
    }
    else
    {
        return super.convertValueForScript(serviceRegistry, theScope, qname, value);
    }
}
 
Example #13
Source File: DifferrentMimeTypeTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    mimetypeService = serviceRegistry.getMimetypeService();
    transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");
    registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry");
    transactionService = serviceRegistry.getTransactionService();
    repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
    nodeService = serviceRegistry.getNodeService();
    contentService = serviceRegistry.getContentService();
    
    assertNotNull("MimetypeMap not present", this.mimetypeService);
    assertNotNull("ServiceRegistry not present", serviceRegistry);
    assertNotNull("TransformerDebug not present", transformerDebug);
    assertNotNull("TransformerConfig not present", transformerConfig);
    assertNotNull("transactionService not present", transactionService);
    assertNotNull("repositoryHelper not present", repositoryHelper);
    assertNotNull("nodeService not present", nodeService);
    assertNotNull("contentService not present", contentService);
}
 
Example #14
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * <br>
 * Creating node - CheckOut - Add write lock to working copy - Unlock working copy - CancelCheckOut
 */
@Test
public void testCancelCheckoutUnlockedWCopy()
{
    ServiceRegistry serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    CheckOutCheckInService securityCOCIService = serviceRegistry.getCheckOutCheckInService();
    NodeRef folderA = createFolder(rootNodeRef, "testMnt9502_" + System.currentTimeMillis());
    assertNotNull(folderA);
    NodeRef clucc = createContent("checkout_lock_unlock_cancelCO", folderA);
    assertNotNull(clucc);
    
    NodeRef wc = securityCOCIService.checkout(clucc);
    lockService.lock(wc, LockType.WRITE_LOCK, 60*60);
    lockService.unlock(wc);
    securityCOCIService.cancelCheckout(wc);
}
 
Example #15
Source File: Document.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Document(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
{
    super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);

    Serializable val = nodeProps.get(ContentModel.PROP_CONTENT);

    if ((val != null) && (val instanceof ContentData)) {
        ContentData cd = (ContentData)val;
        String mimeType = cd.getMimetype();
        String mimeTypeName = sr.getMimetypeService().getDisplaysByMimetype().get(mimeType);
        contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
    }

    setIsFolder(false);
    setIsFile(true);
}
 
Example #16
Source File: ChildAssociation.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param services ServiceRegistry
 * @param childAssocRef ChildAssociationRef
 * @param scope Scriptable
 */
public ChildAssociation(ServiceRegistry services, ChildAssociationRef childAssocRef, Scriptable scope)
{
	ParameterCheck.mandatory("Service registry", services);
	ParameterCheck.mandatory("Child association reference", childAssocRef);		
	this.services = services;
	this.childAssocRef = childAssocRef;
	if (scope != null)
	{
		this.scope = scope;
	}
}
 
Example #17
Source File: TemplateNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Serializable convertProperty(
        Serializable value, QName name, ServiceRegistry services, TemplateImageResolver resolver)
{
    if (value instanceof ContentData)
    {
        // ContentData object properties are converted to TemplateContentData objects
        // so the content and other properties of those objects can be accessed
        return new TemplateContentData((ContentData)value, name);
    }
    else
    {
        return super.convertProperty(value, name, services, resolver);
    }
}
 
Example #18
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    txnHelper = transactionService.getRetryingTransactionHelper();
    
    contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO");
    contentStore = new FileContentStore(ctx, TempFileProvider.getTempDir());
}
 
Example #19
Source File: EncodingDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    txnHelper = transactionService.getRetryingTransactionHelper();
    
    encodingDAO = (EncodingDAO) ctx.getBean("encodingDAO");
}
 
Example #20
Source File: MetadataEncryptorTests.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
    public void setUp() throws Exception
    {
        ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
        transactionService = serviceRegistry.getTransactionService();
//        txnHelper = transactionService.getRetryingTransactionHelper();
        metadataEncryptor = (MetadataEncryptor)ctx.getBean("metadataEncryptor");
        nodeService = serviceRegistry.getNodeService();
        tenantService = (TenantService)ctx.getBean("tenantService");
        dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO");

        AuthenticationUtil.setRunAsUserSystem();
        
        DictionaryBootstrap bootstrap = new DictionaryBootstrap();
        List<String> bootstrapModels = new ArrayList<String>();
        bootstrapModels.add("alfresco/model/dictionaryModel.xml");
        bootstrapModels.add(TEST_MODEL);
//        List<String> labels = new ArrayList<String>();
//        labels.add(TEST_BUNDLE);
        bootstrap.setModels(bootstrapModels);
//        bootstrap.setLabels(labels);
        bootstrap.setDictionaryDAO(dictionaryDAO);
        bootstrap.setTenantService(tenantService);
        bootstrap.bootstrap();
        
        // create a first store directly
        RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>()
        {
            public NodeRef execute()
            {
                StoreRef storeRef = nodeService.createStore(
                        StoreRef.PROTOCOL_WORKSPACE,
                        "Test_" + System.nanoTime());
                return nodeService.getRootNode(storeRef);
            }
        };
        rootNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
    }
 
Example #21
Source File: InviteSender.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService)
{
    this.actionService = services.getActionService();
    this.nodeService = services.getNodeService();
    this.personService = services.getPersonService();
    this.searchService = services.getSearchService();
    this.siteService = services.getSiteService();
    this.fileFolderService = services.getFileFolderService();
    this.repoAdminService = services.getRepoAdminService();
    this.namespaceService = services.getNamespaceService();
    this.repository = repository;
    this.messageService = messageService;
}
 
Example #22
Source File: RepositoryExporterComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before() throws Exception
{
    this.nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
    this.fileFolderService = (FileFolderService)applicationContext.getBean(ServiceRegistry.FILE_FOLDER_SERVICE.getLocalName());
    this.repositoryService = (RepositoryExporterService)applicationContext.getBean("repositoryExporterComponent");
    this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
}
 
Example #23
Source File: CanCheckOutActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 */
protected CanCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
    super(serviceRegistry, Action.CAN_CHECK_OUT);
    permissionEvaluator = new PermissionActionEvaluator(
            serviceRegistry,
            Action.CAN_CHECK_OUT,
            PermissionService.CHECK_OUT);
    lockService = serviceRegistry.getLockService();
}
 
Example #24
Source File: AclCrudDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    txnHelper = transactionService.getRetryingTransactionHelper();
    
    aclCrudDAO = (AclCrudDAO)ctx.getBean("aclCrudDAO");
}
 
Example #25
Source File: JscriptWorkflowDefinition.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create a new instance of <code>WorkflowDefinition</code> from a
 * CMR workflow object model WorkflowDefinition instance
 * 
 * @param cmrWorkflowDefinition an instance of WorkflowDefinition from the CMR workflow object model
 * @param serviceRegistry reference to the Service Registry
 * @param scope the root scripting scope for this object 
 */
public JscriptWorkflowDefinition(final WorkflowDefinition cmrWorkflowDefinition,
			final ServiceRegistry serviceRegistry, final Scriptable scope)
{
	this.id = cmrWorkflowDefinition.id;
	this.name = cmrWorkflowDefinition.name;
	this.version = cmrWorkflowDefinition.version;
	this.title = cmrWorkflowDefinition.title;
	this.description = cmrWorkflowDefinition.description;
	this.serviceRegistry = serviceRegistry;
	this.scope = scope;
}
 
Example #26
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * On setup in transaction implementation
 */
@Before
public void before()
{
    // Set the services
    this.cociService = (CheckOutCheckInService)this.applicationContext.getBean("checkOutCheckInService");
    this.contentService = (ContentService)this.applicationContext.getBean("contentService");
    this.versionService = (VersionService)this.applicationContext.getBean("versionService");
    this.authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("authenticationService");
    this.lockService = (LockService)this.applicationContext.getBean("lockService");
    this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent");
    this.permissionService = (PermissionService)this.applicationContext.getBean("permissionService");
    this.copyService = (CopyService)this.applicationContext.getBean("copyService");
    this.personService = (PersonService) this.applicationContext.getBean("PersonService");
    ServiceRegistry serviceRegistry = (ServiceRegistry) this.applicationContext.getBean("ServiceRegistry");
    this.fileFolderService = serviceRegistry.getFileFolderService();
    this.nodeService = serviceRegistry.getNodeService();
    
    // Authenticate as system to create initial test data set
    this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();
    
    RetryingTransactionCallback<Void> processInitWork = new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            initTestData();
            return null;
        }
    };
    // do the init test data in a new retrying transaction because
    // there may be problems with the DB that needs to be retried; 
    // That is how Alfresco works, it relies on optimistic locking and retries
    transactionService.getRetryingTransactionHelper().doInTransaction(processInitWork, false, true);

}
 
Example #27
Source File: RepositoryStartupTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    AuthenticationUtil.setRunAsUserSystem();
}
 
Example #28
Source File: DescriptorServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test server decriptor
 */
@Test
public void testServerDescriptor()
{
    ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    DescriptorService descriptorService = registry.getDescriptorService();
    Descriptor serverDescriptor = descriptorService.getServerDescriptor();
    
    String major = serverDescriptor.getVersionMajor();
    String minor = serverDescriptor.getVersionMinor();
    String revision = serverDescriptor.getVersionRevision();
    String label = serverDescriptor.getVersionLabel();
    String build = serverDescriptor.getVersionBuild();
    String edition = serverDescriptor.getEdition();
    String id = serverDescriptor.getId();
    
    String version = major + "." + minor + "."  + revision;
    version = buildVersionString(version, label, build);
    
    assertEquals(version, serverDescriptor.getVersion());
    
    int schemaVersion = serverDescriptor.getSchema();
    assertTrue("Server schema version must be greater than 0", schemaVersion > 0);
    
    assertNotNull("edition is null", edition);
    assertEquals("id ", id, "Unknown");
}
 
Example #29
Source File: ScriptTaskListener.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Map<String, Object> getInputMap(DelegateTask delegateTask, String runAsUser) 
{
    HashMap<String, Object> scriptModel = new HashMap<String, Object>(1);
    
    // Add current logged-in user and it's user home
    ActivitiScriptNode personNode = getPersonNode(runAsUser);
    if (personNode != null)
    {
        ServiceRegistry registry = getServiceRegistry();
        scriptModel.put(PERSON_BINDING_NAME, personNode);
        NodeRef userHomeNode = (NodeRef) registry.getNodeService().getProperty(personNode.getNodeRef(), ContentModel.PROP_HOMEFOLDER);
        if (userHomeNode != null)
        {
            scriptModel.put(USERHOME_BINDING_NAME, new ActivitiScriptNode(userHomeNode, registry));
        }
    }
    
    // Add activiti-specific objects
    scriptModel.put(TASK_BINDING_NAME, delegateTask);
    scriptModel.put(EXECUTION_BINDING_NAME, delegateTask.getExecution());
    
    // Add all workflow variables to model
    Map<String, Object> variables = delegateTask.getExecution().getVariables();
    
    for (Entry<String, Object> varEntry : variables.entrySet())
    {
        scriptModel.put(varEntry.getKey(), varEntry.getValue());
    }
    return scriptModel;
}
 
Example #30
Source File: AppliedPatchDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    txnHelper = transactionService.getRetryingTransactionHelper();
    
    appliedPatchDAO = (AppliedPatchDAO) ctx.getBean("appliedPatchDAO");
}