mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Updated channels.get webscript to support specifying a NodeRef.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28552 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
<import resource="classpath*:alfresco/transfer-service-context.xml"/>
|
<import resource="classpath*:alfresco/transfer-service-context.xml"/>
|
||||||
<import resource="classpath*:alfresco/web-publishing-context.xml" />
|
<import resource="classpath*:alfresco/web-publishing-context.xml" />
|
||||||
|
<import resource="classpath*:alfresco/social-publishing-context.xml" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Import activation extensions for Multi-Tenancy.
|
Import activation extensions for Multi-Tenancy.
|
||||||
|
@@ -199,6 +199,44 @@
|
|||||||
</mandatory-aspects>
|
</mandatory-aspects>
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
|
<type name="pub:Connection">
|
||||||
|
<title>Publishing Connectiont</title>
|
||||||
|
<description>Holds details of an OAuth connection</description>
|
||||||
|
<parent>cm:cmobject</parent>
|
||||||
|
<properties>
|
||||||
|
<property name="pub:accountId">
|
||||||
|
<title>Account Id</title>
|
||||||
|
<type>d:any</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
<property name="pub:providerId">
|
||||||
|
<title>Provider Id</title>
|
||||||
|
<type>d:text</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
<property name="pub:providerAccountId">
|
||||||
|
<title>Provider Account Id</title>
|
||||||
|
<type>d:text</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
<property name="pub:accessToken">
|
||||||
|
<title>Access Token</title>
|
||||||
|
<type>d:text</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
<property name="pub:secret">
|
||||||
|
<title>Access Secret</title>
|
||||||
|
<type>d:text</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
<property name="pub:refreshToken">
|
||||||
|
<title>Refresh Token</title>
|
||||||
|
<type>d:text</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</type>
|
||||||
|
|
||||||
</types>
|
</types>
|
||||||
|
|
||||||
<aspects>
|
<aspects>
|
||||||
|
32
config/alfresco/social-publishing-context.xml
Normal file
32
config/alfresco/social-publishing-context.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<!-- Stores OAuth and similar credentials in protected -->
|
||||||
|
<!-- parts of the Data Dictionary -->
|
||||||
|
<bean id="socialConnectionRepository" class="org.alfresco.repo.publishing.authorization.NodeBasedConnectionRepository">
|
||||||
|
<property name="nodeService" ref="NodeService"/>
|
||||||
|
<property name="searchService" ref="SearchService"/>
|
||||||
|
<property name="repositoryHelper" ref="repositoryHelper"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Configure a Twitter service provider -->
|
||||||
|
<bean id="social.connect.twitter" class="org.springframework.social.twitter.connect.TwitterServiceProvider">
|
||||||
|
<constructor-arg value="${twitter.consumerKey}" />
|
||||||
|
<constructor-arg value="${twitter.consumerSecret}" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Configure a Facebook service provider -->
|
||||||
|
<bean id="social.connect.facebook" class="org.springframework.social.facebook.connect.FacebookServiceProvider">
|
||||||
|
<constructor-arg value="${facebook.appId}" />
|
||||||
|
<constructor-arg value="${facebook.appSecret}" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Configure a Linked In service provider -->
|
||||||
|
<bean id="social.connect.linkedin" class="org.springframework.social.linkedin.connect.LinkedInServiceProvider">
|
||||||
|
<constructor-arg value="${linkedIn.consumerKey}" />
|
||||||
|
<constructor-arg value="${linkedIn.consumerSecret}" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
@@ -39,9 +39,9 @@
|
|||||||
|
|
||||||
<!-- Channel Service -->
|
<!-- Channel Service -->
|
||||||
<bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl">
|
<bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl">
|
||||||
<property name="dictionaryService" ref="dictionaryService" />
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="siteService" ref="siteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
<property name="environmentHelper" ref="environmentHelper" />
|
<property name="environmentHelper" ref="environmentHelper" />
|
||||||
<property name="channelHelper" ref="channelHelper" />
|
<property name="channelHelper" ref="channelHelper" />
|
||||||
</bean>
|
</bean>
|
||||||
@@ -53,21 +53,21 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">
|
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="dictionaryService" ref="dictionaryService" />
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
<property name="contentService" ref="contentService" />
|
<property name="fileFolderService" ref="FileFolderService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper">
|
<bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper">
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="siteService" ref="siteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
||||||
<property name="channelHelper" ref="channelHelper" />
|
<property name="channelHelper" ref="channelHelper" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="publishingEventHelper" class="org.alfresco.repo.publishing.PublishingEventHelper">
|
<bean id="publishingEventHelper" class="org.alfresco.repo.publishing.PublishingEventHelper">
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="contentService" ref="contentService" />
|
<property name="contentService" ref="ContentService" />
|
||||||
<property name="serializer" ref="publishingPackageSerializer" />
|
<property name="serializer" ref="publishingPackageSerializer" />
|
||||||
<property name="workflowService" ref="WorkflowService" />
|
<property name="workflowService" ref="WorkflowService" />
|
||||||
<property name="workflowEngineId" value="jbpm" />
|
<property name="workflowEngineId" value="jbpm" />
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<property name="channelHelper" ref="channelHelper" />
|
<property name="channelHelper" ref="channelHelper" />
|
||||||
<property name="channelService" ref="channelService" />
|
<property name="channelService" ref="channelService" />
|
||||||
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@@ -10,17 +10,22 @@
|
|||||||
parent="baseChannelType" />
|
parent="baseChannelType" />
|
||||||
|
|
||||||
<!-- Mock Node Service -->
|
<!-- Mock Node Service -->
|
||||||
<bean id="nodeService" class="org.mockito.Mockito" factory-method="mock">
|
<bean id="NodeService" class="org.mockito.Mockito" factory-method="mock">
|
||||||
<constructor-arg value="org.alfresco.service.cmr.repository.NodeService" />
|
<constructor-arg value="org.alfresco.service.cmr.repository.NodeService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- File Folder Service -->
|
||||||
|
<bean id="FileFolderService" class="org.mockito.Mockito" factory-method="mock">
|
||||||
|
<constructor-arg value="org.alfresco.service.cmr.model.FileFolderService" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Mock Dictionary Service -->
|
<!-- Mock Dictionary Service -->
|
||||||
<bean id="dictionaryService" class="org.mockito.Mockito" factory-method="mock">
|
<bean id="DictionaryService" class="org.mockito.Mockito" factory-method="mock">
|
||||||
<constructor-arg value="org.alfresco.service.cmr.dictionary.DictionaryService" />
|
<constructor-arg value="org.alfresco.service.cmr.dictionary.DictionaryService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Mock Site Service -->
|
<!-- Mock Site Service -->
|
||||||
<bean id="siteService" class="org.mockito.Mockito" factory-method="mock">
|
<bean id="SiteService" class="org.mockito.Mockito" factory-method="mock">
|
||||||
<constructor-arg value="org.alfresco.service.cmr.site.SiteService" />
|
<constructor-arg value="org.alfresco.service.cmr.site.SiteService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
@@ -30,7 +35,7 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Mock Content Service -->
|
<!-- Mock Content Service -->
|
||||||
<bean id="contentService" class="org.mockito.Mockito" factory-method="mock">
|
<bean id="ContentService" class="org.mockito.Mockito" factory-method="mock">
|
||||||
<constructor-arg value="org.alfresco.service.cmr.repository.ContentService" />
|
<constructor-arg value="org.alfresco.service.cmr.repository.ContentService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
|||||||
@Override
|
@Override
|
||||||
public NodeFilter getNodeFilter()
|
public NodeFilter getNodeFilter()
|
||||||
{
|
{
|
||||||
return null;
|
return nodeFilter;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
@@ -112,4 +112,12 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
|||||||
return nodeFinder;
|
return nodeFinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getMaximumStatusLength()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
package org.alfresco.repo.publishing;
|
package org.alfresco.repo.publishing;
|
||||||
|
|
||||||
import static org.alfresco.model.ContentModel.ASSOC_CONTAINS;
|
import static org.alfresco.model.ContentModel.ASSOC_CONTAINS;
|
||||||
import static org.alfresco.model.ContentModel.PROP_CONTENT;
|
|
||||||
import static org.alfresco.model.ContentModel.PROP_CONTENT_PROPERTY_NAME;
|
|
||||||
import static org.alfresco.repo.publishing.PublishingModel.ASPECT_CONTENT_ROOT;
|
import static org.alfresco.repo.publishing.PublishingModel.ASPECT_CONTENT_ROOT;
|
||||||
import static org.alfresco.repo.publishing.PublishingModel.ASPECT_PUBLISHED;
|
import static org.alfresco.repo.publishing.PublishingModel.ASPECT_PUBLISHED;
|
||||||
import static org.alfresco.repo.publishing.PublishingModel.ASSOC_SOURCE;
|
import static org.alfresco.repo.publishing.PublishingModel.ASSOC_SOURCE;
|
||||||
@@ -32,6 +30,8 @@ import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE_ID;
|
|||||||
import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL;
|
import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -40,12 +40,13 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
@@ -53,6 +54,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.collections.CollectionUtils;
|
||||||
|
import org.alfresco.util.collections.Filter;
|
||||||
|
import org.alfresco.util.collections.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
@@ -65,7 +69,7 @@ public class ChannelHelper
|
|||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
private ContentService contentService;
|
private FileFolderService fileFolderService;
|
||||||
|
|
||||||
public ChannelHelper()
|
public ChannelHelper()
|
||||||
{
|
{
|
||||||
@@ -230,47 +234,37 @@ public class ChannelHelper
|
|||||||
return assoc;
|
return assoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param nodeToPublish
|
|
||||||
* @param channelType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean canPublish(NodeRef nodeToPublish, ChannelType type)
|
public boolean canPublish(NodeRef nodeToPublish, ChannelType type)
|
||||||
{
|
{
|
||||||
if(type.canPublish() == false)
|
if(type.canPublish() == false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean isContentTypeSupported = isContentTypeSupported(nodeToPublish, type);
|
FileInfo file = fileFolderService.getFileInfo(nodeToPublish);
|
||||||
boolean isMimetypeSupported = isMimetypeSupported(nodeToPublish, type);
|
ContentData contentData = file.getContentData();
|
||||||
|
String mimetype = contentData == null ? null : contentData.getMimetype();
|
||||||
|
boolean isContentTypeSupported = isContentTypeSupported(file.getType(), type);
|
||||||
|
boolean isMimetypeSupported = isMimetypeSupported(mimetype, type);
|
||||||
return isContentTypeSupported && isMimetypeSupported;
|
return isContentTypeSupported && isMimetypeSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypeSupported(NodeRef nodeToPublish, ChannelType type)
|
private boolean isMimetypeSupported(String mimetype, ChannelType type)
|
||||||
{
|
{
|
||||||
Set<String> supportedMimetypes = type.getSupportedMimetypes();
|
Set<String> supportedMimetypes = type.getSupportedMimetypes();
|
||||||
if (supportedMimetypes == null || supportedMimetypes.isEmpty())
|
if (supportedMimetypes == null || supportedMimetypes.isEmpty())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QName contentProp = (QName) nodeService.getProperty(nodeToPublish, PROP_CONTENT_PROPERTY_NAME);
|
return supportedMimetypes.contains(mimetype);
|
||||||
if (contentProp == null)
|
|
||||||
{
|
|
||||||
String defaultValue = dictionaryService.getProperty(PROP_CONTENT_PROPERTY_NAME).getDefaultValue();
|
|
||||||
contentProp = defaultValue == null ? PROP_CONTENT : QName.createQName(defaultValue);
|
|
||||||
}
|
|
||||||
ContentReader reader = contentService.getReader(nodeToPublish, contentProp);
|
|
||||||
return supportedMimetypes.contains(reader.getMimetype());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isContentTypeSupported(NodeRef nodeToPublish, ChannelType type)
|
private boolean isContentTypeSupported(QName contentType, ChannelType type)
|
||||||
{
|
{
|
||||||
Set<QName> supportedContentTypes = type.getSupportedContentTypes();
|
Set<QName> supportedContentTypes = type.getSupportedContentTypes();
|
||||||
if(supportedContentTypes == null || supportedContentTypes.isEmpty())
|
if(supportedContentTypes == null || supportedContentTypes.isEmpty())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QName contentType = nodeService.getType(nodeToPublish);
|
|
||||||
for (QName supportedType : supportedContentTypes)
|
for (QName supportedType : supportedContentTypes)
|
||||||
{
|
{
|
||||||
if(contentType.equals(supportedType)
|
if(contentType.equals(supportedType)
|
||||||
@@ -307,6 +301,60 @@ public class ChannelHelper
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Channel> getChannels(NodeRef channelContainer, final ChannelService channelService)
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> channelAssocs = getChannelAssocs(channelContainer);
|
||||||
|
return CollectionUtils.transform(channelAssocs, getChannelTransformer(channelService));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Channel> getChannelsByType(NodeRef containerNode, String channelTypeId, ChannelService channelService)
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> channelAssocs = getChannelAssocsByType(containerNode, channelTypeId);
|
||||||
|
return CollectionUtils.transform(channelAssocs, getChannelTransformer(channelService));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChannelType> getReleventChannelTypes(final NodeRef nodeToPublish, Collection<ChannelType> channelTypes)
|
||||||
|
{
|
||||||
|
return CollectionUtils.filter(channelTypes, new Filter<ChannelType>()
|
||||||
|
{
|
||||||
|
public Boolean apply(ChannelType type)
|
||||||
|
{
|
||||||
|
return canPublish(nodeToPublish, type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChannelType> getStatusUpdateChannelTypes(Collection<ChannelType> channelTypes)
|
||||||
|
{
|
||||||
|
return CollectionUtils.filter(channelTypes, new Filter<ChannelType>()
|
||||||
|
{
|
||||||
|
public Boolean apply(ChannelType type)
|
||||||
|
{
|
||||||
|
return type.canPublishStatusUpdates();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ChildAssociationRef> getChannelAssocs(NodeRef channelContainer)
|
||||||
|
{
|
||||||
|
if(channelContainer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Collection<QName> channelNodeTypes = dictionaryService.getSubTypes(TYPE_DELIVERY_CHANNEL, true);
|
||||||
|
HashSet<QName> childNodeTypeQNames = new HashSet<QName>(channelNodeTypes);
|
||||||
|
return nodeService.getChildAssocs(channelContainer, childNodeTypeQNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ChildAssociationRef> getChannelAssocsByType(NodeRef channelContainer, String channelTypeId)
|
||||||
|
{
|
||||||
|
if(channelContainer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return nodeService.getChildAssocsByPropertyValue(channelContainer, PROP_CHANNEL_TYPE_ID, channelTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
private Pair<NodeRef, String> getChannelAndType(NodeRef node)
|
private Pair<NodeRef, String> getChannelAndType(NodeRef node)
|
||||||
{
|
{
|
||||||
NodeRef channel = (NodeRef) nodeService.getProperty(node, PROP_CHANNEL);
|
NodeRef channel = (NodeRef) nodeService.getProperty(node, PROP_CHANNEL);
|
||||||
@@ -328,10 +376,16 @@ public class ChannelHelper
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendStatusUpdates(NodeRef nodeToPublish, NodeRef channelNode, ChannelType channelType)
|
private Function<ChildAssociationRef, Channel> getChannelTransformer(final ChannelService channelService)
|
||||||
{
|
{
|
||||||
//TODO
|
return new Function<ChildAssociationRef, Channel>()
|
||||||
|
{
|
||||||
|
public Channel apply(ChildAssociationRef value)
|
||||||
|
{
|
||||||
|
NodeRef channelNode = value.getChildRef();
|
||||||
|
return buildChannelObject(channelNode, channelService);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,11 +405,11 @@ public class ChannelHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentService the contentService to set
|
* @param fileFolderService the fileFolderService to set
|
||||||
*/
|
*/
|
||||||
public void setContentService(ContentService contentService)
|
public void setFileFolderService(FileFolderService fileFolderService)
|
||||||
{
|
{
|
||||||
this.contentService = contentService;
|
this.fileFolderService = fileFolderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@ import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -40,15 +39,18 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|||||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||||
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.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.alfresco.util.collections.CollectionUtils;
|
||||||
|
import org.alfresco.util.collections.Filter;
|
||||||
|
import org.alfresco.util.collections.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
@@ -61,6 +63,8 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
|
|
||||||
private static final String CHANNEL_CONTAINER_NAME = "channels";
|
private static final String CHANNEL_CONTAINER_NAME = "channels";
|
||||||
|
|
||||||
|
public static final String NAME = "channelService";
|
||||||
|
|
||||||
private final Map<String, ChannelType> channelTypes = new TreeMap<String, ChannelType>();
|
private final Map<String, ChannelType> channelTypes = new TreeMap<String, ChannelType>();
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
@@ -194,23 +198,8 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
public List<Channel> getChannels(String siteId)
|
public List<Channel> getChannels(String siteId)
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatory("siteId", siteId);
|
ParameterCheck.mandatory("siteId", siteId);
|
||||||
|
|
||||||
NodeRef channelContainer = getChannelContainer(siteId);
|
NodeRef channelContainer = getChannelContainer(siteId);
|
||||||
if(channelContainer == null)
|
return channelHelper.getChannels(channelContainer, this);
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
Collection<QName> channelNodeTypes = dictionaryService.getSubTypes(TYPE_DELIVERY_CHANNEL, true);
|
|
||||||
HashSet<QName> childNodeTypeQNames = new HashSet<QName>(channelNodeTypes);
|
|
||||||
List<ChildAssociationRef> channelAssocs = nodeService.getChildAssocs(channelContainer, childNodeTypeQNames);
|
|
||||||
List<Channel> channelList = new ArrayList<Channel>(channelAssocs.size());
|
|
||||||
for (ChildAssociationRef channelAssoc : channelAssocs)
|
|
||||||
{
|
|
||||||
NodeRef channelNode = channelAssoc.getChildRef();
|
|
||||||
Channel channel = channelHelper.buildChannelObject(channelNode, this);
|
|
||||||
channelList.add(channel);
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(channelList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,6 +228,82 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public List<Channel> getRelevantPublishingChannels(NodeRef nodeToPublish)
|
||||||
|
{
|
||||||
|
SiteInfo siteInfo = siteService.getSite(nodeToPublish);
|
||||||
|
if(siteInfo != null)
|
||||||
|
{
|
||||||
|
final NodeRef containerNode = getChannelContainer(siteInfo.getShortName());
|
||||||
|
if(containerNode != null)
|
||||||
|
{
|
||||||
|
List<ChannelType> types = channelHelper.getReleventChannelTypes(nodeToPublish, channelTypes.values());
|
||||||
|
return getChannelsForTypes(containerNode, types);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public List<Channel> getPublishingChannels(String siteId)
|
||||||
|
{
|
||||||
|
final NodeRef containerNode = getChannelContainer(siteId);
|
||||||
|
if(containerNode != null)
|
||||||
|
{
|
||||||
|
List<ChannelType> types = CollectionUtils.filter(channelTypes.values(), new Filter<ChannelType>()
|
||||||
|
{
|
||||||
|
public Boolean apply(ChannelType type)
|
||||||
|
{
|
||||||
|
return type.canPublish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return getChannelsForTypes(containerNode, types);
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public List<Channel> getStatusUpdateChannels(String siteId)
|
||||||
|
{
|
||||||
|
final NodeRef containerNode = getChannelContainer(siteId);
|
||||||
|
if (containerNode != null)
|
||||||
|
{
|
||||||
|
List<ChannelType> types = channelHelper.getStatusUpdateChannelTypes(channelTypes.values());
|
||||||
|
return getChannelsForTypes(containerNode, types);
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public List<Channel> getStatusUpdateChannels(NodeRef nodeToPublish)
|
||||||
|
{
|
||||||
|
SiteInfo site = siteService.getSite(nodeToPublish);
|
||||||
|
if(site!=null)
|
||||||
|
{
|
||||||
|
return getStatusUpdateChannels(site.getShortName());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Channel> getChannelsForTypes(final NodeRef containerNode, List<ChannelType> types)
|
||||||
|
{
|
||||||
|
return CollectionUtils.transformFlat(types, new Function<ChannelType, List<Channel>>()
|
||||||
|
{
|
||||||
|
public List<Channel> apply(ChannelType channelType)
|
||||||
|
{
|
||||||
|
return channelHelper.getChannelsByType(containerNode, channelType.getId(), ChannelServiceImpl.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private NodeRef getChannelContainer(final String siteId)
|
private NodeRef getChannelContainer(final String siteId)
|
||||||
{
|
{
|
||||||
return siteService.getContainer(siteId, CHANNEL_CONTAINER_NAME);
|
return siteService.getContainer(siteId, CHANNEL_CONTAINER_NAME);
|
||||||
|
@@ -78,10 +78,10 @@ public class PublishingEventHelperTest
|
|||||||
@Resource(name="publishingEventHelper")
|
@Resource(name="publishingEventHelper")
|
||||||
PublishingEventHelper helper;
|
PublishingEventHelper helper;
|
||||||
|
|
||||||
@Resource(name="nodeService")
|
@Resource(name="NodeService")
|
||||||
NodeService nodeService;
|
NodeService nodeService;
|
||||||
|
|
||||||
@Resource(name="contentService")
|
@Resource(name="ContentService")
|
||||||
ContentService contentService;
|
ContentService contentService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -40,6 +40,7 @@ public interface PublishingModel
|
|||||||
public static final QName TYPE_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "PublishingQueue");
|
public static final QName TYPE_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "PublishingQueue");
|
||||||
public static final QName TYPE_CHANNEL_CONTAINER = QName.createQName(NAMESPACE, "SiteChannelContainer");
|
public static final QName TYPE_CHANNEL_CONTAINER = QName.createQName(NAMESPACE, "SiteChannelContainer");
|
||||||
public static final QName TYPE_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "PublishingEvent");
|
public static final QName TYPE_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "PublishingEvent");
|
||||||
|
public static final QName TYPE_PUBLISHING_CONNECTION = QName.createQName(NAMESPACE, "Connection");
|
||||||
|
|
||||||
public static final QName ASPECT_CONTENT_ROOT = QName.createQName(NAMESPACE, "ContentRoot");
|
public static final QName ASPECT_CONTENT_ROOT = QName.createQName(NAMESPACE, "ContentRoot");
|
||||||
public static final QName ASPECT_CHANNEL_INFO= QName.createQName(NAMESPACE, "channelInfo");
|
public static final QName ASPECT_CHANNEL_INFO= QName.createQName(NAMESPACE, "channelInfo");
|
||||||
@@ -60,6 +61,13 @@ public interface PublishingModel
|
|||||||
public static final QName PROP_STATUS_UPDATE_CHANNEL_NAMES = QName.createQName(NAMESPACE, "statusUpdateChannelNames");
|
public static final QName PROP_STATUS_UPDATE_CHANNEL_NAMES = QName.createQName(NAMESPACE, "statusUpdateChannelNames");
|
||||||
public static final QName PROP_STATUS_UPDATE_NODE_REF = QName.createQName(NAMESPACE, "statusUpdateNodeRef");
|
public static final QName PROP_STATUS_UPDATE_NODE_REF = QName.createQName(NAMESPACE, "statusUpdateNodeRef");
|
||||||
public static final QName PROP_STATUS_UPDATE_MESSAGE = QName.createQName(NAMESPACE, "statusUpdateMessage");
|
public static final QName PROP_STATUS_UPDATE_MESSAGE = QName.createQName(NAMESPACE, "statusUpdateMessage");
|
||||||
|
// Publishing Connection Properties
|
||||||
|
public static final QName PROP_ACCOUNT_ID= QName.createQName(NAMESPACE, "accountId");
|
||||||
|
public static final QName PROP_PROVIDER_ID= QName.createQName(NAMESPACE, "providerId");
|
||||||
|
public static final QName PROP_PROVIDER_ACCOUNT_ID= QName.createQName(NAMESPACE, "providerAccountId");
|
||||||
|
public static final QName PROP_ACCESS_TOKEN= QName.createQName(NAMESPACE, "accessToken");
|
||||||
|
public static final QName PROP_ACCESS_SECRET= QName.createQName(NAMESPACE, "secret");
|
||||||
|
public static final QName PROP_REFRESH_TOKEN= QName.createQName(NAMESPACE, "refreshToken");
|
||||||
|
|
||||||
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED = "SCHEDULED";
|
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED = "SCHEDULED";
|
||||||
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_IN_PROGRESS = "IN_PROGRESS";
|
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_IN_PROGRESS = "IN_PROGRESS";
|
||||||
@@ -67,6 +75,7 @@ public interface PublishingModel
|
|||||||
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_COMPLETED = "COMPLETED";
|
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_COMPLETED = "COMPLETED";
|
||||||
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_FAILED = "FAILED";
|
public static final String PROPVAL_PUBLISHING_EVENT_STATUS_FAILED = "FAILED";
|
||||||
|
|
||||||
|
|
||||||
public static final QName ASSOC_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "publishingQueueAssoc");
|
public static final QName ASSOC_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "publishingQueueAssoc");
|
||||||
public static final QName ASSOC_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "publishingEventAssoc");
|
public static final QName ASSOC_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "publishingEventAssoc");
|
||||||
public static final QName ASSOC_SOURCE = QName.createQName(NAMESPACE, "source");
|
public static final QName ASSOC_SOURCE = QName.createQName(NAMESPACE, "source");
|
||||||
|
@@ -34,6 +34,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*/
|
*/
|
||||||
public class PublishingObjectFactory implements EnvironmentFactory, PublishingQueueFactory
|
public class PublishingObjectFactory implements EnvironmentFactory, PublishingQueueFactory
|
||||||
{
|
{
|
||||||
|
public static final String NAME = "publishingObjectFactory";
|
||||||
|
|
||||||
private EnvironmentHelper environmentHelper;
|
private EnvironmentHelper environmentHelper;
|
||||||
private TransferManifestNodeFactory transferManifestNodeFactory;
|
private TransferManifestNodeFactory transferManifestNodeFactory;
|
||||||
private PublishingEventHelper publishingEventHelper;
|
private PublishingEventHelper publishingEventHelper;
|
||||||
|
@@ -0,0 +1,250 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco 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 Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.publishing.authorization;
|
||||||
|
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_ACCESS_SECRET;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_ACCESS_TOKEN;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_ACCOUNT_ID;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_PROVIDER_ACCOUNT_ID;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_PROVIDER_ID;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.PROP_REFRESH_TOKEN;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_CONNECTION;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.model.Repository;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
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.QName;
|
||||||
|
import org.springframework.social.connect.Connection;
|
||||||
|
import org.springframework.social.connect.ConnectionRepository;
|
||||||
|
import org.springframework.social.oauth1.OAuthToken;
|
||||||
|
import org.springframework.social.twitter.api.TwitterApi;
|
||||||
|
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A node-backed Social Connection Repository, that stores the
|
||||||
|
* credentials and auth tokens in the Data Dictionary.
|
||||||
|
*
|
||||||
|
* @author Nick Burch
|
||||||
|
* @author Nick Smith
|
||||||
|
*/
|
||||||
|
public class NodeBasedConnectionRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Serial version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 3258131523636186548L;
|
||||||
|
|
||||||
|
/** Reference to the auth store space node */
|
||||||
|
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||||
|
protected static final NodeRef SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF =
|
||||||
|
new NodeRef(SPACES_STORE, "social_publishing_authorisation_space");
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
private SearchService searchService;
|
||||||
|
private Repository repositoryHelper;
|
||||||
|
|
||||||
|
// TODO Replace this with doing it properly...
|
||||||
|
private NodeRef authRootNode;
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchService(SearchService searchService)
|
||||||
|
{
|
||||||
|
this.searchService = searchService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryHelper(Repository repositoryHelper)
|
||||||
|
{
|
||||||
|
this.repositoryHelper = repositoryHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findAuthRootNode() {
|
||||||
|
if(authRootNode != null) return;
|
||||||
|
|
||||||
|
// TODO Replace this with doing it properly...
|
||||||
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
if(! nodeService.exists(SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF))
|
||||||
|
{
|
||||||
|
NodeRef dataDictionary = nodeService.getChildByName(
|
||||||
|
repositoryHelper.getCompanyHome(),
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
"dictionary"
|
||||||
|
);
|
||||||
|
authRootNode = nodeService.getChildByName(
|
||||||
|
dataDictionary,
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF.getId()
|
||||||
|
);
|
||||||
|
if(authRootNode == null)
|
||||||
|
{
|
||||||
|
authRootNode = nodeService.createNode(
|
||||||
|
dataDictionary,
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName("{}"+SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF.getId()),
|
||||||
|
ContentModel.TYPE_FOLDER
|
||||||
|
).getChildRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
authRootNode = SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getAdminUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef findProvider(final String providerId, boolean autoCreate)
|
||||||
|
{
|
||||||
|
NodeRef node = nodeService.getChildByName(
|
||||||
|
authRootNode, ContentModel.ASSOC_CONTAINS, providerId
|
||||||
|
);
|
||||||
|
if(autoCreate && node == null)
|
||||||
|
{
|
||||||
|
node = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef doWork() throws Exception
|
||||||
|
{
|
||||||
|
return nodeService.createNode(
|
||||||
|
authRootNode, ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName("{}" + providerId),
|
||||||
|
ContentModel.TYPE_FOLDER
|
||||||
|
).getChildRef();
|
||||||
|
}
|
||||||
|
} , AuthenticationUtil.getAdminUserName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef findAccount(Serializable accountId, String providerId)
|
||||||
|
{
|
||||||
|
findAuthRootNode();
|
||||||
|
NodeRef folder = findProvider(providerId, false);
|
||||||
|
if(folder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeRef account = nodeService.getChildByName(
|
||||||
|
folder, ContentModel.ASSOC_CONTAINS, accountId.toString()
|
||||||
|
);
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection<?> buildConnection(NodeRef node)
|
||||||
|
{
|
||||||
|
// Map<QName,Serializable> props = nodeService.getProperties(node);
|
||||||
|
// return new Connection(
|
||||||
|
// (long)-1,
|
||||||
|
// (String)props.get(PROP_ACCESS_TOKEN),
|
||||||
|
// (String)props.get(PROP_ACCESS_SECRET),
|
||||||
|
// (String)props.get(PROP_REFRESH_TOKEN),
|
||||||
|
// (String)props.get(PROP_PROVIDER_ACCOUNT_ID)
|
||||||
|
// );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnected(Serializable accountId, String providerId)
|
||||||
|
{
|
||||||
|
NodeRef account = findAccount(accountId, providerId);
|
||||||
|
return (account != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Serializable findAccountIdByConnectionAccessToken(String providerId,
|
||||||
|
String accessToken) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Serializable> findAccountIdsForProviderAccountIds(
|
||||||
|
String providerId, List<String> providerAccountIds) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Connection<?>> findConnections(Serializable accountId,
|
||||||
|
String providerId) {
|
||||||
|
NodeRef account = findAccount(accountId, providerId);
|
||||||
|
if(account == null)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Connection<?>> connections = new ArrayList<Connection<?>>();
|
||||||
|
connections.add( buildConnection(account) );
|
||||||
|
return connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeConnection(Serializable accountId, String providerId,
|
||||||
|
Long connectionId)
|
||||||
|
{
|
||||||
|
NodeRef account = findAccount(accountId, providerId);
|
||||||
|
if(account != null)
|
||||||
|
{
|
||||||
|
nodeService.deleteNode(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection saveConnection(Serializable accountId, String providerId,
|
||||||
|
Connection connection)
|
||||||
|
{
|
||||||
|
// Map<QName, Serializable> args = new HashMap<QName, Serializable>();
|
||||||
|
// args.put(ContentModel.PROP_NAME, accountId);
|
||||||
|
// args.put(PROP_ACCOUNT_ID, accountId);
|
||||||
|
// args.put(PROP_PROVIDER_ID, providerId);
|
||||||
|
// args.put(PROP_PROVIDER_ACCOUNT_ID, connection.getProviderAccountId());
|
||||||
|
// args.put(PROP_ACCESS_TOKEN, connection.getAccessToken());
|
||||||
|
// args.put(PROP_ACCESS_SECRET, connection.getSecret());
|
||||||
|
// args.put(PROP_REFRESH_TOKEN, connection.getRefreshToken());
|
||||||
|
//
|
||||||
|
// findAuthRootNode();
|
||||||
|
// NodeRef folder = findProvider(providerId, true);
|
||||||
|
// NodeRef node = nodeService.createNode(
|
||||||
|
// folder, ContentModel.ASSOC_CONTAINS,
|
||||||
|
// QName.createQName("{}" + accountId.toString()),
|
||||||
|
// TYPE_PUBLISHING_CONNECTION,
|
||||||
|
// args
|
||||||
|
// ).getChildRef();
|
||||||
|
//
|
||||||
|
// return buildConnection(node);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco 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 Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.publishing.authorization;
|
||||||
|
|
||||||
|
import static org.alfresco.model.ContentModel.ASSOC_CONTAINS;
|
||||||
|
import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_CONNECTION;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.model.Repository;
|
||||||
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
|
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.util.collections.CollectionUtils;
|
||||||
|
import org.alfresco.util.collections.Function;
|
||||||
|
import org.springframework.social.connect.Connection;
|
||||||
|
import org.springframework.social.connect.ConnectionKey;
|
||||||
|
import org.springframework.social.connect.ConnectionRepository;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
* @since 4.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NodeBasedConnectionRepository2 implements ConnectionRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Serial version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 3258131523636186548L;
|
||||||
|
|
||||||
|
/** Reference to the auth store space node */
|
||||||
|
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||||
|
protected static final NodeRef SOCIAL_PUBLISHING_AUTHORISATION_ROOT_NODE_REF =
|
||||||
|
new NodeRef(SPACES_STORE, "social_publishing_authorisation_space");
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
private FileFolderService fileFolderService;
|
||||||
|
private SearchService searchService;
|
||||||
|
private Repository repositoryHelper;
|
||||||
|
|
||||||
|
// TODO Replace this with doing it properly...
|
||||||
|
private NodeRef authRootNode;
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fileFolderService the fileFolderService to set
|
||||||
|
*/
|
||||||
|
public void setFileFolderService(FileFolderService fileFolderService)
|
||||||
|
{
|
||||||
|
this.fileFolderService = fileFolderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchService(SearchService searchService)
|
||||||
|
{
|
||||||
|
this.searchService = searchService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryHelper(Repository repositoryHelper)
|
||||||
|
{
|
||||||
|
this.repositoryHelper = repositoryHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public MultiValueMap<String, Connection<?>> findConnections()
|
||||||
|
{
|
||||||
|
MultiValueMap<String, Connection<?>> results = new LinkedMultiValueMap<String, Connection<?>>();
|
||||||
|
for (String providerId : getAllProviderIds())
|
||||||
|
{
|
||||||
|
List<Connection<?>> connections = findConnectionsToProvider(providerId);
|
||||||
|
if(connections!=null && connections.isEmpty() == false)
|
||||||
|
{
|
||||||
|
results.put(providerId, connections);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public List<Connection<?>> findConnectionsToProvider(String providerId)
|
||||||
|
{
|
||||||
|
NodeRef providerNode = getProviderNode(providerId);
|
||||||
|
List<ChildAssociationRef> connectionNodes = nodeService.getChildAssocs(providerNode, Collections.singleton(TYPE_PUBLISHING_CONNECTION));
|
||||||
|
return convertConnections(connectionNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MultiValueMap<String, Connection<?>> findConnectionsForUsers(MultiValueMap<String, String> providerUserIds)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Connection<?> findConnection(ConnectionKey connectionKey)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <A> Connection<A> findPrimaryConnectionToApi(Class<A> apiType)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <A> Connection<A> findConnectionToApiForUser(Class<A> apiType, String providerUserId)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <A> List<Connection<A>> findConnectionsToApi(Class<A> apiType)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addConnection(Connection<?> connection)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateConnection(Connection<?> connection)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeConnectionsToProvider(String providerId)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void removeConnection(ConnectionKey connectionKey)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getAllProviderIds()
|
||||||
|
{
|
||||||
|
return CollectionUtils.transform(fileFolderService.listFolders(getAuthentiactionRoot()), new Function<FileInfo, String>()
|
||||||
|
{
|
||||||
|
public String apply(FileInfo value)
|
||||||
|
{
|
||||||
|
return value.getName();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef getProviderNode(String providerId)
|
||||||
|
{
|
||||||
|
return nodeService.getChildByName(getAuthentiactionRoot(), ASSOC_CONTAINS, providerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef getAuthentiactionRoot()
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Connection<?>> convertConnections(List<ChildAssociationRef> connectionNodes)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -107,4 +107,33 @@ public interface ChannelService
|
|||||||
* @return The specified Channel objects or <code>null</code> if the specified channel does not exist.
|
* @return The specified Channel objects or <code>null</code> if the specified channel does not exist.
|
||||||
*/
|
*/
|
||||||
Channel getChannel(String id);
|
Channel getChannel(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all the channels that are capable of publishing the specified NodeRef.
|
||||||
|
* @param nodeToPublish
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Channel> getRelevantPublishingChannels(NodeRef nodeToPublish);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all the channels that are capable of publishing in the specified Share site.
|
||||||
|
* @param siteId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Channel> getPublishingChannels(String siteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link Channel}s cpaable of performing a status update for the given Share Site.
|
||||||
|
* @param siteId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Channel> getStatusUpdateChannels(String siteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link Channel}s cpaable of performing a status update for the Share Site in which the specified <code>nodeToPublish</code> exists.
|
||||||
|
* @param siteId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Channel> getStatusUpdateChannels(NodeRef nodeToPublish);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -50,4 +50,5 @@ public interface ChannelType
|
|||||||
Set<String> getSupportedMimetypes();
|
Set<String> getSupportedMimetypes();
|
||||||
Set<QName> getSupportedContentTypes();
|
Set<QName> getSupportedContentTypes();
|
||||||
String getNodeUrl(NodeRef node);
|
String getNodeUrl(NodeRef node);
|
||||||
|
int getMaximumStatusLength();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user