mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
MT Share - initial checkpoint
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13459 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<ActivityFeedDAO> 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<ActivityFeedDAO> 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;
|
||||
}
|
||||
}
|
||||
|
@@ -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<ActivityPostDAO> 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<String, String> 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<String, String> lookupPerson(final String postUserId) throws JSONException
|
||||
{
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Pair<String, String>>()
|
||||
{
|
||||
public Pair<String, String> doWork() throws Exception
|
||||
{
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
|
||||
// wrap to make the request in a transaction
|
||||
RetryingTransactionCallback<Pair<String, String>> lookup = new RetryingTransactionCallback<Pair<String, String>>()
|
||||
{
|
||||
public Pair<String, String> 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<String, String>(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<JSONObject>()
|
||||
{
|
||||
public JSONObject doWork() throws Exception
|
||||
{
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
|
||||
// wrap to make the request in a transaction
|
||||
RetryingTransactionCallback<JSONObject> lookup = new RetryingTransactionCallback<JSONObject>()
|
||||
{
|
||||
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<ActivityPostDAO> 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<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
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<String, String> 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);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain));
|
||||
|
||||
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<String, String> lookupPerson(final String postUserId) throws JSONException
|
||||
{
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
|
||||
// wrap to make the request in a transaction
|
||||
RetryingTransactionCallback<Pair<String, String>> lookup = new RetryingTransactionCallback<Pair<String, String>>()
|
||||
{
|
||||
public Pair<String, String> 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<String, String>(firstName, lastName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// execute in txn
|
||||
return txnHelper.doInTransaction(lookup, true);
|
||||
}
|
||||
|
||||
private JSONObject lookupNode(final NodeRef nodeRef, final String postUserId, final JSONObject jo) throws JSONException
|
||||
{
|
||||
return AuthenticationUtil.runAs(new RunAsWork<JSONObject>()
|
||||
{
|
||||
public JSONObject doWork() throws Exception
|
||||
{
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
|
||||
// wrap to make the request in a transaction
|
||||
RetryingTransactionCallback<JSONObject> lookup = new RetryingTransactionCallback<JSONObject>()
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
1032
source/java/org/alfresco/repo/avm/MultiTAVMService.java
Normal file
1032
source/java/org/alfresco/repo/avm/MultiTAVMService.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,58 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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 received 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.security.authentication;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
|
||||
/**
|
||||
* Generates a simple numeric user name of specified length
|
||||
*
|
||||
* @author glen johnson at Alfresco dot com
|
||||
*/
|
||||
public class BasicUserNameGenerator implements UserNameGenerator
|
||||
{
|
||||
// user name length property
|
||||
private int userNameLength;
|
||||
|
||||
/**
|
||||
* Set the user name length
|
||||
*
|
||||
* @param userNameLength the user name length
|
||||
*/
|
||||
public void setUserNameLength(int userNameLength)
|
||||
{
|
||||
this.userNameLength = userNameLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a generated user name
|
||||
*
|
||||
* @return the generated user name
|
||||
*/
|
||||
public String generateUserName()
|
||||
{
|
||||
return RandomStringUtils.randomNumeric(userNameLength);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 received 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.security.authentication;
|
||||
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
|
||||
/**
|
||||
* Generates a simple numeric user name of specified length
|
||||
*
|
||||
* @author glen johnson at Alfresco dot com
|
||||
*/
|
||||
public class BasicUserNameGenerator implements UserNameGenerator
|
||||
{
|
||||
// user name length property
|
||||
private int userNameLength;
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user name length
|
||||
*
|
||||
* @param userNameLength the user name length
|
||||
*/
|
||||
public void setUserNameLength(int userNameLength)
|
||||
{
|
||||
this.userNameLength = userNameLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a generated user name
|
||||
*
|
||||
* @return the generated user name
|
||||
*/
|
||||
public String generateUserName()
|
||||
{
|
||||
String userName = RandomStringUtils.randomNumeric(userNameLength);
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
userName = tenantService.getDomainUser(userName, tenantService.getCurrentUserDomain());
|
||||
}
|
||||
return userName;
|
||||
}
|
||||
}
|
||||
|
@@ -1,447 +1,470 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.security.person;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Common support for creating home folders This is hooked into node creation events from Person type objects via the homeFolderManager. Provider must all be wired up to the
|
||||
* homeFolderManager.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public abstract class AbstractHomeFolderProvider implements HomeFolderProvider, BeanNameAware, InitializingBean
|
||||
{
|
||||
/**
|
||||
* The provider name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The home folder manager
|
||||
*/
|
||||
private HomeFolderManager homeFolderManager;
|
||||
|
||||
/**
|
||||
* The store ref in which to conduct searches
|
||||
*/
|
||||
private StoreRef storeRef;
|
||||
|
||||
/**
|
||||
* Service registry to get hold of public services (so taht actions are audited)
|
||||
*/
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
/**
|
||||
* The path to a folder
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* Cache the result of the path look up.
|
||||
*/
|
||||
private NodeRef pathNodeRef;
|
||||
|
||||
/**
|
||||
* The owner to set on creation of a home folder (if unset this will be the uid).
|
||||
*/
|
||||
private String ownerOnCreate;
|
||||
|
||||
/**
|
||||
* Set if permissions are inherited when nodes are created.
|
||||
*/
|
||||
private boolean inheritsPermissionsOnCreate = false;
|
||||
|
||||
/**
|
||||
* A set of permissions to set for the owner when a home folder is created
|
||||
*/
|
||||
private Set<String> ownerPermissionsToSetOnCreate;
|
||||
|
||||
/**
|
||||
* General permissions to set on the node Map<(String)uid, Set<(String)permission>>.
|
||||
*/
|
||||
private Map<String, Set<String>> permissionsToSetOnCreate;
|
||||
|
||||
/**
|
||||
* Permissions to set for the user - on create and reference.
|
||||
*/
|
||||
private Set<String> userPermissions;
|
||||
|
||||
/**
|
||||
* Clear existing permissions on new home folders (useful of created from a template.
|
||||
*/
|
||||
private boolean clearExistingPermissionsOnCreate = false;
|
||||
|
||||
public AbstractHomeFolderProvider()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register with the homeFolderManagewr
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
homeFolderManager.addProvider(this);
|
||||
}
|
||||
|
||||
// === //
|
||||
// IOC //
|
||||
// === //
|
||||
|
||||
/**
|
||||
* Get the home folder manager.
|
||||
*/
|
||||
protected HomeFolderManager getHomeFolderManager()
|
||||
{
|
||||
return homeFolderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the home folder manager.
|
||||
*
|
||||
* @param homeFolderManager
|
||||
*/
|
||||
public void setHomeFolderManager(HomeFolderManager homeFolderManager)
|
||||
{
|
||||
this.homeFolderManager = homeFolderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the provider name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The provider name is taken from the bean name
|
||||
*/
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store ref
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected StoreRef getStoreRef()
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the store ref
|
||||
*
|
||||
* @param storeRef
|
||||
*/
|
||||
public void setStoreRef(StoreRef storeRef)
|
||||
{
|
||||
this.storeRef = storeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the store from the string url.
|
||||
*
|
||||
* @param storeUrl
|
||||
*/
|
||||
public void setStoreUrl(String storeUrl)
|
||||
{
|
||||
this.storeRef = new StoreRef(storeUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service registry.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service registry.
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit permissions when home folder are created?
|
||||
*
|
||||
* @param inheritsPermissionsOnCreate
|
||||
*/
|
||||
public void setInheritsPermissionsOnCreate(boolean inheritsPermissionsOnCreate)
|
||||
{
|
||||
this.inheritsPermissionsOnCreate = inheritsPermissionsOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner to set on create.
|
||||
*
|
||||
* @param ownerOnCreate
|
||||
*/
|
||||
public void setOwnerOnCreate(String ownerOnCreate)
|
||||
{
|
||||
this.ownerOnCreate = ownerOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner permissions to set on create.
|
||||
*
|
||||
* @param ownerPermissionsToSetOnCreate
|
||||
*/
|
||||
public void setOwnerPermissionsToSetOnCreate(Set<String> ownerPermissionsToSetOnCreate)
|
||||
{
|
||||
this.ownerPermissionsToSetOnCreate = ownerPermissionsToSetOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* General permissions to set on create.
|
||||
*
|
||||
* @param permissionsToSetOnCreate
|
||||
*/
|
||||
public void setPermissionsToSetOnCreate(Map<String, Set<String>> permissionsToSetOnCreate)
|
||||
{
|
||||
this.permissionsToSetOnCreate = permissionsToSetOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* User permissions to set on create and on reference.
|
||||
*
|
||||
* @param userPermissions
|
||||
*/
|
||||
public void setUserPermissions(Set<String> userPermissions)
|
||||
{
|
||||
this.userPermissions = userPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear exising permissions on create. Useful to clear permissions from a template.
|
||||
*
|
||||
* @param clearExistingPermissionsOnCreate
|
||||
*/
|
||||
public void setClearExistingPermissionsOnCreate(boolean clearExistingPermissionsOnCreate)
|
||||
{
|
||||
this.clearExistingPermissionsOnCreate = clearExistingPermissionsOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache path to node resolution/
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected synchronized NodeRef getPathNodeRef()
|
||||
{
|
||||
if (pathNodeRef == null)
|
||||
{
|
||||
pathNodeRef = resolvePath(path);
|
||||
}
|
||||
return pathNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility metho to resolve paths to nodes.
|
||||
*
|
||||
* @param pathToResolve
|
||||
* @return
|
||||
*/
|
||||
protected NodeRef resolvePath(String pathToResolve)
|
||||
{
|
||||
List<NodeRef> refs = serviceRegistry.getSearchService().selectNodes(
|
||||
serviceRegistry.getNodeService().getRootNode(storeRef), pathToResolve, null,
|
||||
serviceRegistry.getNamespaceService(), false);
|
||||
if (refs.size() != 1)
|
||||
{
|
||||
throw new IllegalStateException("Non-unique path: found : " + pathToResolve + " " + refs.size());
|
||||
}
|
||||
return refs.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the policy binding. Run as the system user for auditing.
|
||||
*/
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.RunAsWork<NodeRef> action = new OnCreateNode(childAssocRef);
|
||||
AuthenticationUtil.runAs(action, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract implementation to find/create the approriate home space.
|
||||
*
|
||||
* @param person
|
||||
* @return
|
||||
*/
|
||||
protected abstract HomeSpaceNodeRef getHomeFolder(NodeRef person);
|
||||
|
||||
/**
|
||||
* Helper class to encapsulate the createion settinhg permissions etc
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
private class OnCreateNode implements AuthenticationUtil.RunAsWork<NodeRef>
|
||||
{
|
||||
ChildAssociationRef childAssocRef;
|
||||
|
||||
OnCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
this.childAssocRef = childAssocRef;
|
||||
}
|
||||
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
|
||||
// Find person
|
||||
NodeRef personNodeRef = childAssocRef.getChildRef();
|
||||
// Get home folder
|
||||
HomeSpaceNodeRef homeFolder = getHomeFolder(personNodeRef);
|
||||
// If it exists
|
||||
if (homeFolder.getNodeRef() != null)
|
||||
{
|
||||
// Get uid and keep
|
||||
String uid = DefaultTypeConverter.INSTANCE.convert(String.class, serviceRegistry.getNodeService()
|
||||
.getProperty(personNodeRef, ContentModel.PROP_USERNAME));
|
||||
|
||||
// If created or found then set (other wise it was already set correctly)
|
||||
if (homeFolder.getStatus() != HomeSpaceNodeRef.Status.VALID)
|
||||
{
|
||||
serviceRegistry.getNodeService().setProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER,
|
||||
homeFolder.getNodeRef());
|
||||
}
|
||||
|
||||
// If created..
|
||||
if (homeFolder.getStatus() == HomeSpaceNodeRef.Status.CREATED)
|
||||
{
|
||||
// Set to a specified owner or make owned by the person.
|
||||
if (ownerOnCreate != null)
|
||||
{
|
||||
serviceRegistry.getOwnableService().setOwner(homeFolder.getNodeRef(), ownerOnCreate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
serviceRegistry.getOwnableService().setOwner(homeFolder.getNodeRef(), uid);
|
||||
}
|
||||
|
||||
// clear permissions - useful of not required from a template
|
||||
|
||||
if (clearExistingPermissionsOnCreate)
|
||||
{
|
||||
serviceRegistry.getPermissionService().deletePermissions(homeFolder.getNodeRef());
|
||||
}
|
||||
|
||||
// inherit permissions
|
||||
|
||||
serviceRegistry.getPermissionService().setInheritParentPermissions(homeFolder.getNodeRef(),
|
||||
inheritsPermissionsOnCreate);
|
||||
|
||||
// Set owner permissions
|
||||
|
||||
if (ownerPermissionsToSetOnCreate != null)
|
||||
{
|
||||
for (String permission : ownerPermissionsToSetOnCreate)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(),
|
||||
PermissionService.OWNER_AUTHORITY, permission, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Add other permissions
|
||||
|
||||
if (permissionsToSetOnCreate != null)
|
||||
{
|
||||
for (String user : permissionsToSetOnCreate.keySet())
|
||||
{
|
||||
Set<String> set = permissionsToSetOnCreate.get(user);
|
||||
if (set != null)
|
||||
{
|
||||
for (String permission : set)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(), user,
|
||||
permission, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add user permissions on create and reference
|
||||
|
||||
if (userPermissions != null)
|
||||
{
|
||||
for (String permission : userPermissions)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(), uid, permission,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return homeFolder.getNodeRef();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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.security.person;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Common support for creating home folders This is hooked into node creation events from Person type objects via the homeFolderManager. Provider must all be wired up to the
|
||||
* homeFolderManager.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public abstract class AbstractHomeFolderProvider implements HomeFolderProvider, BeanNameAware, InitializingBean
|
||||
{
|
||||
/**
|
||||
* The provider name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The home folder manager
|
||||
*/
|
||||
private HomeFolderManager homeFolderManager;
|
||||
|
||||
/**
|
||||
* The store ref in which to conduct searches
|
||||
*/
|
||||
private StoreRef storeRef;
|
||||
|
||||
/**
|
||||
* Service registry to get hold of public services (so taht actions are audited)
|
||||
*/
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
/**
|
||||
* Tenant service - required for MT-enabled environment, else optional
|
||||
*/
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* The path to a folder
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* Cache the result of the path look up.
|
||||
*/
|
||||
private Map<String, NodeRef> pathNodeRefs; // MT-aware
|
||||
|
||||
/**
|
||||
* The owner to set on creation of a home folder (if unset this will be the uid).
|
||||
*/
|
||||
private String ownerOnCreate;
|
||||
|
||||
/**
|
||||
* Set if permissions are inherited when nodes are created.
|
||||
*/
|
||||
private boolean inheritsPermissionsOnCreate = false;
|
||||
|
||||
/**
|
||||
* A set of permissions to set for the owner when a home folder is created
|
||||
*/
|
||||
private Set<String> ownerPermissionsToSetOnCreate;
|
||||
|
||||
/**
|
||||
* General permissions to set on the node Map<(String)uid, Set<(String)permission>>.
|
||||
*/
|
||||
private Map<String, Set<String>> permissionsToSetOnCreate;
|
||||
|
||||
/**
|
||||
* Permissions to set for the user - on create and reference.
|
||||
*/
|
||||
private Set<String> userPermissions;
|
||||
|
||||
/**
|
||||
* Clear existing permissions on new home folders (useful of created from a template.
|
||||
*/
|
||||
private boolean clearExistingPermissionsOnCreate = false;
|
||||
|
||||
public AbstractHomeFolderProvider()
|
||||
{
|
||||
super();
|
||||
|
||||
pathNodeRefs = new ConcurrentHashMap<String, NodeRef>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register with the homeFolderManagewr
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
homeFolderManager.addProvider(this);
|
||||
}
|
||||
|
||||
// === //
|
||||
// IOC //
|
||||
// === //
|
||||
|
||||
/**
|
||||
* Get the home folder manager.
|
||||
*/
|
||||
protected HomeFolderManager getHomeFolderManager()
|
||||
{
|
||||
return homeFolderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the home folder manager.
|
||||
*
|
||||
* @param homeFolderManager
|
||||
*/
|
||||
public void setHomeFolderManager(HomeFolderManager homeFolderManager)
|
||||
{
|
||||
this.homeFolderManager = homeFolderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the provider name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The provider name is taken from the bean name
|
||||
*/
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store ref
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected StoreRef getStoreRef()
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the store ref
|
||||
*
|
||||
* @param storeRef
|
||||
*/
|
||||
public void setStoreRef(StoreRef storeRef)
|
||||
{
|
||||
this.storeRef = storeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the store from the string url.
|
||||
*
|
||||
* @param storeUrl
|
||||
*/
|
||||
public void setStoreUrl(String storeUrl)
|
||||
{
|
||||
this.storeRef = new StoreRef(storeUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service registry.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service registry.
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tenant service
|
||||
*
|
||||
* @param tenantService
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit permissions when home folder are created?
|
||||
*
|
||||
* @param inheritsPermissionsOnCreate
|
||||
*/
|
||||
public void setInheritsPermissionsOnCreate(boolean inheritsPermissionsOnCreate)
|
||||
{
|
||||
this.inheritsPermissionsOnCreate = inheritsPermissionsOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner to set on create.
|
||||
*
|
||||
* @param ownerOnCreate
|
||||
*/
|
||||
public void setOwnerOnCreate(String ownerOnCreate)
|
||||
{
|
||||
this.ownerOnCreate = ownerOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner permissions to set on create.
|
||||
*
|
||||
* @param ownerPermissionsToSetOnCreate
|
||||
*/
|
||||
public void setOwnerPermissionsToSetOnCreate(Set<String> ownerPermissionsToSetOnCreate)
|
||||
{
|
||||
this.ownerPermissionsToSetOnCreate = ownerPermissionsToSetOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* General permissions to set on create.
|
||||
*
|
||||
* @param permissionsToSetOnCreate
|
||||
*/
|
||||
public void setPermissionsToSetOnCreate(Map<String, Set<String>> permissionsToSetOnCreate)
|
||||
{
|
||||
this.permissionsToSetOnCreate = permissionsToSetOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* User permissions to set on create and on reference.
|
||||
*
|
||||
* @param userPermissions
|
||||
*/
|
||||
public void setUserPermissions(Set<String> userPermissions)
|
||||
{
|
||||
this.userPermissions = userPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear exising permissions on create. Useful to clear permissions from a template.
|
||||
*
|
||||
* @param clearExistingPermissionsOnCreate
|
||||
*/
|
||||
public void setClearExistingPermissionsOnCreate(boolean clearExistingPermissionsOnCreate)
|
||||
{
|
||||
this.clearExistingPermissionsOnCreate = clearExistingPermissionsOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache path to node resolution
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected NodeRef getPathNodeRef()
|
||||
{
|
||||
String tenantDomain = (tenantService != null ? tenantService.getCurrentUserDomain() : TenantService.DEFAULT_DOMAIN);
|
||||
|
||||
NodeRef pathNodeRef = pathNodeRefs.get(tenantDomain);
|
||||
if (pathNodeRef == null)
|
||||
{
|
||||
pathNodeRef = resolvePath(path);
|
||||
pathNodeRefs.put(tenantDomain, pathNodeRef);
|
||||
}
|
||||
return pathNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility metho to resolve paths to nodes.
|
||||
*
|
||||
* @param pathToResolve
|
||||
* @return
|
||||
*/
|
||||
protected NodeRef resolvePath(String pathToResolve)
|
||||
{
|
||||
List<NodeRef> refs = serviceRegistry.getSearchService().selectNodes(
|
||||
serviceRegistry.getNodeService().getRootNode(storeRef), pathToResolve, null,
|
||||
serviceRegistry.getNamespaceService(), false);
|
||||
if (refs.size() != 1)
|
||||
{
|
||||
throw new IllegalStateException("Non-unique path: found : " + pathToResolve + " " + refs.size());
|
||||
}
|
||||
return refs.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the policy binding. Run as the system user for auditing.
|
||||
*/
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.RunAsWork<NodeRef> action = new OnCreateNode(childAssocRef);
|
||||
AuthenticationUtil.runAs(action, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract implementation to find/create the approriate home space.
|
||||
*
|
||||
* @param person
|
||||
* @return
|
||||
*/
|
||||
protected abstract HomeSpaceNodeRef getHomeFolder(NodeRef person);
|
||||
|
||||
/**
|
||||
* Helper class to encapsulate the createion settinhg permissions etc
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
private class OnCreateNode implements AuthenticationUtil.RunAsWork<NodeRef>
|
||||
{
|
||||
ChildAssociationRef childAssocRef;
|
||||
|
||||
OnCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
this.childAssocRef = childAssocRef;
|
||||
}
|
||||
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
|
||||
// Find person
|
||||
NodeRef personNodeRef = childAssocRef.getChildRef();
|
||||
// Get home folder
|
||||
HomeSpaceNodeRef homeFolder = getHomeFolder(personNodeRef);
|
||||
// If it exists
|
||||
if (homeFolder.getNodeRef() != null)
|
||||
{
|
||||
// Get uid and keep
|
||||
String uid = DefaultTypeConverter.INSTANCE.convert(String.class, serviceRegistry.getNodeService()
|
||||
.getProperty(personNodeRef, ContentModel.PROP_USERNAME));
|
||||
|
||||
// If created or found then set (other wise it was already set correctly)
|
||||
if (homeFolder.getStatus() != HomeSpaceNodeRef.Status.VALID)
|
||||
{
|
||||
serviceRegistry.getNodeService().setProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER,
|
||||
homeFolder.getNodeRef());
|
||||
}
|
||||
|
||||
// If created..
|
||||
if (homeFolder.getStatus() == HomeSpaceNodeRef.Status.CREATED)
|
||||
{
|
||||
// Set to a specified owner or make owned by the person.
|
||||
if (ownerOnCreate != null)
|
||||
{
|
||||
serviceRegistry.getOwnableService().setOwner(homeFolder.getNodeRef(), ownerOnCreate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
serviceRegistry.getOwnableService().setOwner(homeFolder.getNodeRef(), uid);
|
||||
}
|
||||
|
||||
// clear permissions - useful of not required from a template
|
||||
|
||||
if (clearExistingPermissionsOnCreate)
|
||||
{
|
||||
serviceRegistry.getPermissionService().deletePermissions(homeFolder.getNodeRef());
|
||||
}
|
||||
|
||||
// inherit permissions
|
||||
|
||||
serviceRegistry.getPermissionService().setInheritParentPermissions(homeFolder.getNodeRef(),
|
||||
inheritsPermissionsOnCreate);
|
||||
|
||||
// Set owner permissions
|
||||
|
||||
if (ownerPermissionsToSetOnCreate != null)
|
||||
{
|
||||
for (String permission : ownerPermissionsToSetOnCreate)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(),
|
||||
PermissionService.OWNER_AUTHORITY, permission, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Add other permissions
|
||||
|
||||
if (permissionsToSetOnCreate != null)
|
||||
{
|
||||
for (String user : permissionsToSetOnCreate.keySet())
|
||||
{
|
||||
Set<String> set = permissionsToSetOnCreate.get(user);
|
||||
if (set != null)
|
||||
{
|
||||
for (String permission : set)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(), user,
|
||||
permission, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add user permissions on create and reference
|
||||
|
||||
if (userPermissions != null)
|
||||
{
|
||||
for (String permission : userPermissions)
|
||||
{
|
||||
serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(), uid, permission,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return homeFolder.getNodeRef();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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
|
||||
@@ -35,6 +35,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
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.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
@@ -107,6 +108,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
private TaggingService taggingService;
|
||||
private AuthorityService authorityService;
|
||||
private DictionaryService dictionaryService;
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* Set the path to the location of the sites root folder. For example:
|
||||
@@ -211,6 +213,16 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tenant service
|
||||
*
|
||||
* @param tenantService tenant service
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that all necessary properties and services have been provided.
|
||||
*/
|
||||
@@ -587,7 +599,30 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.site.SiteService#getSite(java.lang.String)
|
||||
*/
|
||||
public SiteInfo getSite(String shortName)
|
||||
public SiteInfo getSite(final String shortName)
|
||||
{
|
||||
// MT share - for activity service system callback
|
||||
if (tenantService.isEnabled() && (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) && tenantService.isTenantName(shortName))
|
||||
{
|
||||
final String tenantDomain = tenantService.getDomain(shortName);
|
||||
final String sName = tenantService.getBaseName(shortName, true);
|
||||
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<SiteInfo>()
|
||||
{
|
||||
public SiteInfo doWork() throws Exception
|
||||
{
|
||||
SiteInfo site = getSiteImpl(sName);
|
||||
return new SiteInfoImpl(site.getSitePreset(), shortName, site.getTitle(), site.getDescription(), site.getVisibility(), site.getCustomProperties(), site.getNodeRef());
|
||||
}
|
||||
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain));
|
||||
}
|
||||
else
|
||||
{
|
||||
return getSiteImpl(shortName);
|
||||
}
|
||||
}
|
||||
|
||||
private SiteInfo getSiteImpl(String shortName)
|
||||
{
|
||||
SiteInfo result = null;
|
||||
|
||||
@@ -714,7 +749,29 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.site.SiteService#listMembers(String, String, String, boolean)
|
||||
*/
|
||||
public Map<String, String> listMembers(String shortName, String nameFilter, String roleFilter, boolean collapseGroups)
|
||||
public Map<String, String> listMembers(String shortName, final String nameFilter, final String roleFilter, final boolean collapseGroups)
|
||||
{
|
||||
// MT share - for activity service system callback
|
||||
if (tenantService.isEnabled() && (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) && tenantService.isTenantName(shortName))
|
||||
{
|
||||
final String tenantDomain = tenantService.getDomain(shortName);
|
||||
final String sName = tenantService.getBaseName(shortName, true);
|
||||
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Map<String, String>>()
|
||||
{
|
||||
public Map<String, String> doWork() throws Exception
|
||||
{
|
||||
return listMembersImpl(sName, nameFilter, roleFilter, collapseGroups);
|
||||
}
|
||||
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain));
|
||||
}
|
||||
else
|
||||
{
|
||||
return listMembersImpl(shortName, nameFilter, roleFilter, collapseGroups);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> listMembersImpl(String shortName, String nameFilter, String roleFilter, boolean collapseGroups)
|
||||
{
|
||||
NodeRef siteNodeRef = getSiteNodeRef(shortName);
|
||||
if (siteNodeRef == null)
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,173 +1,173 @@
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
|
||||
/**
|
||||
* Interceptor to translate Node
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Derek Hulley
|
||||
* @author janv
|
||||
*/
|
||||
public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService
|
||||
{
|
||||
private static final long serialVersionUID = -5462852271914961462L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(MultiTNodeServiceInterceptor.class);
|
||||
|
||||
private static ThreadLocal<Boolean> ignoreMT = new ThreadLocal<Boolean>();
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* Change the filtering behaviour of this interceptor on the current thread.
|
||||
* Use this to switch off the filtering and pass references in and out as they
|
||||
* are found.
|
||||
*
|
||||
* @param ignoreMT <tt>true</tt> if the current thread is able to handle
|
||||
* MultiTenant-enabled references.
|
||||
* @return <tt>true</tt> if the current transaction is MT aware
|
||||
*/
|
||||
public static boolean setIgnoreMT(boolean ignoreMT)
|
||||
{
|
||||
boolean wasIgnoreMT = isIgnoreMT();
|
||||
MultiTNodeServiceInterceptor.ignoreMT.set(Boolean.valueOf(ignoreMT));
|
||||
return wasIgnoreMT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the current thread has marked itself
|
||||
* as being able to handle MultiTenant references.
|
||||
*/
|
||||
static public boolean isIgnoreMT()
|
||||
{
|
||||
if (ignoreMT.get() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ignoreMT.get();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable
|
||||
{
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
|
||||
/**
|
||||
* Interceptor to translate Node
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Derek Hulley
|
||||
* @author janv
|
||||
*/
|
||||
public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService
|
||||
{
|
||||
private static final long serialVersionUID = -5462852271914961462L;
|
||||
|
||||
private static Log logger = LogFactory.getLog(MultiTNodeServiceInterceptor.class);
|
||||
|
||||
private static ThreadLocal<Boolean> ignoreMT = new ThreadLocal<Boolean>();
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* Change the filtering behaviour of this interceptor on the current thread.
|
||||
* Use this to switch off the filtering and pass references in and out as they
|
||||
* are found.
|
||||
*
|
||||
* @param ignoreMT <tt>true</tt> if the current thread is able to handle
|
||||
* MultiTenant-enabled references.
|
||||
* @return <tt>true</tt> if the current transaction is MT aware
|
||||
*/
|
||||
public static boolean setIgnoreMT(boolean ignoreMT)
|
||||
{
|
||||
boolean wasIgnoreMT = isIgnoreMT();
|
||||
MultiTNodeServiceInterceptor.ignoreMT.set(Boolean.valueOf(ignoreMT));
|
||||
return wasIgnoreMT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the current thread has marked itself
|
||||
* as being able to handle MultiTenant references.
|
||||
*/
|
||||
static public boolean isIgnoreMT()
|
||||
{
|
||||
if (ignoreMT.get() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ignoreMT.get();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable
|
||||
{
|
||||
// See if we can shortcut (for super 'System' only)
|
||||
if (AuthenticationUtil.getSystemUserName().equals(AuthenticationUtil.getRunAsUser()) || !AuthenticationUtil.isMtEnabled())
|
||||
{
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String methodName = invocation.getMethod().getName();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Intercepting method " + methodName);
|
||||
}
|
||||
|
||||
Object[] args = invocation.getArguments();
|
||||
// Convert each of the arguments to the underlying (full) reference.
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
Object arg = args[i];
|
||||
Object newArg = arg;
|
||||
if (arg == null)
|
||||
{
|
||||
// No conversion possible
|
||||
}
|
||||
if (arg instanceof StoreRef)
|
||||
{
|
||||
StoreRef ref = (StoreRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof NodeRef)
|
||||
{
|
||||
NodeRef ref = (NodeRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef ref = (ChildAssociationRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof AssociationRef)
|
||||
{
|
||||
AssociationRef ref = (AssociationRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (!EqualsHelper.nullSafeEquals(newArg, arg))
|
||||
{
|
||||
logger.debug(
|
||||
"Argument converted: \n" +
|
||||
" Before: " + arg + "\n" +
|
||||
" After: " + newArg);
|
||||
}
|
||||
}
|
||||
|
||||
// Substitute the new value
|
||||
args[i] = newArg;
|
||||
}
|
||||
|
||||
// Make the call
|
||||
Object ret = invocation.proceed();
|
||||
|
||||
{
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String methodName = invocation.getMethod().getName();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Intercepting method " + methodName);
|
||||
}
|
||||
|
||||
Object[] args = invocation.getArguments();
|
||||
// Convert each of the arguments to the underlying (full) reference.
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
Object arg = args[i];
|
||||
Object newArg = arg;
|
||||
if (arg == null)
|
||||
{
|
||||
// No conversion possible
|
||||
}
|
||||
if (arg instanceof StoreRef)
|
||||
{
|
||||
StoreRef ref = (StoreRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof NodeRef)
|
||||
{
|
||||
NodeRef ref = (NodeRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef ref = (ChildAssociationRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
else if (arg instanceof AssociationRef)
|
||||
{
|
||||
AssociationRef ref = (AssociationRef) arg;
|
||||
newArg = tenantService.getName(ref);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (!EqualsHelper.nullSafeEquals(newArg, arg))
|
||||
{
|
||||
logger.debug(
|
||||
"Argument converted: \n" +
|
||||
" Before: " + arg + "\n" +
|
||||
" After: " + newArg);
|
||||
}
|
||||
}
|
||||
|
||||
// Substitute the new value
|
||||
args[i] = newArg;
|
||||
}
|
||||
|
||||
// Make the call
|
||||
Object ret = invocation.proceed();
|
||||
|
||||
if (methodName.equals("getProperty"))
|
||||
{
|
||||
{
|
||||
if (ret != null)
|
||||
{
|
||||
// Convert the outbound value
|
||||
@@ -213,135 +213,135 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
|
||||
}
|
||||
else if (methodName.equals("getStores"))
|
||||
{
|
||||
if ((ret == null) || (! (ret instanceof List)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<StoreRef> rawValues = (List<StoreRef>)ret;
|
||||
final List<StoreRef> convertedValues = new ArrayList<StoreRef>(rawValues.size());
|
||||
|
||||
for (StoreRef ref : rawValues)
|
||||
{
|
||||
StoreRef storeRef = ref;
|
||||
try
|
||||
{
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
// MT: return tenant stores only (although for super System return all stores - as used by
|
||||
// ConfigurationChecker, IndexRecovery, IndexBackup etc)
|
||||
if ((ret == null) || (! (ret instanceof List)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<StoreRef> rawValues = (List<StoreRef>)ret;
|
||||
final List<StoreRef> convertedValues = new ArrayList<StoreRef>(rawValues.size());
|
||||
|
||||
for (StoreRef ref : rawValues)
|
||||
{
|
||||
StoreRef storeRef = ref;
|
||||
try
|
||||
{
|
||||
if (tenantService.isEnabled() && (! storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)))
|
||||
{
|
||||
// MT: return tenant stores only (although for super System return all stores - as used by
|
||||
// ConfigurationChecker, IndexRecovery, IndexBackup etc)
|
||||
if (!AuthenticationUtil.isRunAsUserTheSystemUser())
|
||||
{
|
||||
tenantService.checkDomain(storeRef.getIdentifier());
|
||||
storeRef = tenantService.getBaseName(storeRef);
|
||||
}
|
||||
}
|
||||
|
||||
convertedValues.add(storeRef);
|
||||
}
|
||||
catch (RuntimeException re)
|
||||
{
|
||||
// deliberately ignore - stores in different domain will not be listed
|
||||
}
|
||||
}
|
||||
|
||||
return convertedValues;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert the outbound value
|
||||
ret = convertOutboundValue(ret);
|
||||
}
|
||||
|
||||
// done
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert outbound collection to spoofed (no tenant prefix) values.
|
||||
*/
|
||||
private Collection<Object> convertOutboundValues(Collection<Object> rawValues)
|
||||
{
|
||||
/*
|
||||
* Return types can be Lists or Sets, so cater for both.
|
||||
*/
|
||||
final Collection<Object> convertedValues;
|
||||
if (rawValues instanceof List)
|
||||
{
|
||||
convertedValues = new ArrayList<Object>(rawValues.size());
|
||||
}
|
||||
else if (rawValues instanceof Set)
|
||||
{
|
||||
convertedValues = new HashSet<Object>(rawValues.size(), 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Interceptor can only handle List and Set return types.");
|
||||
}
|
||||
|
||||
for (Object rawValue : rawValues)
|
||||
{
|
||||
Object convertedValue = convertOutboundValue(rawValue);
|
||||
convertedValues.add(convertedValue);
|
||||
}
|
||||
// Done
|
||||
return convertedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert outbound single value to spoofed (no tenant prefix) value.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object convertOutboundValue(Object rawValue)
|
||||
{
|
||||
if (rawValue == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Deal with collections
|
||||
Object value = rawValue;
|
||||
if (rawValue instanceof Collection)
|
||||
{
|
||||
value = convertOutboundValues((Collection<Object>)rawValue);
|
||||
}
|
||||
else if (rawValue instanceof StoreRef)
|
||||
{
|
||||
StoreRef ref = (StoreRef) rawValue;
|
||||
{
|
||||
tenantService.checkDomain(storeRef.getIdentifier());
|
||||
storeRef = tenantService.getBaseName(storeRef);
|
||||
}
|
||||
}
|
||||
|
||||
convertedValues.add(storeRef);
|
||||
}
|
||||
catch (RuntimeException re)
|
||||
{
|
||||
// deliberately ignore - stores in different domain will not be listed
|
||||
}
|
||||
}
|
||||
|
||||
return convertedValues;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert the outbound value
|
||||
ret = convertOutboundValue(ret);
|
||||
}
|
||||
|
||||
// done
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert outbound collection to spoofed (no tenant prefix) values.
|
||||
*/
|
||||
private Collection<Object> convertOutboundValues(Collection<Object> rawValues)
|
||||
{
|
||||
/*
|
||||
* Return types can be Lists or Sets, so cater for both.
|
||||
*/
|
||||
final Collection<Object> convertedValues;
|
||||
if (rawValues instanceof List)
|
||||
{
|
||||
convertedValues = new ArrayList<Object>(rawValues.size());
|
||||
}
|
||||
else if (rawValues instanceof Set)
|
||||
{
|
||||
convertedValues = new HashSet<Object>(rawValues.size(), 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Interceptor can only handle List and Set return types.");
|
||||
}
|
||||
|
||||
for (Object rawValue : rawValues)
|
||||
{
|
||||
Object convertedValue = convertOutboundValue(rawValue);
|
||||
convertedValues.add(convertedValue);
|
||||
}
|
||||
// Done
|
||||
return convertedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert outbound single value to spoofed (no tenant prefix) value.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object convertOutboundValue(Object rawValue)
|
||||
{
|
||||
if (rawValue == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Deal with collections
|
||||
Object value = rawValue;
|
||||
if (rawValue instanceof Collection)
|
||||
{
|
||||
value = convertOutboundValues((Collection<Object>)rawValue);
|
||||
}
|
||||
else if (rawValue instanceof StoreRef)
|
||||
{
|
||||
StoreRef ref = (StoreRef) rawValue;
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof NodeRef)
|
||||
{
|
||||
NodeRef ref = (NodeRef) rawValue;
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef ref = (ChildAssociationRef) rawValue;
|
||||
}
|
||||
else if (rawValue instanceof NodeRef)
|
||||
{
|
||||
NodeRef ref = (NodeRef) rawValue;
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof AssociationRef)
|
||||
{
|
||||
AssociationRef ref = (AssociationRef) rawValue;
|
||||
}
|
||||
else if (rawValue instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef ref = (ChildAssociationRef) rawValue;
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof Path)
|
||||
{
|
||||
Path ref = (Path)rawValue;
|
||||
Path outboundPath = new Path();
|
||||
Iterator<Path.Element> itr = ref.iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
Path.Element pathElement = itr.next();
|
||||
if (pathElement instanceof Path.ChildAssocElement)
|
||||
{
|
||||
pathElement = new Path.ChildAssocElement(tenantService.getBaseName(((Path.ChildAssocElement)pathElement).getRef()));
|
||||
}
|
||||
outboundPath.append(pathElement);
|
||||
}
|
||||
value = outboundPath;
|
||||
}
|
||||
// Done
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rawValue instanceof AssociationRef)
|
||||
{
|
||||
AssociationRef ref = (AssociationRef) rawValue;
|
||||
value = tenantService.getBaseName(ref);
|
||||
}
|
||||
else if (rawValue instanceof Path)
|
||||
{
|
||||
Path ref = (Path)rawValue;
|
||||
Path outboundPath = new Path();
|
||||
Iterator<Path.Element> itr = ref.iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
Path.Element pathElement = itr.next();
|
||||
if (pathElement instanceof Path.ChildAssocElement)
|
||||
{
|
||||
pathElement = new Path.ChildAssocElement(tenantService.getBaseName(((Path.ChildAssocElement)pathElement).getRef()));
|
||||
}
|
||||
outboundPath.append(pathElement);
|
||||
}
|
||||
value = outboundPath;
|
||||
}
|
||||
// Done
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,223 +1,231 @@
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
/**
|
||||
* Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance)
|
||||
*/
|
||||
|
||||
public class SingleTAdminServiceImpl implements TenantAdminService
|
||||
{
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void startTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void stopTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>false</tt> always
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void initialiseTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void deployTenants(final TenantDeployer deployer, Log logger)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void undeployTenants(final TenantDeployer deployer, Log logger)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void register(TenantDeployer tenantDeployer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void unregister(TenantDeployer tenantDeployer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an empty list always
|
||||
*/
|
||||
public List<Tenant> getAllTenants()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getCurrentUserDomain()
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getUserDomain(String username)
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the given <tt>username</tt> always
|
||||
*/
|
||||
public String getBaseNameUser(String username)
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the given <tt>baseUserName</tt> always
|
||||
*/
|
||||
public String getDomainUser(String baseUsername, String tenantDomain)
|
||||
{
|
||||
return baseUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getDomain(String name)
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void deleteTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void disableTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void enableTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public boolean existsTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void exportTenant(String tenantDomain, File directoryDestination)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public Tenant getTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public boolean isEnabledTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.workflow.WorkflowDeployer;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
/**
|
||||
* Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance)
|
||||
*/
|
||||
|
||||
public class SingleTAdminServiceImpl implements TenantAdminService
|
||||
{
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void startTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void stopTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>false</tt> always
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void initialiseTenants()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void deployTenants(final TenantDeployer deployer, Log logger)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void undeployTenants(final TenantDeployer deployer, Log logger)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void register(TenantDeployer tenantDeployer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void unregister(TenantDeployer tenantDeployer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void register(WorkflowDeployer workflowDeployer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an empty list always
|
||||
*/
|
||||
public List<Tenant> getAllTenants()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getCurrentUserDomain()
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getUserDomain(String username)
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the given <tt>username</tt> always
|
||||
*/
|
||||
public String getBaseNameUser(String username)
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the given <tt>baseUserName</tt> always
|
||||
*/
|
||||
public String getDomainUser(String baseUsername, String tenantDomain)
|
||||
{
|
||||
return baseUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
|
||||
*/
|
||||
public String getDomain(String name)
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void deleteTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void disableTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void enableTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public boolean existsTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void exportTenant(String tenantDomain, File directoryDestination)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public Tenant getTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
public boolean isEnabledTenant(String tenantDomain)
|
||||
{
|
||||
throw new UnsupportedOperationException("Single tenant mode is active.");
|
||||
}
|
||||
}
|
@@ -1,182 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.tenant;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Empty Tenant Service implementation (for Single-Tenant / Single-Instance)
|
||||
*/
|
||||
|
||||
public class SingleTServiceImpl implements TenantService
|
||||
{
|
||||
public NodeRef getName(NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public StoreRef getName(StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getName(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
return childAssocRef;
|
||||
}
|
||||
|
||||
public AssociationRef getName(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef;
|
||||
}
|
||||
|
||||
public StoreRef getName(String username, StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public QName getName(NodeRef inNodeRef, QName name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public QName getBaseName(QName name, boolean forceForNonTenant)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public NodeRef getBaseName(NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public StoreRef getBaseName(StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
return childAssocRef;
|
||||
}
|
||||
|
||||
public AssociationRef getBaseName(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef;
|
||||
}
|
||||
|
||||
public String getBaseName(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getBaseName(String name, boolean forceForNonTenant)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getBaseNameUser(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void checkDomainUser(String username)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void checkDomain(String name)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef)
|
||||
{
|
||||
return rootNodeRef;
|
||||
}
|
||||
|
||||
public boolean isTenantUser()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTenantUser(String username)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTenantName(String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getUserDomain(String username)
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getCurrentUserDomain()
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getDomain(String name)
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getDomainUser(String baseUsername, String tenantDomain)
|
||||
{
|
||||
return baseUsername;
|
||||
}
|
||||
|
||||
public Tenant getTenant(String tenantDomain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Empty Tenant Service implementation (for Single-Tenant / Single-Instance)
|
||||
*/
|
||||
|
||||
public class SingleTServiceImpl implements TenantService
|
||||
{
|
||||
public NodeRef getName(NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public StoreRef getName(StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getName(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
return childAssocRef;
|
||||
}
|
||||
|
||||
public AssociationRef getName(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef;
|
||||
}
|
||||
|
||||
public StoreRef getName(String username, StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public QName getName(QName name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public QName getName(NodeRef inNodeRef, QName name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public QName getBaseName(QName name, boolean forceForNonTenant)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public NodeRef getBaseName(NodeRef nodeRef)
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public StoreRef getBaseName(StoreRef storeRef)
|
||||
{
|
||||
return storeRef;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
return childAssocRef;
|
||||
}
|
||||
|
||||
public AssociationRef getBaseName(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef;
|
||||
}
|
||||
|
||||
public String getBaseName(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getBaseName(String name, boolean forceForNonTenant)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getBaseNameUser(String name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void checkDomainUser(String username)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void checkDomain(String name)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef)
|
||||
{
|
||||
return rootNodeRef;
|
||||
}
|
||||
|
||||
public boolean isTenantUser()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTenantUser(String username)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTenantName(String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getUserDomain(String username)
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getCurrentUserDomain()
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getDomain(String name)
|
||||
{
|
||||
return DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
public String getDomainUser(String baseUsername, String tenantDomain)
|
||||
{
|
||||
return baseUsername;
|
||||
}
|
||||
|
||||
public Tenant getTenant(String tenantDomain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,83 +1,90 @@
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Tenant Admin Service interface.
|
||||
* <p>
|
||||
* This interface provides administrative methods to provision and administer tenants.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface TenantAdminService extends TenantUserService
|
||||
{
|
||||
public void startTenants();
|
||||
|
||||
public void stopTenants();
|
||||
|
||||
/*
|
||||
* Deployer methods
|
||||
*/
|
||||
|
||||
public void deployTenants(final TenantDeployer deployer, Log logger);
|
||||
|
||||
public void undeployTenants(final TenantDeployer deployer, Log logger);
|
||||
|
||||
public void register(TenantDeployer tenantDeployer);
|
||||
|
||||
public void unregister(TenantDeployer tenantDeployer);
|
||||
|
||||
public List<Tenant> getAllTenants();
|
||||
|
||||
/*
|
||||
* Deployer methods
|
||||
*/
|
||||
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword);
|
||||
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir);
|
||||
|
||||
public void exportTenant(String tenantDomain, File directoryDestination);
|
||||
|
||||
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir);
|
||||
|
||||
public boolean existsTenant(String tenantDomain);
|
||||
|
||||
public void deleteTenant(String tenantDomain);
|
||||
|
||||
public void enableTenant(String tenantDomain);
|
||||
|
||||
public void disableTenant(String tenantDomain);
|
||||
|
||||
public Tenant getTenant(String tenantDomain);
|
||||
|
||||
public boolean isEnabledTenant(String tenantDomain);
|
||||
}
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.workflow.WorkflowDeployer;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Tenant Admin Service interface.
|
||||
* <p>
|
||||
* This interface provides administrative methods to provision and administer tenants.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface TenantAdminService extends TenantUserService
|
||||
{
|
||||
public void startTenants();
|
||||
|
||||
public void stopTenants();
|
||||
|
||||
/*
|
||||
* Tenant Deployer methods
|
||||
*/
|
||||
|
||||
public void deployTenants(final TenantDeployer deployer, Log logger);
|
||||
|
||||
public void undeployTenants(final TenantDeployer deployer, Log logger);
|
||||
|
||||
public void register(TenantDeployer tenantDeployer);
|
||||
|
||||
public void unregister(TenantDeployer tenantDeployer);
|
||||
|
||||
public List<Tenant> getAllTenants();
|
||||
|
||||
/*
|
||||
* Workflow Deployer methods
|
||||
*/
|
||||
|
||||
public void register(WorkflowDeployer workflowDeployer);
|
||||
|
||||
/*
|
||||
* Admin methods
|
||||
*/
|
||||
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword);
|
||||
|
||||
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir);
|
||||
|
||||
public void exportTenant(String tenantDomain, File directoryDestination);
|
||||
|
||||
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir);
|
||||
|
||||
public boolean existsTenant(String tenantDomain);
|
||||
|
||||
public void deleteTenant(String tenantDomain);
|
||||
|
||||
public void enableTenant(String tenantDomain);
|
||||
|
||||
public void disableTenant(String tenantDomain);
|
||||
|
||||
public Tenant getTenant(String tenantDomain);
|
||||
|
||||
public boolean isEnabledTenant(String tenantDomain);
|
||||
}
|
||||
|
@@ -1,141 +1,146 @@
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Tenant Service interface.
|
||||
* <p>
|
||||
* This interface provides methods to support either ST or MT implementations.
|
||||
*
|
||||
*/
|
||||
public interface TenantService extends TenantUserService
|
||||
{
|
||||
public static final String SEPARATOR = "@";
|
||||
|
||||
public static final String DEFAULT_DOMAIN = "";
|
||||
|
||||
public static final String ADMIN_BASENAME = "admin";
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getName(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getName(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public ChildAssociationRef getName(ChildAssociationRef childAssocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public AssociationRef getName(AssociationRef assocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getName(String username, StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public QName getName(NodeRef inNodeRef, QName name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getName(String name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public QName getBaseName(QName name, boolean forceIfNonTenant);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getBaseName(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getBaseName(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public AssociationRef getBaseName(AssociationRef assocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getBaseName(String name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getBaseName(String name, boolean forceIfNonTenant);
|
||||
|
||||
public void checkDomainUser(String username);
|
||||
|
||||
public void checkDomain(String name);
|
||||
|
||||
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef);
|
||||
|
||||
public boolean isTenantUser();
|
||||
|
||||
public boolean isTenantUser(String username);
|
||||
|
||||
public boolean isTenantName(String name);
|
||||
|
||||
public String getUserDomain(String username);
|
||||
|
||||
public Tenant getTenant(String tenantDomain);
|
||||
}
|
||||
/*
|
||||
* 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.tenant;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Tenant Service interface.
|
||||
* <p>
|
||||
* This interface provides methods to support either ST or MT implementations.
|
||||
*
|
||||
*/
|
||||
public interface TenantService extends TenantUserService
|
||||
{
|
||||
public static final String SEPARATOR = "@";
|
||||
|
||||
public static final String DEFAULT_DOMAIN = "";
|
||||
|
||||
public static final String ADMIN_BASENAME = "admin";
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getName(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getName(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public ChildAssociationRef getName(ChildAssociationRef childAssocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public AssociationRef getName(AssociationRef assocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getName(String username, StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public QName getName(QName name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public QName getName(NodeRef inNodeRef, QName name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>with</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getName(String name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public QName getBaseName(QName name, boolean forceIfNonTenant);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public NodeRef getBaseName(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public StoreRef getBaseName(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public AssociationRef getBaseName(AssociationRef assocRef);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getBaseName(String name);
|
||||
|
||||
/**
|
||||
* @return the reference <b>without</b> the tenant-specific ID attached
|
||||
*/
|
||||
public String getBaseName(String name, boolean forceIfNonTenant);
|
||||
|
||||
public void checkDomainUser(String username);
|
||||
|
||||
public void checkDomain(String name);
|
||||
|
||||
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef);
|
||||
|
||||
public boolean isTenantUser();
|
||||
|
||||
public boolean isTenantUser(String username);
|
||||
|
||||
public boolean isTenantName(String name);
|
||||
|
||||
public String getUserDomain(String username);
|
||||
|
||||
public Tenant getTenant(String tenantDomain);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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
|
||||
@@ -40,6 +40,7 @@ import org.alfresco.repo.dictionary.RepositoryLocation;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantAdminService;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -85,6 +86,7 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
||||
private List<Properties> workflowDefinitions;
|
||||
private List<String> models = new ArrayList<String>();
|
||||
private List<String> resourceBundles = new ArrayList<String>();
|
||||
private TenantAdminService tenantAdminService;
|
||||
private TenantService tenantService;
|
||||
|
||||
private NodeService nodeService;
|
||||
@@ -145,6 +147,16 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
||||
this.dictionaryDAO = dictionaryDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tenant admin service
|
||||
*
|
||||
* @param tenantService the tenant admin service
|
||||
*/
|
||||
public void setTenantAdminService(TenantAdminService tenantAdminService)
|
||||
{
|
||||
this.tenantAdminService = tenantAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tenant service
|
||||
*
|
||||
@@ -432,6 +444,8 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
tenantAdminService.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1261,6 +1261,12 @@ public class JBPMEngine extends BPMEngine
|
||||
public List<WorkflowTask> doInJbpm(JbpmContext context)
|
||||
{
|
||||
Session session = context.getSession();
|
||||
|
||||
if ((query.getProcessName() != null) && (tenantService.isEnabled()))
|
||||
{
|
||||
query.setProcessName(tenantService.getName(query.getProcessName()));
|
||||
}
|
||||
|
||||
Criteria criteria = createTaskQueryCriteria(session, query);
|
||||
List<TaskInstance> tasks = criteria.list();
|
||||
|
||||
@@ -1505,7 +1511,19 @@ public class JBPMEngine extends BPMEngine
|
||||
{
|
||||
process = (process == null) ? root.createCriteria("processInstance") : process;
|
||||
Criteria processDef = process.createCriteria("processDefinition");
|
||||
processDef.add(Restrictions.eq("name", query.getProcessName().toPrefixString(namespaceService)));
|
||||
|
||||
String processName = null;
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
QName baseProcessName = tenantService.getBaseName(query.getProcessName(), true);
|
||||
processName = tenantService.getName(baseProcessName.toPrefixString(namespaceService));
|
||||
}
|
||||
else
|
||||
{
|
||||
processName = query.getProcessName().toPrefixString(namespaceService);
|
||||
}
|
||||
|
||||
processDef.add(Restrictions.eq("name", processName));
|
||||
}
|
||||
|
||||
return process;
|
||||
|
Reference in New Issue
Block a user