mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9155 related refactoring
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29525 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,10 +32,7 @@ public class BlogEntity extends NodeBackedEntity
|
|||||||
private String postedDate;
|
private String postedDate;
|
||||||
|
|
||||||
// Supplemental query-related parameters
|
// Supplemental query-related parameters
|
||||||
private Long parentNodeId;
|
|
||||||
private Long nameQNameId;
|
|
||||||
private Long publishedQNameId;
|
private Long publishedQNameId;
|
||||||
private Long contentTypeQNameId;
|
|
||||||
|
|
||||||
private Long blogIntAspectQNameId;
|
private Long blogIntAspectQNameId;
|
||||||
private Long blogIntPostedQNameId;
|
private Long blogIntPostedQNameId;
|
||||||
@@ -50,11 +47,8 @@ public class BlogEntity extends NodeBackedEntity
|
|||||||
|
|
||||||
public BlogEntity(Long parentNodeId, Long nameQNameId, Long publishedQNameId, Long contentTypeQNameId, Long blogIntAspectQNameId, Long blogIntPostedQNameId)
|
public BlogEntity(Long parentNodeId, Long nameQNameId, Long publishedQNameId, Long contentTypeQNameId, Long blogIntAspectQNameId, Long blogIntPostedQNameId)
|
||||||
{
|
{
|
||||||
super();
|
super(parentNodeId, nameQNameId, contentTypeQNameId);
|
||||||
this.parentNodeId = parentNodeId;
|
|
||||||
this.nameQNameId = nameQNameId;
|
|
||||||
this.publishedQNameId = publishedQNameId;
|
this.publishedQNameId = publishedQNameId;
|
||||||
this.contentTypeQNameId = contentTypeQNameId;
|
|
||||||
|
|
||||||
this.blogIntAspectQNameId = blogIntAspectQNameId;
|
this.blogIntAspectQNameId = blogIntAspectQNameId;
|
||||||
this.blogIntPostedQNameId = blogIntPostedQNameId;
|
this.blogIntPostedQNameId = blogIntPostedQNameId;
|
||||||
@@ -84,26 +78,11 @@ public class BlogEntity extends NodeBackedEntity
|
|||||||
|
|
||||||
// Supplemental query-related parameters
|
// Supplemental query-related parameters
|
||||||
|
|
||||||
public Long getParentNodeId()
|
|
||||||
{
|
|
||||||
return parentNodeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getNameQNameId()
|
|
||||||
{
|
|
||||||
return nameQNameId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getPublishedQNameId()
|
public Long getPublishedQNameId()
|
||||||
{
|
{
|
||||||
return publishedQNameId;
|
return publishedQNameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getContentTypeQNameId()
|
|
||||||
{
|
|
||||||
return contentTypeQNameId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getBlogIntAspectQNameId()
|
public Long getBlogIntAspectQNameId()
|
||||||
{
|
{
|
||||||
return blogIntAspectQNameId;
|
return blogIntAspectQNameId;
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.query.CannedQuery;
|
import org.alfresco.query.CannedQuery;
|
||||||
import org.alfresco.query.CannedQueryFactory;
|
import org.alfresco.query.CannedQueryFactory;
|
||||||
@@ -77,10 +78,12 @@ import org.alfresco.service.cmr.security.NoSuchPersonException;
|
|||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
@@ -2135,6 +2138,118 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
return fileInfo.getNodeRef();
|
return fileInfo.getNodeRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to create a container if missing, and mark it as a
|
||||||
|
* tag scope if it isn't already one
|
||||||
|
*/
|
||||||
|
public static NodeRef getSiteContainer(final String siteShortName,
|
||||||
|
final String componentName, final boolean create,
|
||||||
|
final SiteService siteService, final TransactionService transactionService,
|
||||||
|
final TaggingService taggingService)
|
||||||
|
{
|
||||||
|
// Does the site exist?
|
||||||
|
if(siteService.getSite(siteShortName) == null) {
|
||||||
|
// Either the site doesn't exist, or you're not allowed to see it
|
||||||
|
if(! create)
|
||||||
|
{
|
||||||
|
// Just say there's no container
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We can't create on a non-existant site
|
||||||
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Unable to create the " + componentName + " container from a hidden or non-existant site"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check about the container
|
||||||
|
if(! siteService.hasContainer(siteShortName, componentName))
|
||||||
|
{
|
||||||
|
if(create)
|
||||||
|
{
|
||||||
|
if(transactionService.isReadOnly())
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Unable to create the " + componentName + " container from a read only transaction"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Have the site container created
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Creating " + componentName + " container in site " + siteShortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeRef container = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef doWork() throws Exception
|
||||||
|
{
|
||||||
|
// Create the site container
|
||||||
|
NodeRef container = siteService.createContainer(
|
||||||
|
siteShortName, componentName, null, null
|
||||||
|
);
|
||||||
|
|
||||||
|
// Done
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName()
|
||||||
|
);
|
||||||
|
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Created " + componentName + " as " + container + " for " + siteShortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Container is setup and ready to use
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No container for this site, and not allowed to create
|
||||||
|
// Have the site container created
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("No " + componentName + " component in " + siteShortName + " and not creating");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Container is already there
|
||||||
|
final NodeRef container = siteService.getContainer(siteShortName, componentName);
|
||||||
|
|
||||||
|
// Ensure the calendar container has the tag scope aspect applied to it
|
||||||
|
if(! taggingService.isTagScope(container))
|
||||||
|
{
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Attaching tag scope to " + componentName + " " + container.toString() + " for " + siteShortName);
|
||||||
|
}
|
||||||
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>() {
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
|
new RetryingTransactionCallback<Void>() {
|
||||||
|
public Void execute() throws Throwable {
|
||||||
|
// Add the tag scope aspect
|
||||||
|
taggingService.addTagScope(container);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, false, true
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Container is appropriately setup and configured
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to get the activity data for a user
|
* Helper method to get the activity data for a user
|
||||||
*
|
*
|
||||||
|
@@ -27,8 +27,6 @@ import org.alfresco.service.NotAuditable;
|
|||||||
/**
|
/**
|
||||||
* The Calendar service.
|
* The Calendar service.
|
||||||
*
|
*
|
||||||
* TODO Lucene free querying
|
|
||||||
*
|
|
||||||
* @author Nick Burch
|
* @author Nick Burch
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user