mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Publishing: added authorisation framework for channel types. Migrated YouTube channel type onto it, and added Twitter and SlideShare channel types. Facebook is also added, but there is an issue with the way it authorises apps, so it isn't wired in yet.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28910 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
<import resource="classpath*:alfresco/transfer-service-context.xml"/>
|
||||
<import resource="classpath*:alfresco/web-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/youtube-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/social-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/twitter-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/slideshare-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/domain/*-context.xml" />
|
||||
</beans>
|
||||
|
53
config/alfresco/model/facebookPublishingModel.xml
Normal file
53
config/alfresco/model/facebookPublishingModel.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<model name="facebook:publishingmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
|
||||
<description>Alfresco Facebook Publishing Content Model</description>
|
||||
<author>Alfresco</author>
|
||||
<published>2011-06-15</published>
|
||||
<version>1.0</version>
|
||||
|
||||
<imports>
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
|
||||
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
|
||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
|
||||
<import uri="http://www.alfresco.org/model/publishing/1.0" prefix="pub" />
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://www.alfresco.org/model/publishing/facebook/1.0" prefix="facebook" />
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
<type name="facebook:DeliveryChannel">
|
||||
<title>Facebook Delivery Channel</title>
|
||||
<description>Node type used to represent Facebook delivery channels</description>
|
||||
<parent>pub:DeliveryChannel</parent>
|
||||
<mandatory-aspects>
|
||||
<aspect>facebook:DeliveryChannelAspect</aspect>
|
||||
</mandatory-aspects>
|
||||
</type>
|
||||
|
||||
</types>
|
||||
|
||||
<aspects>
|
||||
<aspect name="facebook:DeliveryChannelAspect">
|
||||
<title>Facebook Delivery Channel Aspect</title>
|
||||
<description>Applied to a node that represents a Facebook delivery channel</description>
|
||||
<parent>pub:UserPasswordDeliveryChannelAspect</parent>
|
||||
</aspect>
|
||||
|
||||
<aspect name="facebook:AssetAspect">
|
||||
<title>Facebook Asset</title>
|
||||
<description>Applied to a node that has been published to Facebook</description>
|
||||
<properties>
|
||||
<property name="facebook:assetId">
|
||||
<title>Facebook Asset Id</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
<property name="facebook:assetUrl">
|
||||
<title>Facebook Asset URL</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
</aspects>
|
||||
</model>
|
@@ -27,6 +27,11 @@
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
<property name="pub:authorisationComplete">
|
||||
<title>Has the channel authorisation process been completed?</title>
|
||||
<type>d:boolean</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
</properties>
|
||||
<associations>
|
||||
<child-association name="pub:deliveryServers">
|
||||
@@ -288,5 +293,39 @@
|
||||
</associations>
|
||||
</aspect>
|
||||
|
||||
<aspect name="pub:OAuth1DeliveryChannelAspect">
|
||||
<title>OAuth1 Authenticated Delivery Channel</title>
|
||||
<description>Applied to delivery channels that use OAuth1</description>
|
||||
<properties>
|
||||
<property name="pub:oauth1TokenValue">
|
||||
<title>The value of the OAuth1 token</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
<property name="pub:oauth1TokenSecret">
|
||||
<title>The secret of the OAuth1 token</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
<aspect name="pub:UserPasswordDeliveryChannelAspect">
|
||||
<title>Username and Password Authenticated Delivery Channel</title>
|
||||
<description>Applied to delivery channels that use OAuth1</description>
|
||||
<properties>
|
||||
<property name="pub:channelUsername">
|
||||
<title>The authenticated channel username</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
<property name="pub:channelPassword">
|
||||
<title>The authenticated channel password</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
</model>
|
||||
|
53
config/alfresco/model/slidesharePublishingModel.xml
Normal file
53
config/alfresco/model/slidesharePublishingModel.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<model name="slideshare:publishingmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
|
||||
<description>Alfresco YouTube Publishing Content Model</description>
|
||||
<author>Alfresco</author>
|
||||
<published>2011-06-15</published>
|
||||
<version>1.0</version>
|
||||
|
||||
<imports>
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
|
||||
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
|
||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
|
||||
<import uri="http://www.alfresco.org/model/publishing/1.0" prefix="pub" />
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://www.alfresco.org/model/publishing/slideshare/1.0" prefix="slideshare" />
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
<type name="slideshare:DeliveryChannel">
|
||||
<title>SlideShare Delivery Channel</title>
|
||||
<description>Node type used to represent SlideShare delivery channels</description>
|
||||
<parent>pub:DeliveryChannel</parent>
|
||||
<mandatory-aspects>
|
||||
<aspect>slideshare:DeliveryChannelAspect</aspect>
|
||||
</mandatory-aspects>
|
||||
</type>
|
||||
|
||||
</types>
|
||||
|
||||
<aspects>
|
||||
<aspect name="slideshare:DeliveryChannelAspect">
|
||||
<title>SlideShare Delivery Channel Aspect</title>
|
||||
<description>Applied to a node that represents a SlideShare delivery channel</description>
|
||||
<parent>pub:UserPasswordDeliveryChannelAspect</parent>
|
||||
</aspect>
|
||||
|
||||
<aspect name="slideshare:AssetAspect">
|
||||
<title>SlideShare Asset</title>
|
||||
<description>Applied to a node that has been published to SlideShare</description>
|
||||
<properties>
|
||||
<property name="slideshare:assetId">
|
||||
<title>SlideShare Asset Id</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
<property name="slideshare:assetUrl">
|
||||
<title>SlideShare Asset URL</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
</aspects>
|
||||
</model>
|
47
config/alfresco/model/twitterPublishingModel.xml
Normal file
47
config/alfresco/model/twitterPublishingModel.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<model name="twitter:publishingmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
|
||||
<description>Alfresco Twitter Publishing Content Model</description>
|
||||
<author>Alfresco</author>
|
||||
<published>2011-06-15</published>
|
||||
<version>1.0</version>
|
||||
|
||||
<imports>
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
|
||||
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
|
||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
|
||||
<import uri="http://www.alfresco.org/model/publishing/1.0" prefix="pub" />
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://www.alfresco.org/model/publishing/twitter/1.0" prefix="twitter" />
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
<type name="twitter:DeliveryChannel">
|
||||
<title>Twitter Delivery Channel</title>
|
||||
<description>Node type used to represent Twitter delivery channels</description>
|
||||
<parent>pub:DeliveryChannel</parent>
|
||||
<mandatory-aspects>
|
||||
<aspect>pub:OAuth1DeliveryChannelAspect</aspect>
|
||||
</mandatory-aspects>
|
||||
</type>
|
||||
|
||||
</types>
|
||||
|
||||
<aspects>
|
||||
<aspect name="twitter:AssetAspect">
|
||||
<title>Twitter Asset</title>
|
||||
<description>Applied to a node that has been published to Twitter</description>
|
||||
<properties>
|
||||
<property name="twitter:assetId">
|
||||
<title>Twitter Status Id</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
<property name="twitter:assetUrl">
|
||||
<title>Twitter Status URL</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
</aspects>
|
||||
</model>
|
@@ -32,18 +32,7 @@
|
||||
<aspect name="youtube:DeliveryChannelAspect">
|
||||
<title>YouTube Delivery Channel</title>
|
||||
<description>Applied to a node that represents a YouTube delivery channel</description>
|
||||
<properties>
|
||||
<property name="youtube:username">
|
||||
<title>YouTube User Name</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
<property name="youtube:password">
|
||||
<title>YouTube Password</title>
|
||||
<type>d:text</type>
|
||||
<multiple>false</multiple>
|
||||
</property>
|
||||
</properties>
|
||||
<parent>pub:UserPasswordDeliveryChannelAspect</parent>
|
||||
</aspect>
|
||||
|
||||
<aspect name="youtube:AssetAspect">
|
||||
|
30
config/alfresco/slideshare-publishing-context.xml
Normal file
30
config/alfresco/slideshare-publishing-context.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
<bean parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
|
||||
<property name="models">
|
||||
<list>
|
||||
<value>alfresco/model/slidesharePublishingModel.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="slidesharePublishingHelper" class="org.alfresco.repo.publishing.slideshare.SlideSharePublishingHelper">
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
</bean>
|
||||
|
||||
<bean id="publish_slideshare" parent="action-executer" class="org.alfresco.repo.publishing.slideshare.SlideSharePublishAction">
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="taggingService" ref="TaggingService" />
|
||||
<property name="contentService" ref="ContentService" />
|
||||
<property name="slideShareHelper" ref="slidesharePublishingHelper" />
|
||||
</bean>
|
||||
|
||||
<bean id="slideshareDeliveryChannelType" class="org.alfresco.repo.publishing.slideshare.SlideShareChannelType" parent="baseChannelType" >
|
||||
<property name="actionService" ref="ActionService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
28
config/alfresco/twitter-publishing-context.xml
Normal file
28
config/alfresco/twitter-publishing-context.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
<bean parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
|
||||
<property name="models">
|
||||
<list>
|
||||
<value>alfresco/model/twitterPublishingModel.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="twitterDeliveryChannelType" class="org.alfresco.repo.publishing.twitter.TwitterChannelType" parent="baseChannelType" >
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="publishingHelper" ref="twitterPublishingHelper" />
|
||||
</bean>
|
||||
|
||||
<bean id="twitterPublishingHelper" class="org.alfresco.repo.publishing.twitter.TwitterPublishingHelper">
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="connectionFactory">
|
||||
<bean class="org.springframework.social.twitter.connect.TwitterConnectionFactory">
|
||||
<constructor-arg value="H6xYrEbF7sgGz9eL5s6uA" />
|
||||
<constructor-arg value="JXydqZec0g4Va3mEl1sY2odlYNnyokS5TWy3C1sNVIg" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -26,7 +26,10 @@
|
||||
<property name="youTubeHelper" ref="youtubePublishingHelper" />
|
||||
</bean>
|
||||
|
||||
<bean id="youtubeDeliveryChannelType" class="org.alfresco.repo.publishing.youtube.YouTubeChannelType" parent="baseChannelType" />
|
||||
<bean id="youtubeDeliveryChannelType" class="org.alfresco.repo.publishing.youtube.YouTubeChannelType" parent="baseChannelType" >
|
||||
<property name="actionService" ref="ActionService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
|
@@ -22,15 +22,20 @@ package org.alfresco.repo.publishing;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.transfer.CompositeNodeFilter;
|
||||
import org.alfresco.repo.transfer.CompositeNodeFinder;
|
||||
import org.alfresco.repo.transfer.PrimaryParentNodeFinder;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -50,7 +55,8 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serviceRegistry the serviceRegistry to set
|
||||
* @param serviceRegistry
|
||||
* the serviceRegistry to set
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
@@ -78,7 +84,9 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a collection of {@link NodeFilter}s to be included in the {@link CompositeNodeFilter} returned by the getNodeFilter() method.
|
||||
* @return a collection of {@link NodeFilter}s to be included in the
|
||||
* {@link CompositeNodeFilter} returned by the getNodeFilter()
|
||||
* method.
|
||||
*/
|
||||
protected Collection<NodeFilter> getAllNodeFIlters()
|
||||
{
|
||||
@@ -86,11 +94,13 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a collection of {@link NodeFinder}s to be included in the {@link CompositeNodeFinder} returned by the getNodeFinder() method.
|
||||
* @return a collection of {@link NodeFinder}s to be included in the
|
||||
* {@link CompositeNodeFinder} returned by the getNodeFinder()
|
||||
* method.
|
||||
*/
|
||||
protected Collection<NodeFinder> getAllNodeFInders()
|
||||
{
|
||||
//TODO Add dependency node finder.
|
||||
// TODO Add dependency node finder.
|
||||
NodeFinder parentFinder = new PrimaryParentNodeFinder();
|
||||
return Arrays.asList(parentFinder);
|
||||
}
|
||||
@@ -103,6 +113,7 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
||||
{
|
||||
return nodeFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -120,4 +131,41 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
//Returning a null here to indicate that we should use our own credential-gathering mechanism.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders,
|
||||
Map<String, String[]> callbackParams)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
ParameterCheck.mandatory("channel", channel);
|
||||
ParameterCheck.mandatory("callbackHeaders", callbackHeaders);
|
||||
ParameterCheck.mandatory("callbackParams", callbackParams);
|
||||
if (!getId().equals(channel.getChannelType().getId()))
|
||||
{
|
||||
throw new IllegalArgumentException("Supplied channel is of the incorrect type. Expected " + getId()
|
||||
+ "; Received " + channel.getChannelType().getId());
|
||||
}
|
||||
|
||||
NodeRef channelNodeRef = channel.getNodeRef();
|
||||
NodeService nodeService = serviceRegistry.getNodeService();
|
||||
|
||||
String[] username = callbackParams.get("username");
|
||||
String[] password = callbackParams.get("password");
|
||||
if (username != null && password != null)
|
||||
{
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_CHANNEL_USERNAME, username[0]);
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_CHANNEL_PASSWORD, password[0]);
|
||||
//TODO: BJR: 20110707: Should test the connection here
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -111,7 +111,7 @@ public class ChannelImpl implements Channel
|
||||
@Override
|
||||
public void updateStatus(String status)
|
||||
{
|
||||
channelType.updateStatus(status, getProperties());
|
||||
channelType.updateStatus(this, status, getProperties());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -161,6 +161,7 @@ public class ChannelServiceImpl implements ChannelService
|
||||
}
|
||||
actualProps.put(ContentModel.PROP_NAME, name);
|
||||
actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId());
|
||||
actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE);
|
||||
NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps);
|
||||
Channel channel = channelHelper.buildChannelObject(channelNode, this);
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class MockChannelType extends AbstractChannelType
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
@@ -149,4 +150,10 @@ public class MockChannelType extends AbstractChannelType
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import static org.alfresco.model.ContentModel.PROP_LONGITUDE;
|
||||
import static org.alfresco.model.ContentModel.PROP_NAME;
|
||||
import static org.alfresco.model.ContentModel.TYPE_CONTENT;
|
||||
import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyMap;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -55,6 +56,7 @@ import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
|
||||
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
||||
import org.alfresco.service.cmr.publishing.PublishingService;
|
||||
import org.alfresco.service.cmr.publishing.StatusUpdate;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -338,7 +340,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
|
||||
publishNode(source, status);
|
||||
|
||||
String expMessage = message + url;
|
||||
verify(channelType, times(1)).updateStatus(eq(expMessage), anyMap());
|
||||
verify(channelType, times(1)).updateStatus(any(Channel.class), eq(expMessage), anyMap());
|
||||
}
|
||||
|
||||
private NodeRef publishNode(NodeRef source)
|
||||
|
@@ -44,6 +44,7 @@ public interface PublishingModel
|
||||
|
||||
public static final QName ASPECT_CHANNEL_INFO= QName.createQName(NAMESPACE, "channelInfo");
|
||||
public static final QName ASPECT_PUBLISHED = QName.createQName(NAMESPACE, "published");
|
||||
public static final QName ASPECT_OAUTH1_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "OAuth1DeliveryChannelAspect");
|
||||
|
||||
public static final QName PROP_CHANNEL = QName.createQName(NAMESPACE, "channel");
|
||||
public static final QName PROP_CHANNEL_TYPE = QName.createQName(NAMESPACE, "channelType");
|
||||
@@ -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_NODE_REF = QName.createQName(NAMESPACE, "statusUpdateNodeRef");
|
||||
public static final QName PROP_STATUS_UPDATE_MESSAGE = QName.createQName(NAMESPACE, "statusUpdateMessage");
|
||||
public static final QName PROP_AUTHORISATION_COMPLETE = QName.createQName(NAMESPACE, "authorisationComplete");
|
||||
public static final QName PROP_OAUTH1_TOKEN_VALUE = QName.createQName(NAMESPACE, "oauth1TokenValue");
|
||||
public static final QName PROP_OAUTH1_TOKEN_SECRET = QName.createQName(NAMESPACE, "oauth1TokenSecret");
|
||||
public static final QName PROP_CHANNEL_USERNAME = QName.createQName(NAMESPACE, "channelUsername");
|
||||
public static final QName PROP_CHANNEL_PASSWORD = QName.createQName(NAMESPACE, "channelPassword");
|
||||
|
||||
|
||||
// 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");
|
||||
|
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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.facebook;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.social.oauth1.AuthorizedRequestToken;
|
||||
import org.springframework.social.oauth1.OAuth1Operations;
|
||||
import org.springframework.social.oauth1.OAuth1Parameters;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.social.oauth2.GrantType;
|
||||
import org.springframework.social.oauth2.OAuth2Operations;
|
||||
import org.springframework.social.oauth2.OAuth2Parameters;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
|
||||
public class FacebookChannelType extends AbstractChannelType
|
||||
{
|
||||
public final static String ID = "facebook";
|
||||
private NodeService nodeService;
|
||||
private FacebookPublishingHelper publishingHelper;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setPublishingHelper(FacebookPublishingHelper facebookPublishingHelper)
|
||||
{
|
||||
this.publishingHelper = facebookPublishingHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublishStatusUpdates()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnpublish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getChannelNodeType()
|
||||
{
|
||||
return FacebookPublishingModel.TYPE_DELIVERY_CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getSupportedContentTypes()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedMimetypes()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
Connection<Facebook> connection = publishingHelper.getFacebookConnectionForChannel(channel.getNodeRef());
|
||||
connection.updateStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeUrl(NodeRef node)
|
||||
{
|
||||
String url = null;
|
||||
if (node != null && nodeService.exists(node) && nodeService.hasAspect(node, FacebookPublishingModel.ASPECT_ASSET))
|
||||
{
|
||||
url = (String)nodeService.getProperty(node, FacebookPublishingModel.PROP_ASSET_URL);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
ParameterCheck.mandatory("channel", channel);
|
||||
ParameterCheck.mandatory("callbackUrl", callbackUrl);
|
||||
if (!ID.equals(channel.getChannelType().getId()))
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid channel type: " + channel.getChannelType().getId());
|
||||
}
|
||||
|
||||
OAuth2Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations();
|
||||
return oauthOperations.buildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, new OAuth2Parameters(callbackUrl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders,
|
||||
Map<String, String[]> callbackParams)
|
||||
{
|
||||
boolean authorised = false;
|
||||
//FIXME: BJR: 20110708: Write this.
|
||||
// String[] verifier = callbackParams.get("oauth_verifier");
|
||||
// if (verifier != null)
|
||||
// {
|
||||
// OAuth2Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations();
|
||||
// NodeRef channelNodeRef = channel.getNodeRef();
|
||||
//
|
||||
// Map<QName, Serializable> props = nodeService.getProperties(channelNodeRef);
|
||||
// String tokenValue = (String) props.get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
||||
// String tokenSecret = (String) props.get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
||||
// OAuthToken token = new OAuthToken(tokenValue, tokenSecret);
|
||||
// OAuthToken accessToken = oauthOperations.exchangeForAccessToken(new AuthorizedRequestToken(token, verifier[0]), null);
|
||||
// nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE, accessToken.getValue());
|
||||
// nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET, accessToken.getSecret());
|
||||
//
|
||||
// authorised = true;
|
||||
// }
|
||||
return authorised;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.facebook;
|
||||
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.social.facebook.connect.FacebookConnectionFactory;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.social.oauth2.AccessGrant;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
|
||||
|
||||
public class FacebookPublishingHelper
|
||||
{
|
||||
private NodeService nodeService;
|
||||
private FacebookConnectionFactory connectionFactory;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setConnectionFactory(FacebookConnectionFactory connectionFactory)
|
||||
{
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
public FacebookConnectionFactory getConnectionFactory()
|
||||
{
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
public Connection<Facebook> getFacebookConnectionForChannel(NodeRef channelNode)
|
||||
{
|
||||
Connection<Facebook> connection = null;
|
||||
if (nodeService.exists(channelNode)
|
||||
&& nodeService.hasAspect(channelNode, FacebookPublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||
{
|
||||
String tokenValue = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
||||
String tokenSecret = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
||||
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
||||
|
||||
if (danceComplete)
|
||||
{
|
||||
AccessGrant token = new AccessGrant(" ");
|
||||
connection = connectionFactory.createConnection(token);
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.facebook;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* @author Brian
|
||||
*
|
||||
*/
|
||||
public interface FacebookPublishingModel
|
||||
{
|
||||
public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/facebook/1.0";
|
||||
public static final String PREFIX = "facebook";
|
||||
|
||||
public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel");
|
||||
|
||||
public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect");
|
||||
|
||||
public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect");
|
||||
public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId");
|
||||
public static final QName PROP_ASSET_URL = QName.createQName(NAMESPACE, "assetUrl");
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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.slideshare;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
public class SlideShareChannelType extends AbstractChannelType
|
||||
{
|
||||
public final static String ID = "slideshare";
|
||||
private final static Set<String> DEFAULT_MIME_TYPES = new TreeSet<String>();
|
||||
|
||||
private NodeService nodeService;
|
||||
private ActionService actionService;
|
||||
private Set<String> permittedMimeTypes = Collections.unmodifiableSet(DEFAULT_MIME_TYPES);
|
||||
|
||||
static
|
||||
{
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_PPT);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_PDF);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_IWORK_KEYNOTE);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_IWORK_PAGES);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_OPENDOCUMENT_TEXT);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_TEXT_CSV);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_EXCEL);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING);
|
||||
DEFAULT_MIME_TYPES.add(MimetypeMap.MIMETYPE_OPENDOCUMENT_SPREADSHEET);
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setActionService(ActionService actionService)
|
||||
{
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
public void setPermittedMimeTypes(Set<String> permittedMimeTypes)
|
||||
{
|
||||
if (permittedMimeTypes == null)
|
||||
{
|
||||
permittedMimeTypes = Collections.emptySet();
|
||||
}
|
||||
this.permittedMimeTypes = Collections.unmodifiableSet(permittedMimeTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublish()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublishStatusUpdates()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnpublish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getChannelNodeType()
|
||||
{
|
||||
return SlideSharePublishingModel.TYPE_DELIVERY_CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getSupportedContentTypes()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedMimetypes()
|
||||
{
|
||||
return permittedMimeTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
Action publishAction = actionService.createAction(SlideSharePublishAction.NAME);
|
||||
actionService.executeAction(publishAction, nodeToPublish);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeUrl(NodeRef node)
|
||||
{
|
||||
String url = null;
|
||||
if (node != null && nodeService.exists(node) && nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET))
|
||||
{
|
||||
url = (String)nodeService.getProperty(node, SlideSharePublishingModel.PROP_PLAYER_URL);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.slideshare;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.benfante.jslideshare.SlideShareAPI;
|
||||
|
||||
public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
||||
{
|
||||
private final static Log log = LogFactory.getLog(SlideSharePublishAction.class);
|
||||
|
||||
public static final String NAME = "publish_slideshare";
|
||||
|
||||
private NodeService nodeService;
|
||||
private ContentService contentService;
|
||||
private TaggingService taggingService;
|
||||
private SlideSharePublishingHelper slideShareHelper;
|
||||
|
||||
public void setSlideShareHelper(SlideSharePublishingHelper slideShareHelper)
|
||||
{
|
||||
this.slideShareHelper = slideShareHelper;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
public void setTaggingService(TaggingService taggingService)
|
||||
{
|
||||
this.taggingService = taggingService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef nodeRef)
|
||||
{
|
||||
SlideShareAPI api = slideShareHelper.getSlideShareApi();
|
||||
Pair<String,String> usernamePassword = slideShareHelper.getSlideShareCredentialsForNode(nodeRef);
|
||||
if (api == null || usernamePassword == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("publish.failed.unable_to_connect_to_service_provider");
|
||||
}
|
||||
|
||||
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||
if (reader.exists())
|
||||
{
|
||||
File contentFile;
|
||||
boolean deleteContentFileOnCompletion = false;
|
||||
if (FileContentReader.class.isAssignableFrom(reader.getClass()))
|
||||
{
|
||||
//Grab the content straight from the content store if we can...
|
||||
contentFile = ((FileContentReader)reader).getFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
//...otherwise copy it to a temp file and use the copy...
|
||||
File tempDir = TempFileProvider.getLongLifeTempDir("slideshare");
|
||||
contentFile = TempFileProvider.createTempFile("slideshare", "", tempDir);
|
||||
reader.getContent(contentFile);
|
||||
deleteContentFileOnCompletion = true;
|
||||
}
|
||||
|
||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
|
||||
if (title == null || title.length() == 0)
|
||||
{
|
||||
title = name;
|
||||
}
|
||||
String description = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
if (description == null || description.length() == 0)
|
||||
{
|
||||
description = title;
|
||||
}
|
||||
|
||||
List<String> tagList = taggingService.getTags(nodeRef);
|
||||
StringBuilder tags = new StringBuilder();
|
||||
for (String tag : tagList)
|
||||
{
|
||||
tags.append(tag);
|
||||
tags.append(' ');
|
||||
}
|
||||
|
||||
String assetId = api.uploadSlideshow(usernamePassword.getFirst(), usernamePassword.getSecond(), title,
|
||||
contentFile, description, tags.toString(), false, false, false, false, false);
|
||||
nodeService.setProperty(nodeRef, SlideSharePublishingModel.PROP_ASSET_ID, assetId);
|
||||
|
||||
if (deleteContentFileOnCompletion)
|
||||
{
|
||||
contentFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.slideshare;
|
||||
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
import com.benfante.jslideshare.SlideShareAPI;
|
||||
import com.benfante.jslideshare.SlideShareAPIFactory;
|
||||
|
||||
public class SlideSharePublishingHelper
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
|
||||
public SlideShareAPI getSlideShareApi()
|
||||
{
|
||||
return SlideShareAPIFactory.getSlideShareAPI("hhjh", "oijkl");
|
||||
}
|
||||
|
||||
|
||||
public Pair<String, String> getSlideShareCredentialsForNode(NodeRef publishNode)
|
||||
{
|
||||
Pair<String, String> result = null;
|
||||
if (nodeService.exists(publishNode))
|
||||
{
|
||||
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
||||
if (nodeService.hasAspect(parent, SlideSharePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||
{
|
||||
String username = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME);
|
||||
String password = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD);
|
||||
if (username != null && password != null)
|
||||
{
|
||||
result = new Pair<String, String>(username, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.slideshare;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* @author Brian
|
||||
*
|
||||
*/
|
||||
public interface SlideSharePublishingModel
|
||||
{
|
||||
public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/youtube/1.0";
|
||||
public static final String PREFIX = "youtube";
|
||||
|
||||
public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel");
|
||||
|
||||
public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect");
|
||||
|
||||
public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect");
|
||||
public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId");
|
||||
public static final QName PROP_PLAYER_URL = QName.createQName(NAMESPACE, "assetUrl");
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* 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.springsocial;
|
||||
|
||||
import org.springframework.social.connect.ConnectionData;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
public class ConnectionSerializer
|
||||
{
|
||||
|
||||
public ConnectionData deSerialize()
|
||||
{
|
||||
Long expireTime = null;
|
||||
String refreshToken = null;
|
||||
String secret = null;
|
||||
String accessToken = null;
|
||||
String providerId = null;
|
||||
String imageUrl = null;
|
||||
String profileUrl = null;
|
||||
String providerUserId = null;
|
||||
String displayName = null;
|
||||
return new ConnectionData(providerId, providerUserId, displayName, profileUrl, imageUrl, accessToken, secret, refreshToken, expireTime);
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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.springsocial;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.social.oauth1.OAuth1ServiceProvider;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
public abstract class OAuth1ChannelType<T> extends AbstractChannelType
|
||||
{
|
||||
OAuth1ServiceProvider<T> serviceProvider;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||
@@ -112,9 +113,16 @@ public class TestChannelType1 extends AbstractChannelType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
//Deliberately blank
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||
@@ -112,9 +113,16 @@ public class TestChannelType2 extends AbstractChannelType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
//Deliberately blank
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||
@@ -112,9 +113,16 @@ public class TestChannelType3 extends AbstractChannelType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
//Deliberately blank
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.twitter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.oauth1.AuthorizedRequestToken;
|
||||
import org.springframework.social.oauth1.OAuth1Operations;
|
||||
import org.springframework.social.oauth1.OAuth1Parameters;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
|
||||
public class TwitterChannelType extends AbstractChannelType
|
||||
{
|
||||
public final static String ID = "twitter";
|
||||
private NodeService nodeService;
|
||||
private TwitterPublishingHelper publishingHelper;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setPublishingHelper(TwitterPublishingHelper twitterPublishingHelper)
|
||||
{
|
||||
this.publishingHelper = twitterPublishingHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPublishStatusUpdates()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnpublish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getChannelNodeType()
|
||||
{
|
||||
return TwitterPublishingModel.TYPE_DELIVERY_CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getSupportedContentTypes()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedMimetypes()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
Connection<Twitter> connection = publishingHelper.getTwitterConnectionForChannel(channel.getNodeRef());
|
||||
connection.getApi().timelineOperations().updateStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeUrl(NodeRef node)
|
||||
{
|
||||
String url = null;
|
||||
if (node != null && nodeService.exists(node) && nodeService.hasAspect(node, TwitterPublishingModel.ASPECT_ASSET))
|
||||
{
|
||||
url = (String)nodeService.getProperty(node, TwitterPublishingModel.PROP_ASSET_URL);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorisationUrl(Channel channel, String callbackUrl)
|
||||
{
|
||||
ParameterCheck.mandatory("channel", channel);
|
||||
ParameterCheck.mandatory("callbackUrl", callbackUrl);
|
||||
if (!ID.equals(channel.getChannelType().getId()))
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid channel type: " + channel.getChannelType().getId());
|
||||
}
|
||||
|
||||
OAuth1Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations();
|
||||
OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null);
|
||||
|
||||
NodeRef channelNodeRef = channel.getNodeRef();
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET, requestToken.getSecret());
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE, requestToken.getValue());
|
||||
|
||||
return oauthOperations.buildAuthorizeUrl(requestToken.getValue(), OAuth1Parameters.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders,
|
||||
Map<String, String[]> callbackParams)
|
||||
{
|
||||
boolean authorised = false;
|
||||
String[] verifier = callbackParams.get("oauth_verifier");
|
||||
if (verifier != null)
|
||||
{
|
||||
OAuth1Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations();
|
||||
NodeRef channelNodeRef = channel.getNodeRef();
|
||||
|
||||
Map<QName, Serializable> props = nodeService.getProperties(channelNodeRef);
|
||||
String tokenValue = (String) props.get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
||||
String tokenSecret = (String) props.get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
||||
OAuthToken token = new OAuthToken(tokenValue, tokenSecret);
|
||||
OAuthToken accessToken = oauthOperations.exchangeForAccessToken(new AuthorizedRequestToken(token, verifier[0]), null);
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE, accessToken.getValue());
|
||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET, accessToken.getSecret());
|
||||
|
||||
authorised = true;
|
||||
}
|
||||
return authorised;
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.twitter;
|
||||
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
|
||||
|
||||
public class TwitterPublishingHelper
|
||||
{
|
||||
private NodeService nodeService;
|
||||
private TwitterConnectionFactory connectionFactory;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setConnectionFactory(TwitterConnectionFactory connectionFactory)
|
||||
{
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
public TwitterConnectionFactory getConnectionFactory()
|
||||
{
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
public Connection<Twitter> getTwitterConnectionForChannel(NodeRef channelNode)
|
||||
{
|
||||
Connection<Twitter> connection = null;
|
||||
if (nodeService.exists(channelNode)
|
||||
&& nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL))
|
||||
{
|
||||
String tokenValue = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
||||
String tokenSecret = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
||||
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
||||
|
||||
if (danceComplete)
|
||||
{
|
||||
OAuthToken token = new OAuthToken(tokenValue, tokenSecret);
|
||||
connection = connectionFactory.createConnection(token);
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.twitter;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* @author Brian
|
||||
*
|
||||
*/
|
||||
public interface TwitterPublishingModel
|
||||
{
|
||||
public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/twitter/1.0";
|
||||
public static final String PREFIX = "twitter";
|
||||
|
||||
public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel");
|
||||
|
||||
public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect");
|
||||
public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId");
|
||||
public static final QName PROP_ASSET_URL = QName.createQName(NAMESPACE, "assetUrl");
|
||||
}
|
@@ -26,6 +26,7 @@ import java.util.Set;
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -103,7 +104,7 @@ public class YouTubeChannelType extends AbstractChannelType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(String status, Map<QName, Serializable> properties)
|
||||
public void updateStatus(Channel channel, String status, Map<QName, Serializable> properties)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.publishing.youtube;
|
||||
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -44,8 +45,8 @@ public class YouTubePublishingHelper
|
||||
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
||||
if (nodeService.hasAspect(parent, YouTubePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||
{
|
||||
String youtubeUsername = (String) nodeService.getProperty(parent, YouTubePublishingModel.PROP_USERNAME);
|
||||
String youtubePassword = (String) nodeService.getProperty(parent, YouTubePublishingModel.PROP_PASSWORD);
|
||||
String youtubeUsername = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME);
|
||||
String youtubePassword = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD);
|
||||
service = new YouTubeService("Alfresco Kickoff Demo",
|
||||
"AI39si71pRNHkfExcTpqcZewDtI4GHWuPAXyRPL2Xq-RQUBWlE1bqn77ANXEL5lZUWFDz6ZlS_XWCw8hlr2BJY1TnC-EMs4e4g");
|
||||
try
|
||||
|
@@ -33,8 +33,6 @@ public interface YouTubePublishingModel
|
||||
public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel");
|
||||
|
||||
public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect");
|
||||
public static final QName PROP_USERNAME = QName.createQName(NAMESPACE, "username");
|
||||
public static final QName PROP_PASSWORD = QName.createQName(NAMESPACE, "password");
|
||||
|
||||
public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect");
|
||||
public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId");
|
||||
|
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.publishing.EnvironmentImpl;
|
||||
import org.alfresco.repo.publishing.PublishingModel;
|
||||
import org.alfresco.repo.publishing.PublishingQueueImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
@@ -104,8 +105,8 @@ public class YouTubeTest extends BaseSpringTest
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
props.put(YouTubePublishingModel.PROP_USERNAME, "YOUR_USER_NAME");
|
||||
props.put(YouTubePublishingModel.PROP_PASSWORD, "YOUR_PASSWORD");
|
||||
props.put(PublishingModel.PROP_CHANNEL_USERNAME, "demochilledpenguin");
|
||||
props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "D3moChilledPenguin");
|
||||
Channel channel = channelService.createChannel(siteId, YouTubeChannelType.ID, "YouTubeChannel", props);
|
||||
|
||||
NodeRef channelNode = channel.getNodeRef();
|
||||
|
@@ -40,7 +40,7 @@ public interface ChannelType
|
||||
NodeFilter getNodeFilter();
|
||||
void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties);
|
||||
void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties);
|
||||
void updateStatus(String status, Map<QName, Serializable> properties);
|
||||
void updateStatus(Channel channel, String status, Map<QName, Serializable> properties);
|
||||
|
||||
boolean canPublish();
|
||||
boolean canUnpublish();
|
||||
@@ -50,4 +50,8 @@ public interface ChannelType
|
||||
Set<QName> getSupportedContentTypes();
|
||||
String getNodeUrl(NodeRef node);
|
||||
int getMaximumStatusLength();
|
||||
|
||||
String getAuthorisationUrl(Channel channel, String callbackUrl);
|
||||
public boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders,
|
||||
Map<String, String[]> callbackParams);
|
||||
}
|
||||
|
Reference in New Issue
Block a user