Java Code Examples for org.alfresco.service.cmr.repository.NodeService

The following are top voted examples for showing how to use org.alfresco.service.cmr.repository.NodeService. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: alfresco-repository   File: HTMLRenderingEngineTest.java   View source code 7 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
    super.onSetUpInTransaction();
    this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("ContentService");
    this.renditionService = (RenditionService) this.applicationContext.getBean("RenditionService");
    this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper");
    this.dictionaryService = (DictionaryService) this.applicationContext.getBean("dictionaryService");
    this.companyHome = repositoryHelper.getCompanyHome();
    
    createTargetFolder();
    
    // Setup the basic rendition definition
    QName renditionName = QName.createQName("Test");
    RenditionDefinition rd = renditionService.loadRenditionDefinition(renditionName); 
    if(rd != null)
    {
       RenditionDefinitionPersisterImpl rdp = new RenditionDefinitionPersisterImpl();
       rdp.setNodeService(nodeService);
       rdp.deleteRenditionDefinition(rd);
    }
    def = renditionService.createRenditionDefinition(renditionName, HTMLRenderingEngine.NAME);
}
 
Example 2
Project: alfresco-repository   File: FileFolderLoader.java   View source code 7 votes vote down vote up
/**
 * @param repoState             keep track of repository readiness
 * @param transactionService    ensure proper rollback, where required
 * @param repositoryHelper      access standard repository paths
 * @param fileFolderService     perform actual file-folder manipulation
 */
public FileFolderLoader(
        RepositoryState repoState,
        TransactionService transactionService,
        Repository repositoryHelper,
        FileFolderService fileFolderService,
        NodeService nodeService,
        ContentService contentService,
        BehaviourFilter policyBehaviourFilter)
{
    this.repoState = repoState;
    this.transactionService = transactionService;
    this.repositoryHelper = repositoryHelper;
    this.fileFolderService = fileFolderService;
    this.nodeService = nodeService;
    this.contentService = contentService;
    this.policyBehaviourFilter = policyBehaviourFilter;
    
    this.normalDistribution = new NormalDistributionHelper();
}
 
Example 3
Project: alfresco-repository   File: CMMDownloadTestUtil.java   View source code 7 votes vote down vote up
public CMMDownloadTestUtil(ApplicationContext ctx)
{
    this.transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    this.contentService = ctx.getBean("contentService", ContentService.class);
    this.searchService = ctx.getBean("searchService", SearchService.class);
    this.nodeService = ctx.getBean("nodeService", NodeService.class);
    this.namespaceService = ctx.getBean("namespaceService", NamespaceService.class);
    this.downloadService = ctx.getBean("downloadService", DownloadService.class);
}
 
Example 4
Project: alfresco-repository   File: ExecuteAllRulesActionExecuterTest.java   View source code 6 votes vote down vote up
/**
 * Called at the beginning of all tests
 */
@Override
protected void onSetUpInTransaction() throws Exception
{
    this.checkOutCheckInService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");
    this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
    this.ruleService = (RuleService)this.applicationContext.getBean("ruleService");
    this.actionService = (ActionService)this.applicationContext.getBean("actionService");
    transactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper");
    fileFolderService = applicationContext.getBean("fileFolderService", FileFolderService.class);
    contentService = applicationContext.getBean("contentService", ContentService.class);
    
    AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
    
    // Create the store and get the root node
    this.testStoreRef = this.nodeService.createStore(
            StoreRef.PROTOCOL_WORKSPACE, "Test_"
                    + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);

    // Get the executer instance 
    this.executer = (ExecuteAllRulesActionExecuter)this.applicationContext.getBean(ExecuteAllRulesActionExecuter.NAME);
}
 
Example 5
Project: alfresco-repository   File: RemoteCredentialsServicesTest.java   View source code 6 votes vote down vote up
@BeforeClass public static void initTestsContext() throws Exception
{
    ApplicationContext testContext = APP_CONTEXT_INIT.getApplicationContext();
    
    PRIVATE_REMOTE_CREDENTIALS_SERVICE = (RemoteCredentialsService)testContext.getBean("remoteCredentialsService");
    REMOTE_CREDENTIALS_SERVICE = (RemoteCredentialsService)testContext.getBean("RemoteCredentialsService");
    
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)testContext.getBean("policyBehaviourFilter");
    DICTIONARY_SERVICE     = (DictionaryService)testContext.getBean("dictionaryService");
    NAMESPACE_SERVICE      = (NamespaceService)testContext.getBean("namespaceService");
    REPOSITORY_HELPER      = (Repository)testContext.getBean("repositoryHelper");
    NODE_SERVICE           = (NodeService)testContext.getBean("nodeService");
    PUBLIC_NODE_SERVICE    = (NodeService)testContext.getBean("NodeService");
    PERSON_SERVICE         = (PersonService)testContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
    TRANSACTION_SERVICE    = (TransactionService)testContext.getBean("TransactionService");
    PERMISSION_SERVICE     = (PermissionService)testContext.getBean("permissionService");

    // Switch to a test shared system container
    RemoteCredentialsServiceImpl.setSharedCredentialsSystemContainerName(SHARED_SYSTEM_CONTAINER_NAME);
}
 
Example 6
Project: alfresco-repository   File: HasTagEvaluatorTest.java   View source code 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
    this.nodeService = (NodeService)applicationContext.getBean("nodeService");
    this.taggingService = (TaggingService)applicationContext.getBean("taggingService");
    
    // Create the store and get the root node
    this.testStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
    this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); 

    // Create the node used for tests
    this.nodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();
    
    this.evaluator = (HasTagEvaluator)applicationContext.getBean(HasTagEvaluator.NAME);        
    AuthenticationUtil.setFullyAuthenticatedUser("admin");
}
 
Example 7
Project: alfresco-repository   File: LinksServiceImplTest.java   View source code 6 votes vote down vote up
@BeforeClass public static void initTestsContext() throws Exception
{
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)testContext.getBean("policyBehaviourFilter");
    LINKS_SERVICE          = (LinksService)testContext.getBean("LinksService");
    NODE_SERVICE           = (NodeService)testContext.getBean("nodeService");
    PUBLIC_NODE_SERVICE    = (NodeService)testContext.getBean("NodeService");
    PERSON_SERVICE         = (PersonService)testContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
    PERMISSION_SERVICE     = (PermissionService)testContext.getBean("permissionService");
    SITE_SERVICE           = (SiteService)testContext.getBean("siteService");
    CONTENT_SERVICE        = (ContentService)testContext.getBean("ContentService");

    // Do the setup as admin
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    createUser(TEST_USER);
    
    // We need to create the test site as the test user so that they can contribute content to it in tests below.
    AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
    createTestSites();
}
 
Example 8
Project: alfresco-repository   File: DocumentEmailMessageHandler.java   View source code 6 votes vote down vote up
/**
     * Adds forum node
     * 
     * @param nodeRef Paren node
     * @return Reference to created node
     */
    private NodeRef addForumNode(NodeRef nodeRef)
    {
        NodeService nodeService = getNodeService();
        
//        //Add discussable aspect to content node
//        if (!nodeService.hasAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE))
//        {
//            nodeService.addAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
//        }

        //Create forum node and associate it with content node
        Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
        properties.put(ContentModel.PROP_NAME, forumNodeName);
        ChildAssociationRef childAssoc = nodeService.createNode(nodeRef, ForumModel.ASSOC_DISCUSSION, ForumModel.ASSOC_DISCUSSION, ForumModel.TYPE_FORUM, properties);
        NodeRef forumNode = childAssoc.getChildRef();        

        //Add necessary aspects to forum node
        properties.clear();
        properties.put(ApplicationModel.PROP_ICON, "forum");
        nodeService.addAspect(forumNode, ApplicationModel.ASPECT_UIFACETS, properties);
        
        return forumNode;
    }
 
Example 9
Project: alfresco-repository   File: PeerAssociatedNodeFinder.java   View source code 6 votes vote down vote up
/**
 * @param thisNode NodeRef
 * @return Set<NodeRef>
 */
private Set<NodeRef> processExcludedSet(NodeRef thisNode)
{
    Set<NodeRef> results = new HashSet<NodeRef>(89);
    NodeService nodeService = serviceRegistry.getNodeService();

    // Find any peer nodes (filtering as necessary)
    List<AssociationRef> targets = nodeService.getTargetAssocs(thisNode, RegexQNamePattern.MATCH_ALL);
    boolean filterPeers = !peerAssociationTypes.isEmpty();
    for (AssociationRef target : targets)
    {
        if (!filterPeers || !peerAssociationTypes.contains(target.getTypeQName()))
        {
            results.add(target.getTargetRef());
        }
    }
    return results;
}
 
Example 10
Project: alfresco-repository   File: GetPeopleCannedQuery.java   View source code 6 votes vote down vote up
public GetPeopleCannedQuery(
        NodeDAO nodeDAO,
        QNameDAO qnameDAO,
        CannedQueryDAO cannedQueryDAO,
        TenantService tenantService,
        NodeService nodeService,
        AuthorityService authorityService,
        CannedQueryParameters params)
{
    super(params);
    
    this.nodeDAO = nodeDAO;
    this.qnameDAO = qnameDAO;
    this.cannedQueryDAO = cannedQueryDAO;
    this.tenantService = tenantService;
    this.nodeService = nodeService;
    this.authorityService = authorityService;
    
}
 
Example 11
Project: alfresco-repository   File: MultiUserRenditionTest.java   View source code 6 votes vote down vote up
public  void initContextAndCreateUser()
{
    appContext = ApplicationContextHelper.getApplicationContext();

    authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    contentService = (ContentService) appContext.getBean("ContentService");
    nodeService = (NodeService) appContext.getBean("NodeService");
    permissionService = (PermissionService) appContext.getBean("PermissionService");
    personService = (PersonService) appContext.getBean("PersonService");
    renditionService = (RenditionService) appContext.getBean("RenditionService");
    repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
    transactionService = (TransactionService) appContext.getBean("TransactionService");
    txnHelper = transactionService.getRetryingTransactionHelper();
    ownableService = (OwnableService) appContext.getBean("ownableService");

    ADMIN_USER = AuthenticationUtil.getAdminUserName();
    
    // Create a nonAdminUser
    createUser(NON_ADMIN_USER);

}
 
Example 12
Project: alfresco-repository   File: SystemNodeUtils.java   View source code 6 votes vote down vote up
/**
 * Returns the NodeRef of a given Child Container within the current Tenant's 
 *  System Container, if found
 */
public static NodeRef getSystemChildContainer(final QName childName, final NodeService nodeService, final Repository repositoryHelper)
{
    NodeRef system = getSystemContainer(nodeService, repositoryHelper);

    // Find the container, under system
    List<ChildAssociationRef> containerRefs = nodeService.getChildAssocs(
            system, ContentModel.ASSOC_CHILDREN, childName);

    NodeRef container = null;
    if (containerRefs.size() > 0)
    {
        container = containerRefs.get(0).getChildRef();
        if (containerRefs.size() > 1)
            logger.warn("Duplicate Shared Credentials Containers found: " + containerRefs);
    }

    return container;
}
 
Example 13
Project: alfresco-repository   File: NodeStoreInspector.java   View source code 6 votes vote down vote up
/**
 * Dumps the contents of a node 
 * 
 * @param nodeService NodeService
 * @param nodeRef NodeRef
 * @return String
 */
public static String dumpNode(NodeService nodeService, NodeRef nodeRef)
{
    StringBuilder builder = new StringBuilder();
    
    if (nodeService.exists(nodeRef) == true)
    {
        builder.append(outputNode(0, nodeService, nodeRef));            
    }
    else
    {
        builder.
            append("The node ").
            append(nodeRef.toString()).
            append(" does not exist.");
    }
    
    return builder.toString();
}
 
Example 14
Project: alfresco-repository   File: IsSubTypeEvaluatorTest.java   View source code 6 votes vote down vote up
@Override
protected void onSetUpInTransaction() throws Exception
{
    this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
    
    // Create the store and get the root node
    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,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();
    
    this.evaluator = (IsSubTypeEvaluator)this.applicationContext.getBean(IsSubTypeEvaluator.NAME);
}
 
Example 15
Project: alfresco-repository   File: ContentModelFormProcessor.java   View source code 6 votes vote down vote up
@Override
protected void updateAssociations(NodeService nodeService)
{
    List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, assocQName);
    for (AssociationRef assoc : existingAssocs)
    {
        if (assoc.getTargetRef().equals(targetNodeRef))
        {
            if (logger.isWarnEnabled())
            {
                logger.warn("Attempt to add existing association prevented. " + assoc);
            }
            return;
        }
    }
    nodeService.createAssociation(sourceNodeRef, targetNodeRef, assocQName);
}
 
Example 16
Project: alfresco-repository   File: AuthenticatedTimerJobHandler.java   View source code 5 votes vote down vote up
/**
 * @param jobHandler the {@link JobHandler} to wrap.
 * @param nodeService the UNPROTECTED {@link NodeService} to use for fetching initiator username
 * when only tenant is known. We can't use initiator ScriptNode for this, because this uses the
 * protected {@link NodeService} which requires an authenticated user in that tenant (see {@link #getInitiator(ActivitiScriptNode)}).
 */
public AuthenticatedTimerJobHandler(JobHandler jobHandler, NodeService nodeService) 
{
    if (jobHandler == null)
    {
        throw new IllegalArgumentException("JobHandler to delegate to is required");
    }
    if(nodeService == null)
    {
        throw new IllegalArgumentException("NodeService is required");
    }
    this.unprotectedNodeService = nodeService;
    this.wrappedHandler = jobHandler;
}
 
Example 17
Project: alfresco-repository   File: MSOfficeContentNetworkFile.java   View source code 5 votes vote down vote up
/**
 * Class constructor
 * 
 * @param nodeService NodeService
 * @param contentService ContentService
 * @param mimetypeService MimetypeService
 * @param nodeRef NodeRef
 * @param name String
 */
protected MSOfficeContentNetworkFile(
        NodeService nodeService,
        ContentService contentService,
        MimetypeService mimetypeService,
        NodeRef nodeRef,
        String name)
{
    super(nodeService, contentService, mimetypeService, nodeRef, name);

    // Create the buffered write list
    
    m_writeList = new ArrayList<BufferedWrite>(); 
}
 
Example 18
Project: alfresco-remote-api   File: RemoteFileFolderLoaderTest.java   View source code 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    
    this.repositoryHelper = (Repository)getServer().getApplicationContext().getBean("repositoryHelper");
    this.nodeService = (NodeService)getServer().getApplicationContext().getBean("nodeService");
    this.transactionService = (TransactionService) getServer().getApplicationContext().getBean("TransactionService");
    this.fileFolderService = (FileFolderService) getServer().getApplicationContext().getBean("FileFolderService");

    // Get the path of the shared folder home
    final NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
    final NodeRef sharedHomeNodeRef = repositoryHelper.getSharedHome();
    RetryingTransactionCallback<NodeRef> createFolderWork = new RetryingTransactionCallback<NodeRef>()
    {
        @Override
        public NodeRef execute() throws Throwable
        {
            List<FileInfo> sharedHomeFileInfos = fileFolderService.getNamePath(companyHomeNodeRef, sharedHomeNodeRef);
            sharedHomePath = "/" + sharedHomeFileInfos.get(0).getName();

            String folderName = UUID.randomUUID().toString();
            // Create a folder
            FileInfo folderInfo = fileFolderService.create(sharedHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
            loadHomePath = sharedHomePath + "/" + folderName;
            // Done
            return folderInfo.getNodeRef();
        }
    };
    AuthenticationUtil.pushAuthentication();            // Will be cleared later
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();

    loadHomeNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(createFolderWork);
}
 
Example 19
Project: alfresco-remote-api   File: InvitationWebScriptTest.java   View source code 5 votes vote down vote up
public static String makeAvatar(final NodeService nodeService, final NodeRef person)
{
    nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null);
    ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName,
                ContentModel.TYPE_CONTENT);
    NodeRef avatar = assoc.getChildRef();
    nodeService.createAssociation(person, avatar, ContentModel.ASSOC_AVATAR);
    return "api/node/" + avatar + "/content/thumbnails/avatar";
}
 
Example 20
Project: alfresco-repository   File: SortedResultSet.java   View source code 5 votes vote down vote up
ContentSizeOrder(QName attribute, boolean ascending, NodeService nodeService)
{
    this.attribute = attribute;
    this.ascending = ascending;
    this.nodeService = nodeService;

}
 
Example 21
Project: alfresco-repository   File: CheckOutActionExecuterTest.java   View source code 5 votes vote down vote up
@Override
protected void onSetUpInTransaction() throws Exception
{
    this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");

    this.checkOutCheckInService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");

    AuthenticationComponent authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());

    // Create the store and get the root node
    this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);

    // Create 'content' the node used for tests
    this.nodeRefContent = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}contenttestnode"),
            ContentModel.TYPE_CONTENT).getChildRef();

    // Create 'folder' the node used for tests
    this.nodeRefFolder = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}foldertestnode"),
            ContentModel.TYPE_FOLDER).getChildRef();

    // Get the executer instance
    this.executer = (CheckOutActionExecuter) this.applicationContext.getBean(CheckOutActionExecuter.NAME);
}
 
Example 22
Project: alfresco-repository   File: ContentMetadataExtracterTest.java   View source code 5 votes vote down vote up
@Override
protected void onSetUpInTransaction() throws Exception
{
    this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("contentService");
    
    AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();

    // Create the store and get the root node
    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,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();

    // Setup the content from the PDF test data
    ContentWriter cw = this.contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
    cw.setMimetype(MimetypeMap.MIMETYPE_PDF);
    cw.putContent(AbstractContentTransformerTest.loadQuickTestFile("pdf"));

    // Get the executer instance
    this.executer = (ContentMetadataExtracter) this.applicationContext.getBean("extract-metadata");
}
 
Example 23
Project: alfresco-repository   File: StandardRenditionLocationResolverImpl.java   View source code 5 votes vote down vote up
/**
 * This method creates a {@link RenditionLocation} object from the specified destination node.
 * This is formed from the specified destination NodeRef, its cm:name and its primary parent.
 * 
 * @param destination NodeRef
 * @return RenditionLocationImpl
 * @throws RenditionServiceException if the destination node does not exist.
 */
private RenditionLocationImpl createNodeLocation(NodeRef destination)
{
    NodeService nodeService = serviceRegistry.getNodeService();
    if(nodeService.exists(destination)==false)
        throw new RenditionServiceException("The rendition destination node does not exist! NodeRef: "+destination);
    
    NodeRef parentRef = nodeService.getPrimaryParent(destination).getParentRef();
    String destinationCmName = (String) nodeService.getProperty(destination, ContentModel.PROP_NAME);
    RenditionLocationImpl location  = new RenditionLocationImpl(parentRef, destination, destinationCmName);
    return location;
}
 
Example 24
Project: alfresco-repository   File: XSLTProcessorTest.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
    super.onSetUpInTransaction();
    this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("ContentService");
    this.fileFolderService = (FileFolderService) this.applicationContext.getBean("FileFolderService");
    this.xsltProcessor = (TemplateProcessor) this.applicationContext.getBean("xsltProcessor");
    this.templateService = (TemplateService) this.applicationContext.getBean("TemplateService");
    this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper");
    this.companyHome = repositoryHelper.getCompanyHome();
}
 
Example 25
Project: alfresco-remote-api   File: RepoService.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
public RepoService(ApplicationContext applicationContext) throws Exception
   {
   	this.applicationContext = applicationContext;
   	this.publicApiContext = new PublicApiTestContext(applicationContext);
   	this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
   	this.siteService = (SiteService)applicationContext.getBean("SiteService");
   	this.activityService = (ActivityService)applicationContext.getBean("activityService");
   	this.fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
   	this.contentService = (ContentService)applicationContext.getBean("ContentService");
   	this.commentService = (CommentService)applicationContext.getBean("CommentService");
   	this.nodeService = (NodeService)applicationContext.getBean("NodeService");
   	this.preferenceService = (PreferenceService)applicationContext.getBean("PreferenceService");
   	this.taggingService = (TaggingService)applicationContext.getBean("TaggingService");
   	this.ratingService = (RatingService)applicationContext.getBean("RatingService");
   	this.tenantService = (TenantService)applicationContext.getBean("tenantService");
   	this.tenantAdminService = (TenantAdminService)applicationContext.getBean("tenantAdminService");
   	this.personService = (PersonService)applicationContext.getBean("PersonService");
   	this.contentStoreCleaner = (ContentStoreCleaner)applicationContext.getBean("contentStoreCleaner");
   	this.postDAO = (ActivityPostDAO)applicationContext.getBean("postDAO");
   	this.nodeRatingSchemeRegistry = (NamedObjectRegistry<RatingScheme>)applicationContext.getBean("nodeRatingSchemeRegistry");
   	this.cociService = (CheckOutCheckInService)applicationContext.getBean("CheckoutCheckinService");
   	this.favouritesService = (FavouritesService)applicationContext.getBean("FavouritesService");
   	this.dictionaryService =  (DictionaryService)applicationContext.getBean("dictionaryService");
   	this.invitationService = (InvitationService)applicationContext.getBean("InvitationService");
   	this.lockService = (LockService)applicationContext.getBean("LockService");
   	this.cmisConnector = (CMISConnector)applicationContext.getBean("CMISConnector");
   	this.nodeIndexer = (NodeIndexer)applicationContext.getBean("nodeIndexer");
   	this.activities = (Activities)applicationContext.getBean("activities");
   	this.hiddenAspect = (HiddenAspect)applicationContext.getBean("hiddenAspect");
   	this.networksService = (NetworksService)applicationContext.getBean("networksService");
   	this.namespaceService = (NamespaceService)applicationContext.getBean("namespaceService"); 
   	this.transactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper");

       Scheduler scheduler = (Scheduler)applicationContext.getBean("schedulerFactory");
   	
   	JobDetailBean contentStoreCleanerJobDetail = (JobDetailBean)applicationContext.getBean("contentStoreCleanerJobDetail");
       scheduler.pauseJob(contentStoreCleanerJobDetail.getName(), contentStoreCleanerJobDetail.getGroup());

       ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)applicationContext.getBean("ActivitiesFeed");
       ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
       this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
       this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
       this.feedGeneratorJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedGeneratorJobDetail");
       this.postLookupJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("postLookupJobDetail");
       this.feedCleanerJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedCleanerJobDetail");
       this.postCleanerJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("postCleanerJobDetail");
       this.feedNotifierJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedNotifierJobDetail");
   	this.feedCleaner = (FeedCleaner)activitiesFeedCtx.getBean("feedCleaner");

       // Pause activities jobs so that we aren't competing with their scheduled versions
       scheduler.pauseJob(feedGeneratorJobDetail.getName(), feedGeneratorJobDetail.getGroup());
       scheduler.pauseJob(postLookupJobDetail.getName(), postLookupJobDetail.getGroup());
       scheduler.pauseJob(feedCleanerJobDetail.getName(), feedCleanerJobDetail.getGroup());
       scheduler.pauseJob(postCleanerJobDetail.getName(), postCleanerJobDetail.getGroup());
       scheduler.pauseJob(feedNotifierJobDetail.getName(), feedNotifierJobDetail.getGroup());

       this.systemNetwork = new TestNetwork(TenantService.DEFAULT_DOMAIN, true);
}
 
Example 26
Project: alfresco-repository   File: ExporterComponentTest.java   View source code 5 votes vote down vote up
private void dumpNodeStore(Locale locale)
{
 
    System.out.println(locale.getDisplayLanguage() + " LOCALE: ");
    I18NUtil.setLocale(locale);
    System.out.println(NodeStoreInspector.dumpNodeStore((NodeService) applicationContext.getBean("NodeService"), storeRef));
}
 
Example 27
Project: alfresco-repository   File: CMISRenditionMapping.java   View source code 5 votes vote down vote up
public CMISRenditionMapping(NodeService nodeService, ContentService contentService,
        RenditionService renditionService, TransactionService transactionService,
        Map<String, List<String>> renditionKinds)
{
    this.nodeService = nodeService;
    this.contentService = contentService;
    this.renditionService = renditionService;
    this.transactionService = transactionService;

    if (renditionKinds == null)
    {
        this.kindToRenditionNames = new HashMap<String, List<String>>();
    } else
    {
        this.kindToRenditionNames = renditionKinds;
    }
    renditionNamesToKind = new HashMap<String, String>();
    for (Entry<String, List<String>> entry : renditionKinds.entrySet())
    {
        for (String renditionName : entry.getValue())
        {
            renditionNamesToKind.put(renditionName, entry.getKey());
        }
    }

    cacheRenditionSizes();
}
 
Example 28
Project: alfresco-repository   File: XSLTRenderingEngineTest.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
    super.onSetUpInTransaction();
    this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("ContentService");
    this.fileFolderService = (FileFolderService) this.applicationContext.getBean("FileFolderService");
    this.xsltProcessor = (TemplateProcessor) this.applicationContext.getBean("xsltProcessor");
    this.templateService = (TemplateService) this.applicationContext.getBean("TemplateService");
    this.renditionService = (RenditionService) this.applicationContext.getBean("RenditionService");
    
    this.companyHome = this.applicationContext.getBean("repositoryHelper", Repository.class).getCompanyHome();
}
 
Example 29
Project: alfresco-repository   File: AspectsIntegrityEvent.java   View source code 5 votes vote down vote up
protected AspectsIntegrityEvent(
        NodeService nodeService,
        DictionaryService dictionaryService,
        NodeRef nodeRef)
{
    super(nodeService, dictionaryService, nodeRef, null, null);
}
 
Example 30
Project: alfresco-remote-api   File: InvitationWebScriptTest.java   View source code 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();

    this.authenticationService = (MutableAuthenticationService) getServer().getApplicationContext().getBean(
                "AuthenticationService");
    this.authenticationComponent = (AuthenticationComponent) getServer().getApplicationContext().getBean(
                "authenticationComponent");
    this.personService = (PersonService) getServer().getApplicationContext().getBean("PersonService");
    this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService");
    this.transactionService = (TransactionService) getServer().getApplicationContext().getBean("TransactionService");
    this.invitationServiceImpl = (InvitationServiceImpl) getServer().getApplicationContext().getBean("invitationService");
    
    // turn off email sending to prevent errors during unit testing 
    // (or sending out email by accident from tests)
    InviteServiceTest.configureMailExecutorForTestMode(this.getServer());
    
    this.authenticationComponent.setSystemUserAsCurrentUser();

    // Create users
    createUser(userOne, "Joe", "Bloggs");
    createUser(userTwo, "Jane", "Doe");
    createUser(userThree, "Nick", "Smith");

    // Do tests as user one
    this.authenticationComponent.setCurrentUser(userOne);
}
 
Example 31
Project: alfresco-repository   File: AbstractRenderingEngineTest.java   View source code 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();

    this.contentService = mock(ContentService.class);
    this.nodeService = mock(NodeService.class);
    engine = new TestRenderingEngine();
    engine.setContentService(contentService);
    engine.setNodeService(nodeService);
    engine.setBehaviourFilter(mock(BehaviourFilter.class));
}
 
Example 32
Project: alfresco-repository   File: SiteServiceImplMoreTest.java   View source code 5 votes vote down vote up
@BeforeClass public static void initStaticData() throws Exception
{
    AUTHORITY_SERVICE         = APP_CONTEXT_INIT.getApplicationContext().getBean("AuthorityService", AuthorityService.class);
    NAMESPACE_SERVICE         = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class);
    NODE_SERVICE              = APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService", NodeService.class);
    NODE_ARCHIVE_SERVICE      = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeArchiveService", NodeArchiveService.class);
    SITE_SERVICE              = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class);
    COCI_SERVICE              = APP_CONTEXT_INIT.getApplicationContext().getBean("checkOutCheckInService", CheckOutCheckInService.class);
    TRANSACTION_HELPER        = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    PERMISSION_SERVICE        = APP_CONTEXT_INIT.getApplicationContext().getBean("permissionServiceImpl", PermissionService.class);
    AUTHENTICATION_SERVICE    = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationService", MutableAuthenticationService.class);
    PERSON_SERVICE            = APP_CONTEXT_INIT.getApplicationContext().getBean("PersonService", PersonService.class);
    FILE_FOLDER_SERVICE       = APP_CONTEXT_INIT.getApplicationContext().getBean("FileFolderService",FileFolderService.class);
    AUTHENTICATION_COMPONENT  = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationComponent",AuthenticationComponent.class);
    LOCK_SERVICE              = APP_CONTEXT_INIT.getApplicationContext().getBean("lockService",LockService.class);
    
    // We'll create this test content as admin.
    final String admin = AuthenticationUtil.getAdminUserName();
    
    TEST_SITE_NAME = GUID.generate();
    TEST_SUB_SITE_NAME = GUID.generate();
    
    final QName subSiteType = QName.createQName("testsite", "testSubsite", NAMESPACE_SERVICE);
    
    STATIC_TEST_SITES.createSite("sitePreset", TEST_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, admin);
    STATIC_TEST_SITES.createSite("sitePreset", TEST_SUB_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, subSiteType, admin);
    
    TEST_SITE_WITH_MEMBERS = STATIC_TEST_SITES.createTestSiteWithUserPerRole(SiteServiceImplMoreTest.class.getSimpleName(), "sitePreset", SiteVisibility.PUBLIC, admin);
}
 
Example 33
Project: alfresco-repository   File: ContentModelFormProcessor.java   View source code 5 votes vote down vote up
@Override
protected void updateAssociations(NodeService nodeService)
{
    List<ChildAssociationRef> existingChildren = nodeService.getChildAssocs(sourceNodeRef);
    boolean childAssocDoesNotExist = true;
    for (ChildAssociationRef assoc : existingChildren)
    {
        if (assoc.getChildRef().equals(targetNodeRef))
        {
            childAssocDoesNotExist = false;
            break;
        }
    }
    if (childAssocDoesNotExist)
    {
        if (logger.isWarnEnabled())
        {
            StringBuilder msg = new StringBuilder();
            msg.append("Attempt to remove non-existent child association prevented. ").append(sourceNodeRef)
                        .append("|").append(targetNodeRef).append(assocQName);
            logger.warn(msg.toString());
        }
        return;
    }

    nodeService.removeChild(sourceNodeRef, targetNodeRef);
}
 
Example 34
Project: alfresco-repository   File: RepositoryStartStopTest.java   View source code 5 votes vote down vote up
public void doTestBasicWriteOperations(ApplicationContext ctx) throws Exception
{
    // Grab the beans we need
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
   
    // So we can write test nodes
    AuthenticationUtil.setRunAsUserSystem();
    
    // Check it looks fine
    assertFalse("The transaction is read-only - further unit tests are pointless.", transactionService.isReadOnly());
    
    // A basic write operation on a node
    RetryingTransactionCallback<Void> addPropertyCallback = new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            NodeService nodeService = serviceRegistry.getNodeService();
            NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
            nodeService.setProperty(rootNodeRef, ContentModel.PROP_NAME, "SanityCheck");
            writeTestWorked = true;
            return null;
        }
    };
    
    // Now do a write operation, and ensure it worked
    writeTestWorked = false;
    transactionService.getRetryingTransactionHelper().doInTransaction(addPropertyCallback, false, true);
    assertTrue("The Node Write didn't occur or failed with an error", writeTestWorked);
}
 
Example 35
Project: alfresco-remote-api   File: NodeBrowserPost.java   View source code 4 votes vote down vote up
/**
 * @param nodeService node service
 */
public void setNodeService(NodeService nodeService)
{
    this.nodeService = nodeService;
}
 
Example 36
Project: alfresco-remote-api   File: ExcludedTypes.java   View source code 4 votes vote down vote up
public void setNodeService(NodeService nodeService)
   {
	this.nodeService = nodeService;
}
 
Example 37
Project: alfresco-repository   File: PseudoFileOverlayImpl.java   View source code 4 votes vote down vote up
public void setNodeService(NodeService nodeService)
{
    this.nodeService = nodeService;
}
 
Example 38
Project: alfresco-remote-api   File: RestVariableHelper.java   View source code 4 votes vote down vote up
public void setNodeService(NodeService nodeService)
{
    this.nodeService = nodeService;
}
 
Example 39
Project: alfresco-repository   File: AbstractRatingRollupAlgorithm.java   View source code 4 votes vote down vote up
public void setNodeService(NodeService nodeService)
{
    this.nodeService = nodeService;
}
 
Example 40
Project: alfresco-repository   File: FullNodeServiceTest.java   View source code 4 votes vote down vote up
protected NodeService getNodeService()
{
    return (NodeService) applicationContext.getBean("NodeService");
}