mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix ALF-10402: PUB: Access tokens are not being stored in encrypted properties
- NOTE: this fix means that any existing publishing channels in the repo will cease to work and will cause the publishing generally to have problems. If you have publishing channels in your repo then you must remove them following this fix. This can be done by either cleaning your repo out completely or deleting the node underneath "Data Dictionary/Publishing Root" (it has a UUID as its name). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30646 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,11 +49,13 @@
|
|||||||
<property name="dictionaryService" ref="DictionaryService" />
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="channelHelper" ref="channelHelper" />
|
<property name="channelHelper" ref="channelHelper" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Channel Type Implementations -->
|
<!-- Channel Type Implementations -->
|
||||||
<bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true" >
|
<bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true" >
|
||||||
<property name="channelService" ref="channelService" />
|
<property name="channelService" ref="channelService" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">
|
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
<bean id="facebookPublishingHelper" class="org.alfresco.repo.publishing.facebook.FacebookPublishingHelper">
|
<bean id="facebookPublishingHelper" class="org.alfresco.repo.publishing.facebook.FacebookPublishingHelper">
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="connectionFactory" ref="facebookConnectionFactory" />
|
<property name="connectionFactory" ref="facebookConnectionFactory" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="facebookConnectionFactory" class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
|
<bean id="facebookConnectionFactory" class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
<bean id="flickrPublishingHelper" class="org.alfresco.repo.publishing.flickr.FlickrPublishingHelper">
|
<bean id="flickrPublishingHelper" class="org.alfresco.repo.publishing.flickr.FlickrPublishingHelper">
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="connectionFactory" ref="flickrConnectionFactory" />
|
<property name="connectionFactory" ref="flickrConnectionFactory" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="flickrConnectionFactory" class="org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrConnectionFactory">
|
<bean id="flickrConnectionFactory" class="org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrConnectionFactory">
|
||||||
|
@@ -299,12 +299,12 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="pub:oauth1TokenValue">
|
<property name="pub:oauth1TokenValue">
|
||||||
<title>The value of the OAuth1 token</title>
|
<title>The value of the OAuth1 token</title>
|
||||||
<type>d:text</type>
|
<type>d:encrypted</type>
|
||||||
<multiple>false</multiple>
|
<multiple>false</multiple>
|
||||||
</property>
|
</property>
|
||||||
<property name="pub:oauth1TokenSecret">
|
<property name="pub:oauth1TokenSecret">
|
||||||
<title>The secret of the OAuth1 token</title>
|
<title>The secret of the OAuth1 token</title>
|
||||||
<type>d:text</type>
|
<type>d:encrypted</type>
|
||||||
<multiple>false</multiple>
|
<multiple>false</multiple>
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -316,7 +316,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="pub:oauth2Token">
|
<property name="pub:oauth2Token">
|
||||||
<title>The value of the OAuth2 token</title>
|
<title>The value of the OAuth2 token</title>
|
||||||
<type>d:text</type>
|
<type>d:encrypted</type>
|
||||||
<multiple>false</multiple>
|
<multiple>false</multiple>
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -328,12 +328,12 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="pub:channelUsername">
|
<property name="pub:channelUsername">
|
||||||
<title>The authenticated channel username</title>
|
<title>The authenticated channel username</title>
|
||||||
<type>d:text</type>
|
<type>d:encrypted</type>
|
||||||
<multiple>false</multiple>
|
<multiple>false</multiple>
|
||||||
</property>
|
</property>
|
||||||
<property name="pub:channelPassword">
|
<property name="pub:channelPassword">
|
||||||
<title>The authenticated channel password</title>
|
<title>The authenticated channel password</title>
|
||||||
<type>d:text</type>
|
<type>d:encrypted</type>
|
||||||
<multiple>false</multiple>
|
<multiple>false</multiple>
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
<bean id="slidesharePublishingHelper" class="org.alfresco.repo.publishing.slideshare.SlideSharePublishingHelper">
|
<bean id="slidesharePublishingHelper" class="org.alfresco.repo.publishing.slideshare.SlideSharePublishingHelper">
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="slideshareConnector" ref="slideshareApiConnector" />
|
<property name="slideshareConnector" ref="slideshareApiConnector" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="slideshareApiConnector" class="com.benfante.jslideshare.SlideShareConnectorImpl">
|
<bean id="slideshareApiConnector" class="com.benfante.jslideshare.SlideShareConnectorImpl">
|
||||||
@@ -28,6 +29,12 @@
|
|||||||
<property name="publicAction" value="false" />
|
<property name="publicAction" value="false" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="unpublish_slideshare" parent="action-executer" class="org.alfresco.repo.publishing.slideshare.SlideShareUnpublishAction">
|
||||||
|
<property name="nodeService" ref="NodeService" />
|
||||||
|
<property name="slideShareHelper" ref="slidesharePublishingHelper" />
|
||||||
|
<property name="publicAction" value="false" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="slideshareDeliveryChannelType" class="org.alfresco.repo.publishing.slideshare.SlideShareChannelType" parent="baseChannelType" >
|
<bean id="slideshareDeliveryChannelType" class="org.alfresco.repo.publishing.slideshare.SlideShareChannelType" parent="baseChannelType" >
|
||||||
<property name="actionService" ref="ActionService" />
|
<property name="actionService" ref="ActionService" />
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<bean id="youtubePublishingHelper" class="org.alfresco.repo.publishing.youtube.YouTubePublishingHelper">
|
<bean id="youtubePublishingHelper" class="org.alfresco.repo.publishing.youtube.YouTubePublishingHelper">
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
|
<property name="encryptor" ref="metadataEncryptor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="publish_youtube" parent="action-executer" class="org.alfresco.repo.publishing.youtube.YouTubePublishAction">
|
<bean id="publish_youtube" parent="action-executer" class="org.alfresco.repo.publishing.youtube.YouTubePublishAction">
|
||||||
|
BIN
config/test/alfresco/TestPresentation2.ppt
Normal file
BIN
config/test/alfresco/TestPresentation2.ppt
Normal file
Binary file not shown.
BIN
config/test/alfresco/TestPresentation3.odp
Normal file
BIN
config/test/alfresco/TestPresentation3.odp
Normal file
Binary file not shown.
BIN
config/test/alfresco/TestPresentation4.pdf
Normal file
BIN
config/test/alfresco/TestPresentation4.pdf
Normal file
Binary file not shown.
@@ -100,6 +100,10 @@
|
|||||||
<constructor-arg value="org.alfresco.service.cmr.security.PermissionService" />
|
<constructor-arg value="org.alfresco.service.cmr.security.PermissionService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="metadataEncryptor" class="org.mockito.Mockito" factory-method="mock">
|
||||||
|
<constructor-arg value="org.alfresco.repo.node.encryption.MetadataEncryptor" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="dictionaryBootstrap" class="java.lang.Object" />
|
<bean id="dictionaryBootstrap" class="java.lang.Object" />
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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.node.encryption;
|
package org.alfresco.repo.node.encryption;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -12,7 +30,6 @@ import javax.crypto.SealedObject;
|
|||||||
import org.alfresco.encryption.FallbackEncryptor;
|
import org.alfresco.encryption.FallbackEncryptor;
|
||||||
import org.alfresco.encryption.KeyProvider;
|
import org.alfresco.encryption.KeyProvider;
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
@@ -53,21 +70,8 @@ public class MetadataEncryptor
|
|||||||
this.encryptor = encryptor;
|
this.encryptor = encryptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthenticationException if the thread is not running as 'system'
|
|
||||||
*/
|
|
||||||
private final void checkAuthentication()
|
|
||||||
{
|
|
||||||
if (!AuthenticationUtil.isRunAsUserTheSystemUser())
|
|
||||||
{
|
|
||||||
throw new AuthenticationException("Metadata decryption can only be done by the system user.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt a properties if the data definition (model-specific) requires it.
|
* Encrypt a properties if the data definition (model-specific) requires it.
|
||||||
* <p/>
|
|
||||||
* This method has no specific authentication requirements.
|
|
||||||
*
|
*
|
||||||
* @param propertyQName the property qualified name
|
* @param propertyQName the property qualified name
|
||||||
* @param inbound the property to encrypt
|
* @param inbound the property to encrypt
|
||||||
@@ -91,8 +95,6 @@ public class MetadataEncryptor
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt a property if the data definition (model-specific) requires it.
|
* Decrypt a property if the data definition (model-specific) requires it.
|
||||||
* <p/>
|
|
||||||
* This method can only be called by the 'system' user.
|
|
||||||
*
|
*
|
||||||
* @param propertyQName the property qualified name
|
* @param propertyQName the property qualified name
|
||||||
* @param inbound the property to decrypt
|
* @param inbound the property to decrypt
|
||||||
@@ -124,8 +126,6 @@ public class MetadataEncryptor
|
|||||||
/**
|
/**
|
||||||
* Encrypt properties if their data definition (model-specific) requires it.
|
* Encrypt properties if their data definition (model-specific) requires it.
|
||||||
* The values provided can be mixed; values will be encrypted only if required.
|
* The values provided can be mixed; values will be encrypted only if required.
|
||||||
* <p/>
|
|
||||||
* This method has no specific authentication requirements.
|
|
||||||
*
|
*
|
||||||
* @param inbound the properties to encrypt
|
* @param inbound the properties to encrypt
|
||||||
* @return a new map of values if some encryption occured
|
* @return a new map of values if some encryption occured
|
||||||
@@ -170,8 +170,6 @@ public class MetadataEncryptor
|
|||||||
/**
|
/**
|
||||||
* Decrypt properties if they are decryptable. The values provided can be mixed;
|
* Decrypt properties if they are decryptable. The values provided can be mixed;
|
||||||
* encrypted values will be sought out and decrypted.
|
* encrypted values will be sought out and decrypted.
|
||||||
* <p/>
|
|
||||||
* This method can only be called by the 'system' user.
|
|
||||||
*
|
*
|
||||||
* @param inbound the properties to decrypt
|
* @param inbound the properties to decrypt
|
||||||
* @return a new map of values if some decryption occured
|
* @return a new map of values if some decryption occured
|
||||||
@@ -179,8 +177,6 @@ public class MetadataEncryptor
|
|||||||
*/
|
*/
|
||||||
public Map<QName, Serializable> decrypt(Map<QName, Serializable> inbound)
|
public Map<QName, Serializable> decrypt(Map<QName, Serializable> inbound)
|
||||||
{
|
{
|
||||||
checkAuthentication();
|
|
||||||
|
|
||||||
Set<QName> encryptedProperties = new HashSet<QName>(5);
|
Set<QName> encryptedProperties = new HashSet<QName>(5);
|
||||||
for (Map.Entry<QName, Serializable> entry : inbound.entrySet())
|
for (Map.Entry<QName, Serializable> entry : inbound.entrySet())
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,7 @@ import java.io.Serializable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
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;
|
||||||
@@ -38,6 +39,7 @@ import org.springframework.core.io.Resource;
|
|||||||
public abstract class AbstractChannelType implements ChannelType
|
public abstract class AbstractChannelType implements ChannelType
|
||||||
{
|
{
|
||||||
private ChannelService channelService;
|
private ChannelService channelService;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
public void setChannelService(ChannelService channelService)
|
public void setChannelService(ChannelService channelService)
|
||||||
{
|
{
|
||||||
@@ -50,6 +52,16 @@ public abstract class AbstractChannelType implements ChannelType
|
|||||||
return channelService;
|
return channelService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MetadataEncryptor getEncryptor()
|
||||||
|
{
|
||||||
|
return encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@@ -58,8 +58,10 @@ public abstract class AbstractOAuth1ChannelType<A> extends AbstractChannelType
|
|||||||
if (nodeService.exists(channelNode)
|
if (nodeService.exists(channelNode)
|
||||||
&& nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL))
|
&& nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL))
|
||||||
{
|
{
|
||||||
String tokenValue = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
String tokenValue = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, nodeService
|
||||||
String tokenSecret = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE));
|
||||||
|
String tokenSecret = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, nodeService
|
||||||
|
.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET));
|
||||||
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
||||||
|
|
||||||
if (danceComplete)
|
if (danceComplete)
|
||||||
@@ -90,8 +92,10 @@ public abstract class AbstractOAuth1ChannelType<A> extends AbstractChannelType
|
|||||||
OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null);
|
OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null);
|
||||||
|
|
||||||
NodeRef channelNodeRef = channel.getNodeRef();
|
NodeRef channelNodeRef = channel.getNodeRef();
|
||||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET, requestToken.getSecret());
|
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET,
|
||||||
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE, requestToken.getValue());
|
getEncryptor().encrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, requestToken.getSecret()));
|
||||||
|
nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE,
|
||||||
|
getEncryptor().encrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, requestToken.getValue()));
|
||||||
|
|
||||||
return oauthOperations.buildAuthorizeUrl(requestToken.getValue(), getOAuth1Parameters(callbackUrl));
|
return oauthOperations.buildAuthorizeUrl(requestToken.getValue(), getOAuth1Parameters(callbackUrl));
|
||||||
}
|
}
|
||||||
@@ -108,14 +112,17 @@ public abstract class AbstractOAuth1ChannelType<A> extends AbstractChannelType
|
|||||||
NodeRef channelNodeRef = channel.getNodeRef();
|
NodeRef channelNodeRef = channel.getNodeRef();
|
||||||
|
|
||||||
Map<QName, Serializable> currentProps = nodeService.getProperties(channelNodeRef);
|
Map<QName, Serializable> currentProps = nodeService.getProperties(channelNodeRef);
|
||||||
String tokenValue = (String) currentProps.get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
String tokenValue = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, currentProps
|
||||||
String tokenSecret = (String) currentProps.get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
.get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE));
|
||||||
|
String tokenSecret = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, currentProps
|
||||||
|
.get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET));
|
||||||
OAuthToken token = new OAuthToken(tokenValue, tokenSecret);
|
OAuthToken token = new OAuthToken(tokenValue, tokenSecret);
|
||||||
OAuthToken accessToken = oauthOperations.exchangeForAccessToken(new AuthorizedRequestToken(token, verifier[0]), null);
|
OAuthToken accessToken = oauthOperations.exchangeForAccessToken(new AuthorizedRequestToken(token, verifier[0]), null);
|
||||||
|
|
||||||
Map<QName, Serializable> newProps = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> newProps = new HashMap<QName, Serializable>();
|
||||||
newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, accessToken.getValue());
|
newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, accessToken.getValue());
|
||||||
newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, accessToken.getSecret());
|
newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, accessToken.getSecret());
|
||||||
|
newProps = getEncryptor().encrypt(newProps);
|
||||||
getChannelService().updateChannel(channel, newProps);
|
getChannelService().updateChannel(channel, newProps);
|
||||||
authorised = AuthStatus.AUTHORISED;
|
authorised = AuthStatus.AUTHORISED;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import java.util.Map;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
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;
|
||||||
@@ -57,6 +58,7 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
private ChannelHelper channelHelper;
|
private ChannelHelper channelHelper;
|
||||||
private PublishingRootObject rootObject;
|
private PublishingRootObject rootObject;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeService
|
* @param nodeService
|
||||||
@@ -92,6 +94,11 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
this.channelHelper = channelHelper;
|
this.channelHelper = channelHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@@ -126,7 +133,7 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
String message = "Channel Type: " + channelTypeId + " does not exist!";
|
String message = "Channel Type: " + channelTypeId + " does not exist!";
|
||||||
throw new IllegalArgumentException(message);
|
throw new IllegalArgumentException(message);
|
||||||
}
|
}
|
||||||
HashMap<QName, Serializable> actualProps = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> actualProps = new HashMap<QName, Serializable>();
|
||||||
if (properties != null)
|
if (properties != null)
|
||||||
{
|
{
|
||||||
actualProps.putAll(properties);
|
actualProps.putAll(properties);
|
||||||
@@ -134,6 +141,7 @@ public class ChannelServiceImpl implements ChannelService
|
|||||||
actualProps.put(ContentModel.PROP_NAME, name);
|
actualProps.put(ContentModel.PROP_NAME, name);
|
||||||
actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId());
|
actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId());
|
||||||
actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE);
|
actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE);
|
||||||
|
actualProps = encryptor.encrypt(actualProps);
|
||||||
NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps);
|
NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps);
|
||||||
return channelHelper.buildChannelObject(channelNode, this);
|
return channelHelper.buildChannelObject(channelNode, this);
|
||||||
}
|
}
|
||||||
|
@@ -165,6 +165,7 @@ public class FacebookChannelType extends AbstractChannelType
|
|||||||
{
|
{
|
||||||
Map<QName,Serializable> channelProps = new HashMap<QName, Serializable>();
|
Map<QName,Serializable> channelProps = new HashMap<QName, Serializable>();
|
||||||
channelProps.put(PublishingModel.PROP_OAUTH2_TOKEN, accessToken);
|
channelProps.put(PublishingModel.PROP_OAUTH2_TOKEN, accessToken);
|
||||||
|
channelProps = getEncryptor().encrypt(channelProps);
|
||||||
getChannelService().updateChannel(channel, channelProps);
|
getChannelService().updateChannel(channel, channelProps);
|
||||||
authorised = AuthStatus.AUTHORISED;
|
authorised = AuthStatus.AUTHORISED;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.publishing.facebook;
|
package org.alfresco.repo.publishing.facebook;
|
||||||
|
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
import org.alfresco.repo.publishing.PublishingModel;
|
import org.alfresco.repo.publishing.PublishingModel;
|
||||||
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;
|
||||||
@@ -34,6 +35,7 @@ public class FacebookPublishingHelper
|
|||||||
{
|
{
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private FacebookConnectionFactory connectionFactory;
|
private FacebookConnectionFactory connectionFactory;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -50,13 +52,19 @@ public class FacebookPublishingHelper
|
|||||||
return connectionFactory;
|
return connectionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
public Connection<Facebook> getFacebookConnectionForChannel(NodeRef channelNode)
|
public Connection<Facebook> getFacebookConnectionForChannel(NodeRef channelNode)
|
||||||
{
|
{
|
||||||
Connection<Facebook> connection = null;
|
Connection<Facebook> connection = null;
|
||||||
if (nodeService.exists(channelNode)
|
if (nodeService.exists(channelNode)
|
||||||
&& nodeService.hasAspect(channelNode, FacebookPublishingModel.ASPECT_DELIVERY_CHANNEL))
|
&& nodeService.hasAspect(channelNode, FacebookPublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||||
{
|
{
|
||||||
String tokenValue = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH2_TOKEN);
|
String tokenValue = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH2_TOKEN, nodeService.getProperty(
|
||||||
|
channelNode, PublishingModel.PROP_OAUTH2_TOKEN));
|
||||||
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
||||||
|
|
||||||
if (danceComplete)
|
if (danceComplete)
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.publishing.flickr;
|
package org.alfresco.repo.publishing.flickr;
|
||||||
|
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
import org.alfresco.repo.publishing.PublishingModel;
|
import org.alfresco.repo.publishing.PublishingModel;
|
||||||
import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr;
|
import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr;
|
||||||
import org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrConnectionFactory;
|
import org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrConnectionFactory;
|
||||||
@@ -30,6 +31,7 @@ public class FlickrPublishingHelper
|
|||||||
{
|
{
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private FlickrConnectionFactory connectionFactory;
|
private FlickrConnectionFactory connectionFactory;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -41,6 +43,11 @@ public class FlickrPublishingHelper
|
|||||||
this.connectionFactory = connectionFactory;
|
this.connectionFactory = connectionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
public FlickrConnectionFactory getConnectionFactory()
|
public FlickrConnectionFactory getConnectionFactory()
|
||||||
{
|
{
|
||||||
return connectionFactory;
|
return connectionFactory;
|
||||||
@@ -53,8 +60,10 @@ public class FlickrPublishingHelper
|
|||||||
if (nodeService.exists(channelNode)
|
if (nodeService.exists(channelNode)
|
||||||
&& nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL))
|
&& nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL))
|
||||||
{
|
{
|
||||||
String tokenValue = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE);
|
String tokenValue = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, nodeService
|
||||||
String tokenSecret = (String) nodeService.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET);
|
.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE));
|
||||||
|
String tokenSecret = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, nodeService
|
||||||
|
.getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET));
|
||||||
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
|
||||||
|
|
||||||
if (danceComplete)
|
if (danceComplete)
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.linkedin;
|
|
||||||
|
|
||||||
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 LinkedInPublishingHelper
|
|
||||||
{
|
|
||||||
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,29 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.benfante.jslideshare.SlideShareAPI;
|
||||||
|
import com.benfante.jslideshare.SlideShareErrorException;
|
||||||
|
import com.benfante.jslideshare.SlideShareException;
|
||||||
|
|
||||||
|
public interface SlideShareApi extends SlideShareAPI
|
||||||
|
{
|
||||||
|
String deleteSlideshow(String username, String password, String id) throws SlideShareException,
|
||||||
|
SlideShareErrorException;
|
||||||
|
}
|
@@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
|
|
||||||
import com.benfante.jslideshare.DocumentParser;
|
import com.benfante.jslideshare.DocumentParser;
|
||||||
import com.benfante.jslideshare.DocumentParserResult;
|
import com.benfante.jslideshare.DocumentParserResult;
|
||||||
import com.benfante.jslideshare.SlideShareAPI;
|
|
||||||
import com.benfante.jslideshare.SlideShareConnector;
|
import com.benfante.jslideshare.SlideShareConnector;
|
||||||
import com.benfante.jslideshare.SlideShareErrorException;
|
import com.benfante.jslideshare.SlideShareErrorException;
|
||||||
import com.benfante.jslideshare.SlideShareException;
|
import com.benfante.jslideshare.SlideShareException;
|
||||||
@@ -40,7 +39,7 @@ import com.benfante.jslideshare.messages.SlideshowInfo;
|
|||||||
import com.benfante.jslideshare.messages.Tag;
|
import com.benfante.jslideshare.messages.Tag;
|
||||||
import com.benfante.jslideshare.messages.User;
|
import com.benfante.jslideshare.messages.User;
|
||||||
|
|
||||||
public class SlideShareApiImpl implements SlideShareAPI
|
public class SlideShareApiImpl implements SlideShareApi
|
||||||
{
|
{
|
||||||
private static final Log logger = LogFactory.getLog(SlideShareApiImpl.class);
|
private static final Log logger = LogFactory.getLog(SlideShareApiImpl.class);
|
||||||
|
|
||||||
@@ -57,12 +56,12 @@ public class SlideShareApiImpl implements SlideShareAPI
|
|||||||
static
|
static
|
||||||
{
|
{
|
||||||
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW, "http://www.slideshare.net/api/2/get_slideshow");
|
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW, "http://www.slideshare.net/api/2/get_slideshow");
|
||||||
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_INFO, "https://www.slideshare.net/api/2/get_slideshow_info");
|
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_INFO, "http://www.slideshare.net/api/2/get_slideshow");
|
||||||
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_USER, "https://www.slideshare.net/api/2/get_slideshow_by_user");
|
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_USER, "http://www.slideshare.net/api/2/get_slideshow_by_user");
|
||||||
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_TAG, "https://www.slideshare.net/api/2/get_slideshow_by_tag");
|
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_TAG, "http://www.slideshare.net/api/2/get_slideshow_by_tag");
|
||||||
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_GROUP, "https://www.slideshare.net/api/2/get_slideshow_from_group");
|
DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_GROUP, "http://www.slideshare.net/api/2/get_slideshow_from_group");
|
||||||
DEFAULT_API_URLS.put(URL_UPLOAD_SLIDESHOW, "http://www.slideshare.net/api/2/upload_slideshow");
|
DEFAULT_API_URLS.put(URL_UPLOAD_SLIDESHOW, "http://www.slideshare.net/api/2/upload_slideshow");
|
||||||
DEFAULT_API_URLS.put(URL_DELETE_SLIDESHOW, "https://www.slideshare.net/api/2/delete_slideshow");
|
DEFAULT_API_URLS.put(URL_DELETE_SLIDESHOW, "http://www.slideshare.net/api/2/delete_slideshow");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> apiUrls = new TreeMap<String, String>(DEFAULT_API_URLS);
|
private Map<String, String> apiUrls = new TreeMap<String, String>(DEFAULT_API_URLS);
|
||||||
@@ -200,7 +199,7 @@ public class SlideShareApiImpl implements SlideShareAPI
|
|||||||
addParameter(parameters, "username", username);
|
addParameter(parameters, "username", username);
|
||||||
addParameter(parameters, "password", password);
|
addParameter(parameters, "password", password);
|
||||||
addParameter(parameters, "slideshow_id", id);
|
addParameter(parameters, "slideshow_id", id);
|
||||||
return sendGetMessage(URL_DELETE_SLIDESHOW, parameters).getSlideShowId();
|
return sendMessage(URL_DELETE_SLIDESHOW, parameters).getSlideShowId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> addParameter(Map<String, String> parameters, String name, String value)
|
private Map<String, String> addParameter(Map<String, String> parameters, String name, String value)
|
||||||
|
@@ -70,7 +70,7 @@ public class SlideShareChannelType extends AbstractChannelType
|
|||||||
@Override
|
@Override
|
||||||
public boolean canUnpublish()
|
public boolean canUnpublish()
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,7 +107,8 @@ public class SlideShareChannelType extends AbstractChannelType
|
|||||||
@Override
|
@Override
|
||||||
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
Action unpublishAction = actionService.createAction(SlideShareUnpublishAction.NAME);
|
||||||
|
actionService.executeAction(unpublishAction, nodeToUnpublish);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -38,19 +38,27 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.benfante.jslideshare.SlideShareAPI;
|
import com.benfante.jslideshare.SlideShareAPI;
|
||||||
import com.benfante.jslideshare.messages.Slideshow;
|
import com.benfante.jslideshare.messages.SlideshowInfo;
|
||||||
|
|
||||||
public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
private final static Log log = LogFactory.getLog(SlideSharePublishAction.class);
|
private final static Log log = LogFactory.getLog(SlideSharePublishAction.class);
|
||||||
|
private final static int STATUS_QUEUED = 0;
|
||||||
|
// private final static int STATUS_CONVERTING = 1;
|
||||||
|
private final static int STATUS_SUCCEEDED = 2;
|
||||||
|
private final static int STATUS_FAILED = 3;
|
||||||
|
private final static int STATUS_TIMED_OUT = 10;
|
||||||
public static final String NAME = "publish_slideshare";
|
public static final String NAME = "publish_slideshare";
|
||||||
|
private static final String ERROR_SLIDESHARE_CONVERSION_FAILED = "publish.slideshare.conversionFailed";
|
||||||
|
private static final String ERROR_SLIDESHARE_CONVERSION_TIMED_OUT = "publish.slideshare.conversionTimedOut";
|
||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private TaggingService taggingService;
|
private TaggingService taggingService;
|
||||||
private SlideSharePublishingHelper slideShareHelper;
|
private SlideSharePublishingHelper slideShareHelper;
|
||||||
|
|
||||||
|
private long timeoutMilliseconds = 40L * 60L * 1000L; // 40 mins default
|
||||||
|
|
||||||
public void setSlideShareHelper(SlideSharePublishingHelper slideShareHelper)
|
public void setSlideShareHelper(SlideSharePublishingHelper slideShareHelper)
|
||||||
{
|
{
|
||||||
this.slideShareHelper = slideShareHelper;
|
this.slideShareHelper = slideShareHelper;
|
||||||
@@ -71,15 +79,21 @@ public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
|||||||
this.taggingService = taggingService;
|
this.taggingService = taggingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTimeoutMilliseconds(long timeoutMilliseconds)
|
||||||
|
{
|
||||||
|
this.timeoutMilliseconds = timeoutMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void executeImpl(Action action, NodeRef nodeRef)
|
protected void executeImpl(Action action, NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Pair<String,String> usernamePassword = slideShareHelper.getSlideShareCredentialsForNode(nodeRef);
|
Pair<String, String> usernamePassword = slideShareHelper.getSlideShareCredentialsForNode(nodeRef);
|
||||||
if (usernamePassword == null)
|
if (usernamePassword == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("publish.failed.no_credentials_found");
|
throw new AlfrescoRuntimeException("publish.failed.no_credentials_found");
|
||||||
}
|
}
|
||||||
SlideShareAPI api = slideShareHelper.getSlideShareApi(usernamePassword.getFirst(), usernamePassword.getSecond());
|
SlideShareAPI api = slideShareHelper
|
||||||
|
.getSlideShareApi(usernamePassword.getFirst(), usernamePassword.getSecond());
|
||||||
|
|
||||||
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||||
if (reader.exists())
|
if (reader.exists())
|
||||||
@@ -88,17 +102,22 @@ public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
|||||||
String mime = reader.getMimetype();
|
String mime = reader.getMimetype();
|
||||||
|
|
||||||
String extension = slideShareHelper.getAllowedMimeTypes().get(mime);
|
String extension = slideShareHelper.getAllowedMimeTypes().get(mime);
|
||||||
if (extension == null) extension = "";
|
if (extension == null)
|
||||||
|
extension = "";
|
||||||
|
|
||||||
boolean deleteContentFileOnCompletion = false;
|
boolean deleteContentFileOnCompletion = false;
|
||||||
|
|
||||||
//SlideShare seems to work entirely off file extension, so we always copy onto the
|
// SlideShare seems to work entirely off file extension, so we
|
||||||
//file system and upload from there.
|
// always copy onto the
|
||||||
|
// file system and upload from there.
|
||||||
File tempDir = TempFileProvider.getLongLifeTempDir("slideshare");
|
File tempDir = TempFileProvider.getLongLifeTempDir("slideshare");
|
||||||
contentFile = TempFileProvider.createTempFile("slideshare", extension, tempDir);
|
contentFile = TempFileProvider.createTempFile("slideshare", extension, tempDir);
|
||||||
reader.getContent(contentFile);
|
reader.getContent(contentFile);
|
||||||
deleteContentFileOnCompletion = true;
|
deleteContentFileOnCompletion = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
|
String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
|
||||||
if (title == null || title.length() == 0)
|
if (title == null || title.length() == 0)
|
||||||
@@ -123,30 +142,72 @@ public class SlideSharePublishAction extends ActionExecuterAbstractBase
|
|||||||
contentFile, description, tags.toString(), false, false, false, false, false);
|
contentFile, description, tags.toString(), false, false, false, false, false);
|
||||||
|
|
||||||
String url = null;
|
String url = null;
|
||||||
Slideshow slides = api.getSlideshow(assetId);
|
int status = STATUS_QUEUED;
|
||||||
if (slides != null)
|
boolean finished = false;
|
||||||
|
long timeoutTime = System.currentTimeMillis() + timeoutMilliseconds;
|
||||||
|
// Fetch the slideshow info every 5 seconds for 5 minutes...
|
||||||
|
while (!finished)
|
||||||
{
|
{
|
||||||
url = slides.getPermalink();
|
SlideshowInfo slideInfo = api.getSlideshowInfo(assetId, "");
|
||||||
|
if (slideInfo != null)
|
||||||
|
{
|
||||||
|
if (url == null)
|
||||||
|
{
|
||||||
|
url = slideInfo.getUrl();
|
||||||
if (log.isInfoEnabled())
|
if (log.isInfoEnabled())
|
||||||
{
|
{
|
||||||
log.info("SlideShare has provided a URL for asset " + assetId + ": " + url);
|
log.info("SlideShare has provided a URL for asset " + assetId + ": " + url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
status = slideInfo.getStatus();
|
||||||
|
}
|
||||||
|
finished = (status == STATUS_FAILED || status == STATUS_SUCCEEDED);
|
||||||
|
|
||||||
|
if (!finished)
|
||||||
|
{
|
||||||
|
if (System.currentTimeMillis() < timeoutTime)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(30000L);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_TIMED_OUT;
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status == STATUS_SUCCEEDED)
|
||||||
|
{
|
||||||
if (log.isInfoEnabled())
|
if (log.isInfoEnabled())
|
||||||
{
|
{
|
||||||
log.info("File " + name + " has been published to SlideShare with id " + assetId + " at URL " + url);
|
log.info("File " + name + " has been published to SlideShare with id " + assetId + " at URL "
|
||||||
|
+ url);
|
||||||
}
|
}
|
||||||
nodeService.addAspect(nodeRef, SlideSharePublishingModel.ASPECT_ASSET, null);
|
nodeService.addAspect(nodeRef, SlideSharePublishingModel.ASPECT_ASSET, null);
|
||||||
nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_ID, assetId);
|
nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_ID, assetId);
|
||||||
nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_URL, url);
|
nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_URL, url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(status == STATUS_FAILED ? ERROR_SLIDESHARE_CONVERSION_FAILED
|
||||||
|
: ERROR_SLIDESHARE_CONVERSION_TIMED_OUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
if (deleteContentFileOnCompletion)
|
if (deleteContentFileOnCompletion)
|
||||||
{
|
{
|
||||||
contentFile.delete();
|
contentFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.Map;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
import org.alfresco.repo.publishing.PublishingModel;
|
import org.alfresco.repo.publishing.PublishingModel;
|
||||||
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;
|
||||||
@@ -53,6 +54,7 @@ public class SlideSharePublishingHelper
|
|||||||
private Map<String, String> allowedMimeTypes = Collections.unmodifiableMap(DEFAULT_MIME_TYPES);
|
private Map<String, String> allowedMimeTypes = Collections.unmodifiableMap(DEFAULT_MIME_TYPES);
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private SlideShareConnector slideshareConnector;
|
private SlideShareConnector slideshareConnector;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -74,6 +76,11 @@ public class SlideSharePublishingHelper
|
|||||||
this.allowedMimeTypes = Collections.unmodifiableMap(allowedMimeTypes);
|
this.allowedMimeTypes = Collections.unmodifiableMap(allowedMimeTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
public SlideShareAPI getSlideShareApi()
|
public SlideShareAPI getSlideShareApi()
|
||||||
{
|
{
|
||||||
return createApiObject();
|
return createApiObject();
|
||||||
@@ -92,8 +99,10 @@ public class SlideSharePublishingHelper
|
|||||||
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
||||||
if (nodeService.hasAspect(parent, SlideSharePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
if (nodeService.hasAspect(parent, SlideSharePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||||
{
|
{
|
||||||
String username = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME);
|
String username = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_USERNAME, nodeService
|
||||||
String password = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD);
|
.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME));
|
||||||
|
String password = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_PASSWORD, nodeService
|
||||||
|
.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD));
|
||||||
if (username != null && password != null)
|
if (username != null && password != null)
|
||||||
{
|
{
|
||||||
result = new Pair<String, String>(username, password);
|
result = new Pair<String, String>(username, password);
|
||||||
@@ -103,7 +112,7 @@ public class SlideSharePublishingHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlideShareAPI getSlideShareApi(String username, String password)
|
public SlideShareApi getSlideShareApi(String username, String password)
|
||||||
{
|
{
|
||||||
SlideShareApiImpl api = createApiObject();
|
SlideShareApiImpl api = createApiObject();
|
||||||
api.setUsername(username);
|
api.setUsername(username);
|
||||||
|
@@ -19,9 +19,13 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.publishing.slideshare;
|
package org.alfresco.repo.publishing.slideshare;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
@@ -37,6 +41,7 @@ import org.alfresco.service.cmr.action.ActionService;
|
|||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
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.repository.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -65,6 +70,8 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
protected PublishingQueueImpl queue;
|
protected PublishingQueueImpl queue;
|
||||||
protected Environment environment;
|
protected Environment environment;
|
||||||
protected NodeRef docLib;
|
protected NodeRef docLib;
|
||||||
|
protected Map<String, String> testFiles = new TreeMap<String, String>();
|
||||||
|
protected Map<NodeRef, String> testNodeMap = new HashMap<NodeRef, String>();
|
||||||
|
|
||||||
private ChannelService channelService;
|
private ChannelService channelService;
|
||||||
|
|
||||||
@@ -84,6 +91,11 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
siteService.createSite("test", siteId, "Site created by publishing test", "Site created by publishing test",
|
siteService.createSite("test", siteId, "Site created by publishing test", "Site created by publishing test",
|
||||||
SiteVisibility.PUBLIC);
|
SiteVisibility.PUBLIC);
|
||||||
docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
||||||
|
|
||||||
|
testFiles.put("test/alfresco/TestPresentation.pptx", MimetypeMap.MIMETYPE_OPENXML_PRESENTATION);
|
||||||
|
testFiles.put("test/alfresco/TestPresentation2.ppt", MimetypeMap.MIMETYPE_PPT);
|
||||||
|
testFiles.put("test/alfresco/TestPresentation3.odp", MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION);
|
||||||
|
testFiles.put("test/alfresco/TestPresentation4.pdf", MimetypeMap.MIMETYPE_PDF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTearDown()
|
public void onTearDown()
|
||||||
@@ -96,30 +108,51 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note that this test isn't normally run, as it requires valid YouTube credentials.
|
// Note that this test isn't normally run, as it requires valid YouTube
|
||||||
//To run it, remove the initial 'x' from the method name and set the appropriate YouTube credentials where the
|
// credentials.
|
||||||
//text "YOUR_USER_NAME" and "YOUR_PASSWORD" appear.
|
// To run it, remove the initial 'x' from the method name and set the
|
||||||
|
// appropriate YouTube credentials where the
|
||||||
|
// text "YOUR_USER_NAME" and "YOUR_PASSWORD" appear.
|
||||||
public void xtestSlideSharePublishAndUnpublishActions() throws Exception
|
public void xtestSlideSharePublishAndUnpublishActions() throws Exception
|
||||||
{
|
{
|
||||||
final NodeRef node = transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
final List<NodeRef> nodes = transactionHelper.doInTransaction(new RetryingTransactionCallback<List<NodeRef>>()
|
||||||
{
|
{
|
||||||
public NodeRef execute() throws Throwable
|
public List<NodeRef> execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
List<NodeRef> createdTestNodes = new ArrayList<NodeRef>();
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||||
|
// props.put(PublishingModel.PROP_CHANNEL_USERNAME,
|
||||||
|
// "YOUR_USER_NAME");
|
||||||
|
// props.put(PublishingModel.PROP_CHANNEL_PASSWORD,
|
||||||
|
// "YOUR_PASSWORD");
|
||||||
props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME");
|
props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME");
|
||||||
props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD");
|
props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD");
|
||||||
Channel channel = channelService.createChannel(SlideShareChannelType.ID, "SlideShareChannel", props);
|
Channel channel = channelService.createChannel(SlideShareChannelType.ID, GUID.generate(), props);
|
||||||
|
|
||||||
NodeRef channelNode = channel.getNodeRef();
|
NodeRef channelNode = channel.getNodeRef();
|
||||||
Resource file = new ClassPathResource("test/alfresco/TestPresentation.pptx");
|
|
||||||
Map<QName, Serializable> vidProps = new HashMap<QName, Serializable>();
|
for (Map.Entry<String, String> testFileInfoEntry : testFiles.entrySet())
|
||||||
vidProps.put(ContentModel.PROP_NAME, "Test Presentation");
|
{
|
||||||
NodeRef node = nodeService.createNode(channelNode, ContentModel.ASSOC_CONTAINS,
|
NodeRef nodeRef = createTestNode(channelNode, testFileInfoEntry.getKey(), testFileInfoEntry
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testPresentation"),
|
.getValue());
|
||||||
ContentModel.TYPE_CONTENT, vidProps).getChildRef();
|
createdTestNodes.add(nodeRef);
|
||||||
|
testNodeMap.put(nodeRef, testFileInfoEntry.getKey());
|
||||||
|
}
|
||||||
|
return createdTestNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef createTestNode(NodeRef parent, String fileLocation, String mimeType)
|
||||||
|
throws ContentIOException, IOException
|
||||||
|
{
|
||||||
|
Resource file = new ClassPathResource(fileLocation);
|
||||||
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||||
|
props.put(ContentModel.PROP_NAME, "Presentation " + GUID.generate());
|
||||||
|
NodeRef node = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, GUID.generate()),
|
||||||
|
ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||||
ContentService contentService = serviceRegistry.getContentService();
|
ContentService contentService = serviceRegistry.getContentService();
|
||||||
ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
|
ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
|
||||||
writer.setMimetype(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION);
|
writer.setMimetype(mimeType);
|
||||||
writer.putContent(file.getFile());
|
writer.putContent(file.getFile());
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@@ -128,6 +161,8 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||||
{
|
{
|
||||||
public NodeRef execute() throws Throwable
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
for (NodeRef node : nodes)
|
||||||
{
|
{
|
||||||
ActionService actionService = serviceRegistry.getActionService();
|
ActionService actionService = serviceRegistry.getActionService();
|
||||||
Action publishAction = actionService.createAction(SlideSharePublishAction.NAME);
|
Action publishAction = actionService.createAction(SlideSharePublishAction.NAME);
|
||||||
@@ -135,16 +170,21 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
Map<QName, Serializable> props = nodeService.getProperties(node);
|
Map<QName, Serializable> props = nodeService.getProperties(node);
|
||||||
Assert.assertTrue(nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET));
|
Assert.assertTrue(nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET));
|
||||||
Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_ID));
|
Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_ID));
|
||||||
// Assert.assertNotNull(props.get(SlideSharePublishingModel.PROP_ASSET_URL));
|
Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_URL));
|
||||||
|
|
||||||
|
System.out.println("Test file: " + testNodeMap.get(node));
|
||||||
System.out.println("SlideShare id: " + props.get(PublishingModel.PROP_ASSET_ID));
|
System.out.println("SlideShare id: " + props.get(PublishingModel.PROP_ASSET_ID));
|
||||||
|
System.out.println("SlideShare URL: " + props.get(PublishingModel.PROP_ASSET_URL));
|
||||||
|
}
|
||||||
|
|
||||||
// Action unpublishAction = actionService.createAction(SlideShareUnpublishAction.NAME);
|
// Action unpublishAction =
|
||||||
// actionService.executeAction(unpublishAction, node);
|
// actionService.createAction(SlideShareUnpublishAction.NAME);
|
||||||
// props = nodeService.getProperties(node);
|
// actionService.executeAction(unpublishAction, node);
|
||||||
// Assert.assertFalse(nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET));
|
// props = nodeService.getProperties(node);
|
||||||
// Assert.assertNull(props.get(SlideSharePublishingModel.PROP_ASSET_ID));
|
// Assert.assertFalse(nodeService.hasAspect(node,
|
||||||
// Assert.assertNull(props.get(SlideSharePublishingModel.PROP_ASSET_URL));
|
// SlideSharePublishingModel.ASPECT_ASSET));
|
||||||
|
// Assert.assertNull(props.get(SlideSharePublishingModel.PROP_ASSET_ID));
|
||||||
|
// Assert.assertNull(props.get(SlideSharePublishingModel.PROP_ASSET_URL));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -152,8 +192,11 @@ public class SlideShareTest extends BaseSpringTest
|
|||||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||||
{
|
{
|
||||||
public NodeRef execute() throws Throwable
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
for (NodeRef node : nodes)
|
||||||
{
|
{
|
||||||
nodeService.deleteNode(node);
|
nodeService.deleteNode(node);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* 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.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
|
import org.alfresco.repo.publishing.PublishingModel;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
|
public class SlideShareUnpublishAction extends ActionExecuterAbstractBase
|
||||||
|
{
|
||||||
|
public static final String NAME = "unpublish_slideshare";
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
private SlideSharePublishingHelper slideShareHelper;
|
||||||
|
|
||||||
|
public void setSlideShareHelper(SlideSharePublishingHelper slideShareHelper)
|
||||||
|
{
|
||||||
|
this.slideShareHelper = slideShareHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeImpl(Action action, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
if (nodeService.hasAspect(nodeRef, SlideSharePublishingModel.ASPECT_ASSET))
|
||||||
|
{
|
||||||
|
String assetId = (String) nodeService.getProperty(nodeRef, PublishingModel.PROP_ASSET_ID);
|
||||||
|
if (assetId != null)
|
||||||
|
{
|
||||||
|
Pair<String, String> usernamePassword = slideShareHelper.getSlideShareCredentialsForNode(nodeRef);
|
||||||
|
if (usernamePassword == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("publish.failed.no_credentials_found");
|
||||||
|
}
|
||||||
|
SlideShareApi api = slideShareHelper.getSlideShareApi(
|
||||||
|
usernamePassword.getFirst(), usernamePassword.getSecond());
|
||||||
|
|
||||||
|
api.deleteSlideshow(usernamePassword.getFirst(), usernamePassword.getSecond(), assetId);
|
||||||
|
nodeService.removeAspect(nodeRef, SlideSharePublishingModel.ASPECT_ASSET);
|
||||||
|
nodeService.removeAspect(nodeRef, PublishingModel.ASPECT_ASSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.publishing.youtube;
|
package org.alfresco.repo.publishing.youtube;
|
||||||
|
|
||||||
|
import org.alfresco.repo.node.encryption.MetadataEncryptor;
|
||||||
import org.alfresco.repo.publishing.PublishingModel;
|
import org.alfresco.repo.publishing.PublishingModel;
|
||||||
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;
|
||||||
@@ -30,12 +31,17 @@ public class YouTubePublishingHelper
|
|||||||
{
|
{
|
||||||
private static final Log log = LogFactory.getLog(YouTubePublishingHelper.class);
|
private static final Log log = LogFactory.getLog(YouTubePublishingHelper.class);
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
private MetadataEncryptor encryptor;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEncryptor(MetadataEncryptor encryptor)
|
||||||
|
{
|
||||||
|
this.encryptor = encryptor;
|
||||||
|
}
|
||||||
|
|
||||||
public YouTubeService getYouTubeServiceForNode(NodeRef publishNode)
|
public YouTubeService getYouTubeServiceForNode(NodeRef publishNode)
|
||||||
{
|
{
|
||||||
@@ -45,8 +51,10 @@ public class YouTubePublishingHelper
|
|||||||
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
NodeRef parent = nodeService.getPrimaryParent(publishNode).getParentRef();
|
||||||
if (nodeService.hasAspect(parent, YouTubePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
if (nodeService.hasAspect(parent, YouTubePublishingModel.ASPECT_DELIVERY_CHANNEL))
|
||||||
{
|
{
|
||||||
String youtubeUsername = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME);
|
String youtubeUsername = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_USERNAME, nodeService
|
||||||
String youtubePassword = (String) nodeService.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD);
|
.getProperty(parent, PublishingModel.PROP_CHANNEL_USERNAME));
|
||||||
|
String youtubePassword = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_PASSWORD, nodeService
|
||||||
|
.getProperty(parent, PublishingModel.PROP_CHANNEL_PASSWORD));
|
||||||
service = new YouTubeService("Alfresco",
|
service = new YouTubeService("Alfresco",
|
||||||
"AI39si78RHlniONCtnu9o8eBfwZToBAp2ZbbURm5eoJjj4gZi0LcxjDqJTzD35oYokmtFXbCo5ojofbimGnMlRbmNrh7-M7ZCw");
|
"AI39si78RHlniONCtnu9o8eBfwZToBAp2ZbbURm5eoJjj4gZi0LcxjDqJTzD35oYokmtFXbCo5ojofbimGnMlRbmNrh7-M7ZCw");
|
||||||
try
|
try
|
||||||
|
Reference in New Issue
Block a user