org.springframework.context.support.AbstractRefreshableApplicationContext#org.alfresco.repo.security.authentication.AuthenticationUtil源码实例Demo

下面列出了org.springframework.context.support.AbstractRefreshableApplicationContext#org.alfresco.repo.security.authentication.AuthenticationUtil 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: alfresco-remote-api   文件: MoveMethod.java
/**
 * Unlock only if the node was locked in the first place.
 */
private void unlock(final NodeRef nodeRef, LockInfo lockInfo)
{
    if (lockInfo != null && lockInfo.isLocked())
    {
        if (lockInfo.isExpired())
        {
            // If the lock expired unlock as system user
            AuthenticationUtil.runAs(new RunAsWork<Void>()
            {
                public Void doWork() throws Exception
                {
                    getDAVHelper().getLockService().unlock(nodeRef);
                    return null;
                }
            }, AuthenticationUtil.getSystemUserName());
        }
        // else unlock as current user
        else
        {
            getDAVHelper().getLockService().unlock(nodeRef);
        }
    }
}
 
/**
 * Run the authentication filter
 * 
 * @param context ServletContext
 * @param req ServletRequest
 * @param resp ServletResponse
 * @param chain FilterChain
 * @exception ServletException
 * @exception IOException
 */
@Override
public void doFilter(ServletContext context, ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException
{
    try
    {
        doFilterInternal(context, req, resp, chain);
    }
    finally
    {
        if (logger.isTraceEnabled())
        {
            logger.debug("About to clear the security context");
        }
        AuthenticationUtil.clearCurrentSecurityContext();
    }
}
 
@After public void tidyUpUnwantedNodeRefs()
{
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    
    txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
            {
                public Void execute() throws Throwable
                {
                    for (NodeRef node : nodesToBeTidiedUp)
                    {
                        if (nodeService.exists(node))
                            nodeService.deleteNode(node);
                    }
                    return null;
                }
            });  
    nodesToBeTidiedUp.clear();
}
 
源代码4 项目: alfresco-remote-api   文件: RatingRestApiTest.java
@Override
public void tearDown() throws Exception
{
    super.tearDown();

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());

    transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
            {
                public Void execute() throws Throwable
                {
                    if (testNode != null && nodeService.exists(testNode))
                    {
                        nodeService.deleteNode(testNode);
                        deleteUser(USER_ONE);
                        deleteUser(USER_TWO);
                    }
                    return null;
                }          
            });        
}
 
源代码5 项目: alfresco-repository   文件: Repository.java
/**
 * Gets the currently authenticated person
 * Includes any overlay authentication set by runas 
 * @return  person node ref
 */
public NodeRef getPerson()
{
    RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
    {
        @Override
        public NodeRef execute() throws Throwable
        {
            NodeRef person = null;
            String currentUserName = AuthenticationUtil.getRunAsUser();
            if (currentUserName != null)
            {
                if (personService.personExists(currentUserName))
                {
                    person = personService.getPerson(currentUserName);
                }
            }
            return person;
        }
    };
    return retryingTransactionHelper.doInTransaction(callback, true);
}
 
源代码6 项目: alfresco-repository   文件: MultiTDemoTest.java
public void test07LoginTenantGuests() throws Throwable
{
    logger.info("Login tenant guests");
    
    try
    {
        AuthenticationUtil.clearCurrentSecurityContext();
        
        for (final String tenantDomain : tenants)
        {
            loginLogoutUser(tenantService.getDomainUser(DEFAULT_GUEST_UN, tenantDomain), DEFAULT_GUEST_UN);
        }
    }   
    catch (Throwable t)
    {
        StringWriter stackTrace = new StringWriter();
        t.printStackTrace(new PrintWriter(stackTrace));
        System.err.println(stackTrace.toString());
        throw t;
    }
}
 
@Override
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext(CONTEXTS);
    // Get the required services
    transactionService = (TransactionService) ctx.getBean("TransactionService");
    subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService");
    personService = (PersonService) ctx.getBean("PersonService");
    nodeService = (NodeService) ctx.getBean("NodeService");
    searchService = (SearchService) ctx.getBean("SearchService");
    repositoryHelper = (Repository) ctx.getBean("repositoryHelper");

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());

    txn = transactionService.getNonPropagatingUserTransaction(false);
    txn.begin();

    createPerson(USER_BOB);
    createPerson(USER_TOM);
    createPerson(USER_LISA);
}
 
@Override
protected void tearDown() throws Exception
{
    super.tearDown();
    
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    
    personManager.clearPeople();
    
    // Zap any replication definitions we created
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for(ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
       replicationService.deleteReplicationDefinition(rd);
    }
    AuthenticationUtil.clearCurrentSecurityContext();
    
    txn.commit();
}
 
public void process(final NodeRef person) throws Throwable
{
    // note: runAs before runAsTenant (to avoid clearing tenant context, if no previous auth)
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        @Override
        public Object doWork() throws Exception
        {
            return TenantUtil.runAsTenant(new TenantRunAsWork<Void>()
            {
                public Void doWork() throws Exception
                {
                   RunAsWorker.this.doWork(person);
                    return null;
                }
            }, tenantDomain);
        }
    }, userName);
}
 
源代码10 项目: alfresco-remote-api   文件: WebDAVMethodTest.java
@Test
public void checkLockedNodeTenantTest()
{
    setUpApplicationContext();

    // Create a tenant domain
    TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>() {
        public Object doWork() throws Exception {
            if (!tenantAdminService.existsTenant(TEST_TENANT_DOMAIN))
            {
                tenantAdminService.createTenant(TEST_TENANT_DOMAIN, (DEFAULT_ADMIN_PW + " " + TEST_TENANT_DOMAIN).toCharArray(), null);
            }
            return null;
        }
    }, TenantService.DEFAULT_DOMAIN);
    
    TenantUtil.runAsUserTenant(new TenantUtil.TenantRunAsWork<Object>()
    {
        @Override
        public Object doWork() throws Exception
        {
            checkLockedNodeTestTenantWork();
            return null;
        }
    }, AuthenticationUtil.getAdminUserName(), TEST_TENANT_DOMAIN);
}
 
源代码11 项目: alfresco-remote-api   文件: RepoStore.java
public Object findTemplateSource(final String name)
    throws IOException
{
    return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {
            return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
            {
                public Object execute() throws Exception
                {
                    RepoTemplateSource source = null;
                    NodeRef nodeRef = findNodeRef(name);
                    if (nodeRef != null)
                    {
                        source = new RepoTemplateSource(nodeRef);
                    }
                    return source;
                }
            }, true);
        }
    }, AuthenticationUtil.getSystemUserName());
}
 
@After
public void tearDown() throws Exception
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    for (final String user : users)
    {
        transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
        {
            @Override
            public Void execute() throws Throwable
            {
                deleteUser(user, null);
                return null;
            }
        });
    }
    users.clear();
    AuthenticationUtil.clearCurrentSecurityContext();
}
 
源代码13 项目: alfresco-repository   文件: FeedNotifierJobTest.java
@After
public void cleanUp()
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @SuppressWarnings("synthetic-access")
        public Void execute() throws Throwable
        {
            personService.deletePerson(failingPersonNodeRef);
            personService.deletePerson(personNodeRef);
            return null;
        }
    }, false, true);
    AuthenticationUtil.clearCurrentSecurityContext();
}
 
源代码14 项目: alfresco-repository   文件: MultiTDemoTest.java
public void test18AddCustomWebClient()
{
    // note: add as demo files - need to re-start Alfresco to see custom web client config / messages 
    logger.info("test add custom web client config");
    
    for (final String tenantDomain : tenants)
    {    
        final String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
        
        TenantUtil.runAsUserTenant(new TenantRunAsWork<Object>()
        {
            public Object doWork() throws Exception
            {
                NodeRef webClientExtFolder = getWebClientExtensionNodeRef(SPACES_STORE);
                
                InputStream is = getClass().getClassLoader().getResourceAsStream("tenant/webclient.properties");
                addContent(webClientExtFolder, "webclient.properties", is, MimetypeMap.MIMETYPE_TEXT_PLAIN);
                
                is = getClass().getClassLoader().getResourceAsStream("tenant/web-client-config-custom.xml");
                addContent(webClientExtFolder, "web-client-config-custom.xml", is, MimetypeMap.MIMETYPE_XML);
                
                return null;
            }
        }, tenantAdminName, tenantDomain);
    }
}
 
源代码15 项目: alfresco-repository   文件: ScriptSiteService.java
/**
 * Get a site for a provided site short name.
 * <p>
 * Returns null if the site does not exist.
 * 
 * @param shortName short name of the site
 * @return Site the site, null if does not exist
 */
public Site getSite(final String shortName)
{
    SiteInfo siteInfo = null;
    Site site = null;
    if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
    {
        siteInfo = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<SiteInfo>()
        {
            public SiteInfo doWork() throws Exception
            {
                return siteService.getSite(shortName);
            }
        }, AuthenticationUtil.getAdminUserName());
    }
    else
    {
        siteInfo = this.siteService.getSite(shortName);
    }

    if (siteInfo != null)
    {
        site = new Site(siteInfo, this.serviceRegistry, this.siteService, getScope());
    }
    return site;
}
 
@BeforeClass public static void initStaticData() throws Exception
{
    COPY_SERVICE              = (CopyService)                 APP_CONTEXT_INIT.getApplicationContext().getBean("copyService");
    NODE_SERVICE              = (NodeService)                 APP_CONTEXT_INIT.getApplicationContext().getBean("nodeService");
    RATING_NAMING_CONVENTIONS = (RatingNamingConventionsUtil) APP_CONTEXT_INIT.getApplicationContext().getBean("rollupNamingConventions");
    RATING_SERVICE            = (RatingService)               APP_CONTEXT_INIT.getApplicationContext().getBean("ratingService");
    SCRIPT_SERVICE            = (ScriptService)               APP_CONTEXT_INIT.getApplicationContext().getBean("scriptService");
    TRANSACTION_HELPER        = (RetryingTransactionHelper)   APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper");
    
    Repository repositoryHelper = (Repository) APP_CONTEXT_INIT.getApplicationContext().getBean("repositoryHelper");
    COMPANY_HOME = repositoryHelper.getCompanyHome();
    
    // Create some static test content
    TEST_FOLDER = STATIC_TEST_NODES.createNode(COMPANY_HOME, "testFolder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());
    COPY_DEST_FOLDER = STATIC_TEST_NODES.createNode(COMPANY_HOME, "testCopyDestinationFolder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());

}
 
@Test
public void mnt13183LockInfo()
{
    // CIFS lock node to 1 hour
    lockService.lock(nodeRef1, LockType.WRITE_LOCK, 3600, Lifetime.EPHEMERAL, "lock_info_that_is_not_from_webdav");

    // WebDAV get lock info
    LockInfo lockInfoNodeRef1 = davLockService.getLockInfo(nodeRef1);
    assertNull("exclusiveLockToken is null", lockInfoNodeRef1.getExclusiveLockToken());
    
    String user = AuthenticationUtil.getFullyAuthenticatedUser();
    
    // WebDav lock, check marker
    davLockService.lock(nodeRef2, user, 3600);
    
    LockState lockState2 = lockService.getLockState(nodeRef2);
    assertNotNull("lockState is not null", lockState2);
    
    String additionalInfo2 = lockState2.getAdditionalInfo();
    assertNotNull("additionalInfo is not null", additionalInfo2);
    assertTrue("Check WEBDAV_LOCK marker", additionalInfo2.startsWith(LockInfoImpl.ADDINFO_WEBDAV_MARKER));   
}
 
@Override
protected void tearDown() throws Exception
{
    super.tearDown();
    
    SiteInfo site = siteService.getSite(TEST_SITE_NAME);
    // use retrying transaction to delete the site
    this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            // delete the test site
            siteService.deleteSite(TEST_SITE_NAME);
            
            return null;
        }
    });
    nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(site.getNodeRef()));
    
    AuthenticationUtil.clearCurrentSecurityContext();
}
 
public void testValidUpload_ExtModuleOnly() throws Exception
{
    File zipFile = getResourceFile("validExtModule.zip");
    PostRequest postRequest = buildMultipartPostRequest(zipFile);

    AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER);
    Response response = sendRequest(postRequest, 403);

    AuthenticationUtil.setFullyAuthenticatedUser(CUSTOM_MODEL_ADMIN);
    response = sendRequest(postRequest, 200);

    JSONObject json = new JSONObject(new JSONTokener(response.getContentAsString()));
    assertFalse(json.has("modelName"));

    String extModule = json.getString("shareExtModule");
    Document document = XMLUtil.parse(extModule);
    NodeList nodes = document.getElementsByTagName("id");
    assertEquals(1, nodes.getLength());
    assertNotNull(nodes.item(0).getTextContent());
}
 
@Test
public void testPreservingPropertiesOfFolderMnt8109() throws Exception
{
    try
    {
        Thread.sleep(1000);
    }
    catch (Exception e)
    {
        // Just stop to wait for the end of...
    }

    // Enabling preservation of modification properties data...
    fileFolderService.setPreserveAuditableData(true);
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER_NAME);
            moveObjectAndAssert(testFolder);
            return null;
        }
    });
}
 
源代码21 项目: alfresco-repository   文件: PeopleTest.java
@Override
protected void tearDown() throws Exception
{        
    try
    {
        txn.rollback();
    }
    catch (Throwable e)
    {
        e.printStackTrace();
    }

    AuthenticationUtil.clearCurrentSecurityContext();

    people.setServiceRegistry(serviceRegistry);
}
 
private void applyRatingAs(final NodeRef targetNode, final float rating, final String ratingSchemeName,
            String asUser) throws RatingServiceException
{

    String fau = AuthenticationUtil.getFullyAuthenticatedUser();
    try
    {
        AuthenticationUtil.setFullyAuthenticatedUser(asUser);
        RunAsWork<Void> applyRatingsAsWork = new RunAsWork<Void>()
        {

            @Override
            public Void doWork() throws Exception
            {
                ratingService.applyRating(targetNode,
                                          rating,
                                          ratingSchemeName);
                return null;
            }

        };
        AuthenticationUtil.runAs(applyRatingsAsWork,
                                 asUser);
    }
    finally
    {
        AuthenticationUtil.setFullyAuthenticatedUser(fau);
    }
}
 
源代码23 项目: alfresco-remote-api   文件: TestPeople.java
private Person createTestUpdatePerson() throws PublicApiException
{
    Person person = new Person();
    String personId = UUID.randomUUID().toString()+"@"+account1.getId();
    person.setUserName(personId);
    person.setFirstName("Joe");
    person.setEmail(personId);
    person.setEnabled(true);
    person.setPassword("password123");
    person.setDescription("This is a very short bio.");
    person.setProperties(Collections.singletonMap("papi:jabber", "[email protected]"));
    person.setAspectNames(Collections.singletonList("papi:dessertable"));

    person = people.create(person);

    AuthenticationUtil.setFullyAuthenticatedUser("[email protected]"+account1.getId());
    NodeRef nodeRef = personService.getPerson(person.getId());
    // Add some non-custom aspects, these should be untouched by the people API.
    nodeService.addAspect(nodeRef, ContentModel.ASPECT_AUDITABLE, null);
    nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, "This is a title");
    
    assertEquals("[email protected]", person.getProperties().get("papi:jabber"));
    assertEquals(2, person.getAspectNames().size());
    assertTrue(person.getAspectNames().contains("papi:comms"));
    assertTrue(person.getAspectNames().contains("papi:dessertable"));
    return person;
}
 
源代码24 项目: alfresco-repository   文件: BaseInterpreter.java
/**
 * Interpret a single command using the BufferedReader passed in for any data needed.
 *
 * @param line The unparsed command
 * @return The textual output of the command.
 */
public String interpretCommand(final String line)
    throws IOException
{
    String currentUserName = getCurrentUserName();
    if (hasAuthority(currentUserName))
    {        
        // execute command in context of currently selected user
        return AuthenticationUtil.runAs(new RunAsWork<String>()
        {
            public String doWork() throws Exception
            {
                RetryingTransactionCallback<String> txnWork = new RetryingTransactionCallback<String>()
                {
                    public String execute() throws Exception
                    {
                        return executeCommand(line);
                    }
                };
                return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
            }
        }, currentUserName);
    }
    else
    {
        return("Error: User '"+ currentUserName + "' not authorised");
    }
}
 
/**
 * <a href="https://issues.alfresco.com/jira/browse/ALF-7889">ALF-7889</a>
 */
public synchronized void testAR7889ArchiveAndRestoreMustNotModifyAuditable() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(USER_A);
    nodeService.addAspect(b, ContentModel.ASPECT_AUDITABLE, null);
    
    // Do a little wait to ensure that the cm:auditable modified date is at least 1s old
    wait(2000L);
    
    // Get the cm:auditable modified time
    String modifierOriginal = (String) nodeService.getProperty(b, ContentModel.PROP_MODIFIER);
    Date modifiedOriginal = (Date) nodeService.getProperty(b, ContentModel.PROP_MODIFIED);

    verifyAspectExistence(b, ContentModel.ASPECT_AUDITABLE, true);

    nodeService.deleteNode(b);
    verifyNodeExistence(b_, true);
    
    // Check that the cm:auditable modified did not change
    String modifierArchived = (String) nodeService.getProperty(b_, ContentModel.PROP_MODIFIER);
    Date modifiedArchived = (Date) nodeService.getProperty(b_, ContentModel.PROP_MODIFIED);
    assertEquals("cm:modifier should not have changed", modifierOriginal, modifierArchived);
    assertEquals("cm:modified should not have changed", modifiedOriginal, modifiedArchived);

    // Restore is done using clean txn
    commitAndBeginNewTransaction();

    // Restore and check cm:auditable
    RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(b_);
    assertEquals("Restore failed", RestoreStatus.SUCCESS, report.getStatus());
    
    // Check that the cm:auditable modified did not change
    String modifierRestored = (String) nodeService.getProperty(b, ContentModel.PROP_MODIFIER);
    Date modifiedRestored = (Date) nodeService.getProperty(b, ContentModel.PROP_MODIFIED);
    assertEquals("cm:modifier should not have changed", modifierOriginal, modifierRestored);
    assertEquals("cm:modified should not have changed", modifiedOriginal, modifiedRestored);
    verifyAspectExistence(b, ContentModel.ASPECT_AUDITABLE, true);
}
 
@Before
public void before() throws Exception
{
    final Date now = new Date();
    final Date twoSecondsAgo = new Date(now.getTime() - 2000);
    
    this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
    this.thumbnailService = (ThumbnailService)this.applicationContext.getBean("thumbnailService");
    this.failureHandlingOptions = (FailureHandlingOptions) this.applicationContext.getBean("standardFailureOptions");

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    // 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);

    // We'll fake this. We won't actually run any thumbnails - just set up the various aspect and child-node
    // conditions we need to test the evaluator.
    this.newUnthumbnailedNodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CONTAINS,
            QName.createQName("{test}newUnthumbnailedNodeRef"),
            ContentModel.TYPE_CONTENT).getChildRef();

    this.recentlyFailedNodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CONTAINS,
            QName.createQName("{test}recentlyFailedNodeRef"),
            ContentModel.TYPE_CONTENT).getChildRef();
    nodeService.addAspect(recentlyFailedNodeRef, ContentModel.ASPECT_FAILED_THUMBNAIL_SOURCE, null);
    NodeRef thumbDef1FailureNode = nodeService.createNode(recentlyFailedNodeRef,
                                                         ContentModel.ASSOC_FAILED_THUMBNAIL,
                                                         thumbnailDef1,
                                                         ContentModel.TYPE_FAILED_THUMBNAIL).getChildRef();
    nodeService.setProperty(thumbDef1FailureNode, ContentModel.PROP_FAILED_THUMBNAIL_TIME, twoSecondsAgo);
    nodeService.setProperty(thumbDef1FailureNode, ContentModel.PROP_FAILURE_COUNT, 1);
}
 
源代码27 项目: alfresco-remote-api   文件: CommentsApiTest.java
public void testCommentDoesNotVersion() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    String versionBefore = getCurrentVersion(nodeRef);
    addComment(nodeRef, AuthenticationUtil.getAdminUserName(), 200);
    String versionAfter = getCurrentVersion(nodeRef);
    assertEquals(versionBefore, versionAfter);
}
 
源代码28 项目: alfresco-repository   文件: EventsServiceImpl.java
@Override
public void inheritPermissionsEnabled(NodeRef nodeRef)
{
    NodeInfo nodeInfo = getNodeInfo(nodeRef, InheritPermissionsEnabledEvent.EVENT_TYPE);
    if (nodeInfo.checkNodeInfo())
    {
        String username = AuthenticationUtil.getFullyAuthenticatedUser();
        String networkId = TenantUtil.getCurrentDomain();
        String name = nodeInfo.getName();
        String nodeId = nodeInfo.getNodeId();
        String siteId = nodeInfo.getSiteId();
        String txnId = AlfrescoTransactionSupport.getTransactionId();
        List<String> nodePaths = nodeInfo.getPaths();
        List<List<String>> pathNodeIds = nodeInfo.getParentNodeIds();
        long timestamp = System.currentTimeMillis();
        Long modificationTime = nodeInfo.getModificationTimestamp();
        String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
        Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());

        Set<String> aspects = nodeInfo.getAspectsAsStrings();
        Map<String, Serializable> properties = nodeInfo.getProperties();

        Event event = InheritPermissionsEnabledEvent.builder().seqNumber(nextSequenceNumber()).name(name).txnId(txnId).timestamp(timestamp)
                .networkId(networkId).siteId(siteId).nodeId(nodeId).nodeType(nodeType).paths(nodePaths).parentNodeIds(pathNodeIds)
                .username(username).nodeModificationTime(modificationTime).client(alfrescoClient).aspects(aspects).nodeProperties(properties)
                .build();         
               
        sendEvent(event);
    }
}
 
源代码29 项目: alfresco-repository   文件: EventsServiceImpl.java
@Override
public void secondaryAssociationCreated(final ChildAssociationRef secAssociation)
{
    NodeInfo nodeInfo = getNodeInfo(secAssociation.getChildRef(), NodeAddedEvent.EVENT_TYPE);
    if(nodeInfo.checkNodeInfo())
    {
        String username = AuthenticationUtil.getFullyAuthenticatedUser();
        String networkId = TenantUtil.getCurrentDomain();

        String name = nodeInfo.getName();
        String objectId = nodeInfo.getNodeId();
        String siteId = nodeInfo.getSiteId();
        String txnId = AlfrescoTransactionSupport.getTransactionId();
        
        NodeRef secParentNodeRef = secAssociation.getParentRef();
        String secParentNodeName = (String)nodeService.getProperty(secAssociation.getParentRef(), ContentModel.PROP_NAME);
        List<Path> secParentPath = nodeService.getPaths(secParentNodeRef, true);
        List<String> nodePaths = getPaths(secParentPath, Arrays.asList(secParentNodeName, name));
        List<List<String>> pathNodeIds = this.getNodeIds(secParentPath);
        
        long timestamp = System.currentTimeMillis();
        Long modificationTime = nodeInfo.getModificationTimestamp();
        String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
        Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());

        Set<String> aspects = nodeInfo.getAspectsAsStrings();
        Map<String, Serializable> properties = nodeInfo.getProperties();

        Event event = new NodeAddedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds,
                username, modificationTime, alfrescoClient, aspects, properties);
        sendEvent(event);
    }
}
 
/**
 * {@inheritDoc}
 */
@Override
public String loadLicense()
{
    // Ensure that we force a writable txn for this operation
    final RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.setForceWritable(true);
    
    final RetryingTransactionCallback<String> loadCallback = new RetryingTransactionCallback<String>()
    {
        @Override
        public String execute() throws Throwable
        {
            return licenseService.loadLicense();      
        }
    };
    // ... and we have to be 'system' for this, too
    String result = AuthenticationUtil.runAs(new RunAsWork<String>()
    {
        public String doWork() throws Exception
        {
            return txnHelper.doInTransaction(loadCallback, false, true);
        }
    }, AuthenticationUtil.getSystemUserName());

    if (logger.isDebugEnabled())
    {
        logger.debug("Load license call returning: " + result);
    }
    return result;
}