diff --git a/config/alfresco/activities/activities-feed-context.xml b/config/alfresco/activities/activities-feed-context.xml
index 99f0882ed4..2e10391e66 100644
--- a/config/alfresco/activities/activities-feed-context.xml
+++ b/config/alfresco/activities/activities-feed-context.xml
@@ -8,6 +8,7 @@
+
@@ -59,6 +60,7 @@
+
diff --git a/config/alfresco/application-context.xml b/config/alfresco/application-context.xml
index c4a54b0294..6d36653d8d 100644
--- a/config/alfresco/application-context.xml
+++ b/config/alfresco/application-context.xml
@@ -56,6 +56,7 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${user.name.caseSensitive}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${user.name.caseSensitive}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
- org.alfresco.repo.security.authentication.AuthenticationComponent
-
-
-
-
-
-
-
-
-
- ${server.transaction.mode.default}
-
-
-
+
+
+
+
+
+
+
+ org.alfresco.repo.security.authentication.AuthenticationComponent
+
+
+
+
+
+
+
+
+
+ ${server.transaction.mode.default}
+
+
+
@@ -160,301 +160,288 @@
-
+
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${spaces.store}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${spaces.store}
-
-
-
-
-
-
-
-
-
-
- ${server.transaction.allow-writes}
-
-
- ${user.name.caseSensitive}
-
-
-
- true
-
-
-
- SPLIT
-
-
- true
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /${spaces.company_home.childname}
-
-
- ${spaces.store}
-
-
-
-
-
-
-
-
-
-
-
- /${spaces.company_home.childname}/${spaces.guest_home.childname}
-
-
- ${spaces.store}
-
-
-
-
-
-
- Consumer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /${spaces.company_home.childname}
-
-
- ${spaces.store}
-
-
-
-
-
- false
-
-
-
- All
-
-
-
-
- All
-
-
-
-
-
-
-
-
-
- /${spaces.company_home.childname}/${spaces.user_homes.childname}
-
-
- ${spaces.store}
-
-
-
-
-
- false
-
-
-
- All
-
-
-
-
- All
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PT1H
-
-
-
- false
-
-
-
- false
-
-
-
-
-
- AFTER_FIXED_TIME
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- 8
-
-
+ parent="authenticationComponentBase">
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${spaces.store}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${spaces.store}
+
+
+
+
+
+
+
+
+
+
+ ${server.transaction.allow-writes}
+
+
+ ${user.name.caseSensitive}
+
+
+
+ true
+
+
+
+ SPLIT
+
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /${spaces.company_home.childname}
+
+
+ ${spaces.store}
+
+
+
+
+
+ /${spaces.company_home.childname}/${spaces.guest_home.childname}
+
+
+ ${spaces.store}
+
+
+
+ Consumer
+
+
+
+
+
+
+
+
+ /${spaces.company_home.childname}
+
+
+ ${spaces.store}
+
+
+ false
+
+
+
+ All
+
+
+
+
+ All
+
+
+
+
+
+
+ /${spaces.company_home.childname}/${spaces.user_homes.childname}
+
+
+ ${spaces.store}
+
+
+ false
+
+
+
+ All
+
+
+
+
+ All
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PT1H
+
+
+
+ false
+
+
+
+ false
+
+
+
+
+
+ AFTER_FIXED_TIME
+
+
+
+
+
+
+ 6
+
+
+
+
+
+
+
+
+
+ 8
+
+
\ No newline at end of file
diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 5f824881bd..760895acb9 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -383,7 +383,7 @@
jbpm
alfresco/workflow/invitation-moderated_processdefinition.xml
text/xml
- true
+ false
diff --git a/config/alfresco/extension/mt/mt-admin-context.xml.sample b/config/alfresco/extension/mt/mt-admin-context.xml.sample
index 318d3bee71..2a2604ac25 100644
--- a/config/alfresco/extension/mt/mt-admin-context.xml.sample
+++ b/config/alfresco/extension/mt/mt-admin-context.xml.sample
@@ -7,26 +7,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/config/alfresco/mt/mt-base-context.xml b/config/alfresco/mt/mt-base-context.xml
new file mode 100644
index 0000000000..9901bd2966
--- /dev/null
+++ b/config/alfresco/mt/mt-base-context.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml
index 457b0ff937..a8e9ab3390 100644
--- a/config/alfresco/public-services-context.xml
+++ b/config/alfresco/public-services-context.xml
@@ -828,7 +828,7 @@
org.alfresco.service.cmr.avm.AVMService
-
+
@@ -837,6 +837,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/site-services-context.xml b/config/alfresco/site-services-context.xml
index 0acaff9506..5fba8a6718 100644
--- a/config/alfresco/site-services-context.xml
+++ b/config/alfresco/site-services-context.xml
@@ -74,6 +74,7 @@
./${spaces.company_home.childname}/st:sites
+
diff --git a/config/alfresco/workflow-context.xml b/config/alfresco/workflow-context.xml
index d67de37e67..363691b49b 100644
--- a/config/alfresco/workflow-context.xml
+++ b/config/alfresco/workflow-context.xml
@@ -18,6 +18,8 @@
+
+
diff --git a/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java b/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java
index 6373ecf6f2..09730df654 100644
--- a/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java
+++ b/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -38,6 +38,7 @@ import org.alfresco.repo.activities.feed.control.FeedControlDaoService;
import org.alfresco.repo.activities.post.ActivityPostDAO;
import org.alfresco.repo.activities.post.ActivityPostDaoService;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.activities.ActivityService;
import org.alfresco.service.cmr.activities.FeedControl;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -69,6 +70,8 @@ public class ActivityServiceImpl implements ActivityService
private AuthorityService authorityService;
private FeedGenerator feedGenerator;
+ private TenantService tenantService;
+
private int maxFeedItems = 100;
private boolean userNamesAreCaseSensitive = false;
@@ -108,32 +111,37 @@ public class ActivityServiceImpl implements ActivityService
this.feedGenerator = feedGenerator;
}
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
/* (non-Javadoc)
* @see org.alfresco.service.cmr.activities.ActivityService#postActivity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
- public void postActivity(String activityType, String network, String appTool, String activityData)
+ public void postActivity(String activityType, String siteId, String appTool, String activityData)
{
- postActivity(activityType, network, appTool, activityData, ActivityPostDAO.STATUS.PENDING);
+ postActivity(activityType, siteId, appTool, activityData, ActivityPostDAO.STATUS.PENDING);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.activities.ActivityService#postActivity(java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
*/
- public void postActivity(String activityType, String network, String appTool, NodeRef nodeRef)
+ public void postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
StringBuffer sb = new StringBuffer();
sb.append("{").append("\"nodeRef\":\"").append(nodeRef.toString()).append("\"").append("}");
- postActivity(activityType, network, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
+ postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.activities.ActivityService#postActivity(java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
*/
- public void postActivity(String activityType, String network, String appTool, NodeRef nodeRef, String name)
+ public void postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef, String name)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
@@ -142,13 +150,13 @@ public class ActivityServiceImpl implements ActivityService
.append("\"name\":\"").append(name).append("\"")
.append("}");
- postActivity(activityType, network, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
+ postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.activities.ActivityService#postActivity(java.lang.String, java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef)
*/
- public void postActivity(String activityType, String network, String appTool, NodeRef nodeRef, String name, QName typeQName, NodeRef parentNodeRef)
+ public void postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef, String name, QName typeQName, NodeRef parentNodeRef)
{
// primarily for delete node activities - eg. delete document, delete folder
@@ -163,23 +171,23 @@ public class ActivityServiceImpl implements ActivityService
.append("\"parentNodeRef\":\"").append(parentNodeRef.toString()).append("\"")
.append("}");
- postActivity(activityType, network, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
+ postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostDAO.STATUS.PENDING);
}
- private void postActivity(String activityType, String siteNetwork, String appTool, String activityData, ActivityPostDAO.STATUS status)
+ private void postActivity(String activityType, String siteId, String appTool, String activityData, ActivityPostDAO.STATUS status)
{
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
try
{
// optional - default to empty string
- if (siteNetwork == null)
+ if (siteId == null)
{
- siteNetwork = "";
+ siteId = "";
}
- else if (siteNetwork.length() > MAX_LEN_SITE_ID)
+ else if (siteId.length() > MAX_LEN_SITE_ID)
{
- throw new AlfrescoRuntimeException("Invalid site network - exceeds " + MAX_LEN_SITE_ID + " chars: " + siteNetwork);
+ throw new AlfrescoRuntimeException("Invalid siteId - exceeds " + MAX_LEN_SITE_ID + " chars: " + siteId);
}
// optional - default to empty string
@@ -235,7 +243,9 @@ public class ActivityServiceImpl implements ActivityService
Date postDate = new Date();
ActivityPostDAO activityPost = new ActivityPostDAO();
activityPost.setUserId(currentUser);
- activityPost.setSiteNetwork(siteNetwork);
+
+ activityPost.setSiteNetwork(tenantService.getName(siteId));
+
activityPost.setAppTool(appTool);
activityPost.setActivityData(activityData);
activityPost.setActivityType(activityType);
@@ -297,6 +307,8 @@ public class ActivityServiceImpl implements ActivityService
List activityFeeds = null;
if (siteId != null)
{
+ siteId = tenantService.getName(siteId);
+
activityFeeds = feedDaoService.selectUserFeedEntries(feedUserId, format, siteId);
}
else
@@ -312,6 +324,8 @@ public class ActivityServiceImpl implements ActivityService
{
break;
}
+
+ activityFeed.setSiteNetwork(tenantService.getBaseName(activityFeed.getSiteNetwork()));
activityFeedEntries.add(activityFeed.getJSONString());
}
}
@@ -343,6 +357,8 @@ public class ActivityServiceImpl implements ActivityService
try
{
+ siteId = tenantService.getName(siteId);
+
List activityFeeds = feedDaoService.selectSiteFeedEntries(siteId, format);
int count = 0;
@@ -353,6 +369,8 @@ public class ActivityServiceImpl implements ActivityService
{
break;
}
+
+ activityFeed.setSiteNetwork(tenantService.getBaseName(activityFeed.getSiteNetwork()));
activityFeedEntries.add(activityFeed.getJSONString());
}
}
@@ -504,4 +522,16 @@ public class ActivityServiceImpl implements ActivityService
throw are;
}
}
+
+ private FeedControl getTenantFeedControl(FeedControl feedControl)
+ {
+ // TODO
+ return null;
+ }
+
+ private FeedControl getBaseFeedControl(FeedControl feedControl)
+ {
+ // TODO
+ return null;
+ }
}
diff --git a/source/java/org/alfresco/repo/activities/post/lookup/PostLookup.java b/source/java/org/alfresco/repo/activities/post/lookup/PostLookup.java
index 6adef304ca..d822d486a5 100644
--- a/source/java/org/alfresco/repo/activities/post/lookup/PostLookup.java
+++ b/source/java/org/alfresco/repo/activities/post/lookup/PostLookup.java
@@ -1,338 +1,351 @@
-/*
- * Copyright (C) 2005-2008 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.activities.post.lookup;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.repo.activities.post.ActivityPostDAO;
-import org.alfresco.repo.activities.post.ActivityPostDaoService;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
-import org.alfresco.repo.transaction.RetryingTransactionHelper;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.Path;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.cmr.security.PersonService;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.Pair;
-import org.alfresco.util.PropertyCheck;
-import org.alfresco.util.VmShutdownListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.quartz.JobExecutionException;
-
-/**
- * The post lookup component is responsible for updating posts that require a secondary lookup (to get additional activity data)
- */
-public class PostLookup
-{
- private static Log logger = LogFactory.getLog(PostLookup.class);
-
- private static VmShutdownListener vmShutdownListener = new VmShutdownListener(PostLookup.class.getName());
-
- private ActivityPostDaoService postDaoService;
- private NodeService nodeService;
- private PermissionService permissionService;
- private TransactionService transactionService;
- private PersonService personService;
-
- public void setPostDaoService(ActivityPostDaoService postDaoService)
- {
- this.postDaoService = postDaoService;
- }
-
- public void setNodeService(NodeService nodeService)
- {
- this.nodeService = nodeService;
- }
-
- public void setPermissionService(PermissionService permissionService)
- {
- this.permissionService = permissionService;
- }
-
- public void setTransactionService(TransactionService transactionService)
- {
- this.transactionService = transactionService;
- }
-
- public void setPersonService(PersonService personService)
- {
- this.personService = personService;
- }
-
- /**
- * Perform basic checks to ensure that the necessary dependencies were injected.
- */
- private void checkProperties()
- {
- PropertyCheck.mandatory(this, "postDaoService", postDaoService);
- PropertyCheck.mandatory(this, "nodeService", nodeService);
- PropertyCheck.mandatory(this, "permissionService", permissionService);
- PropertyCheck.mandatory(this, "transactionService", transactionService);
- PropertyCheck.mandatory(this, "personService", personService);
- }
-
- public void execute() throws JobExecutionException
- {
- checkProperties();
- try
- {
- ActivityPostDAO params = new ActivityPostDAO();
- params.setStatus(ActivityPostDAO.STATUS.PENDING.toString());
-
- List activityPosts = postDaoService.selectPosts(params);
-
- if (activityPosts.size() > 0)
- {
- logger.info("Update: " + activityPosts.size() + " activity posts");
- }
-
- for (ActivityPostDAO activityPost : activityPosts)
- {
- try
- {
- postDaoService.startTransaction();
-
- JSONObject jo = new JSONObject(new JSONTokener(activityPost.getActivityData()));
- String postUserId = activityPost.getUserId();
-
- if (! jo.isNull("nodeRef"))
- {
- String nodeRefStr = jo.getString("nodeRef");
- NodeRef nodeRef = new NodeRef(nodeRefStr);
-
- // lookup additional node data
- JSONObject activityData = lookupNode(nodeRef, postUserId, jo);
-
- activityPost.setActivityData(activityData.toString());
- }
- else
- {
- // lookup additional person data
- Pair firstLastName = lookupPerson(postUserId);
- if (firstLastName != null)
- {
- jo.put("firstName", firstLastName.getFirst());
- jo.put("lastName", firstLastName.getSecond());
-
- activityPost.setActivityData(jo.toString());
- }
- }
-
- activityPost.setLastModified(new Date());
-
- postDaoService.updatePost(activityPost.getId(), activityPost.getSiteNetwork(), activityPost.getActivityData(), ActivityPostDAO.STATUS.POSTED);
- if (logger.isDebugEnabled())
- {
- activityPost.setStatus(ActivityPostDAO.STATUS.POSTED.toString()); // for debug output
- logger.debug("Updated: " + activityPost);
- }
-
- postDaoService.commitTransaction();
- }
- catch (JSONException e)
- {
- // log error, but consume exception (skip this post)
- logger.error("Skipping activity post " + activityPost.getId() + ": " + e);
- postDaoService.updatePostStatus(activityPost.getId(), ActivityPostDAO.STATUS.ERROR);
-
- postDaoService.commitTransaction();
- }
- catch (SQLException e)
- {
- logger.error("Exception during update of post", e);
- throw new JobExecutionException(e);
- }
- finally
- {
- postDaoService.endTransaction();
- }
- }
- }
- catch (SQLException e)
- {
- logger.error("Exception during select of posts", e);
- throw new JobExecutionException(e);
- }
- catch (Throwable e)
- {
- // If the VM is shutting down, then ignore
- if (vmShutdownListener.isVmShuttingDown())
- {
- // Ignore
- }
- else
- {
- logger.error("Exception during update of posts", e);
- }
- }
- }
-
- private Pair lookupPerson(final String postUserId) throws JSONException
- {
- return AuthenticationUtil.runAs(new RunAsWork>()
- {
- public Pair doWork() throws Exception
- {
- RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
-
- // wrap to make the request in a transaction
- RetryingTransactionCallback> lookup = new RetryingTransactionCallback>()
- {
- public Pair execute() throws Throwable
- {
- String firstName = "";
- String lastName = "";
-
- if (personService.personExists(postUserId))
- {
- NodeRef personRef = personService.getPerson(postUserId);
-
- firstName = (String)nodeService.getProperty(personRef, ContentModel.PROP_FIRSTNAME);
- lastName = (String)nodeService.getProperty(personRef, ContentModel.PROP_LASTNAME);
-
- return new Pair(firstName, lastName);
- }
-
- return null;
- }
- };
-
- // execute in txn
- return txnHelper.doInTransaction(lookup, true);
- }
- }, AuthenticationUtil.getSystemUserName());
- }
-
- private JSONObject lookupNode(final NodeRef nodeRef, final String postUserId, final JSONObject jo) throws JSONException
- {
- return AuthenticationUtil.runAs(new RunAsWork()
- {
- public JSONObject doWork() throws Exception
- {
- RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
-
- // wrap to make the request in a transaction
- RetryingTransactionCallback lookup = new RetryingTransactionCallback()
- {
- public JSONObject execute() throws Throwable
- {
- String name = "";
- if (! jo.isNull("name"))
- {
- name = jo.getString("name");
- }
-
- NodeRef parentNodeRef = null;
- if (! jo.isNull("parentNodeRef"))
- {
- parentNodeRef = new NodeRef(jo.getString("parentNodeRef"));
- }
-
-
- String typeQName = "";
- if (! jo.isNull("typeQName"))
- {
- typeQName = jo.getString("typeQName");
- }
-
- String displayPath = "";
- Path path = null;
- String firstName = "";
- String lastName = "";
-
- if (personService.personExists(postUserId))
- {
- // lookup firstname, lastname
- NodeRef personRef = personService.getPerson(postUserId);
-
- firstName = (String)nodeService.getProperty(personRef, ContentModel.PROP_FIRSTNAME);
- lastName = (String)nodeService.getProperty(personRef, ContentModel.PROP_LASTNAME);
- }
-
- if ((nodeRef != null) && (nodeService.exists(nodeRef)))
- {
- if (name.length() == 0)
- {
- // lookup node name
- name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
- }
-
- if (typeQName.length() == 0)
- {
- // lookup type
- typeQName = nodeService.getType(nodeRef).toPrefixString(); // TODO: missing the prefix ?
- }
-
- if (parentNodeRef == null)
- {
- // lookup parent node
- parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
- }
- }
-
- if ((parentNodeRef != null) && (nodeService.exists(parentNodeRef)))
- {
- // parent node exists, lookup parent node path
- path = nodeService.getPath(parentNodeRef);
- }
-
- if (path != null)
- {
- // lookup display path
- displayPath = path.toDisplayPath(nodeService, permissionService);
-
- // note: for now, also tack on the node name
- displayPath += "/" + name;
- }
-
- // merge with existing activity data
- jo.put("name", name);
- jo.put("nodeRef", nodeRef.toString());
- jo.put("typeQName", typeQName);
- jo.put("parentNodeRef", (parentNodeRef != null ? parentNodeRef.toString() : null));
- jo.put("displayPath", displayPath);
- jo.put("firstName", firstName);
- jo.put("lastName", lastName);
-
- return jo;
- }
- };
-
- // execute in txn
- return txnHelper.doInTransaction(lookup, true);
- }
- }, AuthenticationUtil.getSystemUserName());
- }
+/*
+ * Copyright (C) 2005-2009 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.activities.post.lookup;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.repo.activities.post.ActivityPostDAO;
+import org.alfresco.repo.activities.post.ActivityPostDaoService;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.tenant.TenantService;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.repository.Path;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.Pair;
+import org.alfresco.util.PropertyCheck;
+import org.alfresco.util.VmShutdownListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.quartz.JobExecutionException;
+
+/**
+ * The post lookup component is responsible for updating posts that require a secondary lookup (to get additional activity data)
+ */
+public class PostLookup
+{
+ private static Log logger = LogFactory.getLog(PostLookup.class);
+
+ private static VmShutdownListener vmShutdownListener = new VmShutdownListener(PostLookup.class.getName());
+
+ private ActivityPostDaoService postDaoService;
+ private NodeService nodeService;
+ private PermissionService permissionService;
+ private TransactionService transactionService;
+ private PersonService personService;
+ private TenantService tenantService;
+
+ public void setPostDaoService(ActivityPostDaoService postDaoService)
+ {
+ this.postDaoService = postDaoService;
+ }
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ public void setPermissionService(PermissionService permissionService)
+ {
+ this.permissionService = permissionService;
+ }
+
+ public void setTransactionService(TransactionService transactionService)
+ {
+ this.transactionService = transactionService;
+ }
+
+ public void setPersonService(PersonService personService)
+ {
+ this.personService = personService;
+ }
+
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
+ /**
+ * Perform basic checks to ensure that the necessary dependencies were injected.
+ */
+ private void checkProperties()
+ {
+ PropertyCheck.mandatory(this, "postDaoService", postDaoService);
+ PropertyCheck.mandatory(this, "nodeService", nodeService);
+ PropertyCheck.mandatory(this, "permissionService", permissionService);
+ PropertyCheck.mandatory(this, "transactionService", transactionService);
+ PropertyCheck.mandatory(this, "personService", personService);
+ PropertyCheck.mandatory(this, "tenantService", tenantService);
+ }
+
+ public void execute() throws JobExecutionException
+ {
+ checkProperties();
+ try
+ {
+ ActivityPostDAO params = new ActivityPostDAO();
+ params.setStatus(ActivityPostDAO.STATUS.PENDING.toString());
+
+ List activityPosts = postDaoService.selectPosts(params);
+
+ if (activityPosts.size() > 0)
+ {
+ logger.info("Update: " + activityPosts.size() + " activity posts");
+ }
+
+ for (final ActivityPostDAO activityPost : activityPosts)
+ {
+ try
+ {
+ postDaoService.startTransaction();
+
+ final JSONObject jo = new JSONObject(new JSONTokener(activityPost.getActivityData()));
+ final String postUserId = activityPost.getUserId();
+
+ // MT share
+ String tenantDomain = tenantService.getUserDomain(postUserId);
+
+ AuthenticationUtil.runAs(new RunAsWork