mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixing URL issues on publishing.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29035 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
|
<import resource="classpath:alfresco/extension/dev-context.xml" />
|
||||||
<import resource="classpath:alfresco/web-publishing-context.xml" />
|
<import resource="classpath:alfresco/web-publishing-context.xml" />
|
||||||
|
|
||||||
<!-- Mock Channel Type -->
|
<!-- Mock Channel Type -->
|
||||||
|
@@ -141,17 +141,26 @@ public class ChannelHelper
|
|||||||
public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef environment, String channelName)
|
public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef environment, String channelName)
|
||||||
{
|
{
|
||||||
NodeRef channel = getChannelNodeForEnvironment(environment, channelName);
|
NodeRef channel = getChannelNodeForEnvironment(environment, channelName);
|
||||||
return mapSourceToEnvironment(source, channel);
|
return mapSourceToEnvironmentInternal(source, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef in the specified channelt
|
* Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef in the specified channelt
|
||||||
* @param source
|
* @param source
|
||||||
* @param channel
|
* @param editorialChannel
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef channel)
|
public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef editorialChannel)
|
||||||
{
|
{
|
||||||
|
// NodeRef liveChannel = mapChannelNOde(editorialChannel);
|
||||||
|
return mapSourceToEnvironmentInternal(source, editorialChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef mapSourceToEnvironmentInternal(NodeRef source, NodeRef liveChannel)
|
||||||
|
{
|
||||||
|
if(source == null || liveChannel == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(source, ASSOC_SOURCE, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(source, ASSOC_SOURCE, RegexQNamePattern.MATCH_ALL);
|
||||||
if(parentAssocs != null)
|
if(parentAssocs != null)
|
||||||
{
|
{
|
||||||
@@ -159,7 +168,7 @@ public class ChannelHelper
|
|||||||
{
|
{
|
||||||
NodeRef publishedNode = parentAssoc.getParentRef();
|
NodeRef publishedNode = parentAssoc.getParentRef();
|
||||||
NodeRef parent = nodeService.getPrimaryParent(publishedNode).getParentRef();
|
NodeRef parent = nodeService.getPrimaryParent(publishedNode).getParentRef();
|
||||||
if(channel.equals(parent))
|
if(liveChannel.equals(parent))
|
||||||
{
|
{
|
||||||
return publishedNode;
|
return publishedNode;
|
||||||
}
|
}
|
||||||
@@ -179,6 +188,25 @@ public class ChannelHelper
|
|||||||
return getSingleValue(childAssocs, true);
|
return getSingleValue(childAssocs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link NodeRef} for the live channel given the {@link NodeRef} for the editorial channel.
|
||||||
|
* @param editorialChannel
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public NodeRef mapChannelNOde(NodeRef editorialChannel)
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> assocs = nodeService.getParentAssocs(editorialChannel, PublishingModel.ASSOC_EDITORIAL_CHANNEL, RegexQNamePattern.MATCH_ALL);
|
||||||
|
if(assocs.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(assocs.size()>1)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("There is more than one environment channel node!");
|
||||||
|
}
|
||||||
|
return assocs.get(0).getParentRef();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the {@link Channel} NodeRef and {@link ChannelType} id for a given node, if such a Channel exists.
|
* Finds the {@link Channel} NodeRef and {@link ChannelType} id for a given node, if such a Channel exists.
|
||||||
* @param node
|
* @param node
|
||||||
|
@@ -114,4 +114,13 @@ public class ChannelImpl implements Channel
|
|||||||
channelType.updateStatus(this, status, getProperties());
|
channelType.updateStatus(this, status, getProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getUrl(NodeRef publishedNode)
|
||||||
|
{
|
||||||
|
NodeRef mappedChannel = channelHelper.mapChannelNOde(nodeRef);
|
||||||
|
NodeRef mappedNode = channelHelper.mapSourceToEnvironment(publishedNode, mappedChannel);
|
||||||
|
return channelType.getNodeUrl(mappedNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -99,7 +99,7 @@ public class PublishingEventProcessor
|
|||||||
NodeRef node = update.getNodeToLinkTo();
|
NodeRef node = update.getNodeToLinkTo();
|
||||||
if(node!= null)
|
if(node!= null)
|
||||||
{
|
{
|
||||||
String nodeUrl = publishChannel.getChannelType().getNodeUrl(node);
|
String nodeUrl = publishChannel.getUrl(node);
|
||||||
if(nodeUrl != null)
|
if(nodeUrl != null)
|
||||||
{
|
{
|
||||||
message += urlShortener.shortenUrl(nodeUrl);
|
message += urlShortener.shortenUrl(nodeUrl);
|
||||||
|
@@ -4,7 +4,7 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
public class BitlyUrlShortenerTest extends TestCase
|
public class BitlyUrlShortenerTest extends TestCase
|
||||||
{
|
{
|
||||||
private BitlyUrlShortenerImpl shortener = new BitlyUrlShortenerImpl();
|
private BitlyUrlShortenerImpl shortener;
|
||||||
|
|
||||||
public void testShorten()
|
public void testShorten()
|
||||||
{
|
{
|
||||||
@@ -15,4 +15,16 @@ public class BitlyUrlShortenerTest extends TestCase
|
|||||||
assertFalse(url.equals(shortUrl));
|
assertFalse(url.equals(shortUrl));
|
||||||
assertTrue(shortUrl.length()<=20);
|
assertTrue(shortUrl.length()<=20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception
|
||||||
|
{
|
||||||
|
this.shortener = new BitlyUrlShortenerImpl();;
|
||||||
|
shortener.setApiKey("R_ca15c6c89e9b25ccd170bafd209a0d4f");
|
||||||
|
shortener.setUrlLength(20);
|
||||||
|
shortener.setUsername("brianalfresco");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brian
|
* @author Brian
|
||||||
*
|
* @author Nick Smith
|
||||||
*/
|
*/
|
||||||
public interface Channel
|
public interface Channel
|
||||||
{
|
{
|
||||||
@@ -51,4 +51,10 @@ public interface Channel
|
|||||||
void unPublish(NodeRef nodeToUnpublish);
|
void unPublish(NodeRef nodeToUnpublish);
|
||||||
void updateStatus(String status);
|
void updateStatus(String status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the URL for some published content given the content node in the editorial environment.
|
||||||
|
* @param publishedNode The node representing the published content in the editorial environment.
|
||||||
|
* @return a URL for the published content.
|
||||||
|
*/
|
||||||
|
String getUrl(NodeRef publishedNode);
|
||||||
}
|
}
|
@@ -48,10 +48,15 @@ public interface ChannelType
|
|||||||
|
|
||||||
Set<String> getSupportedMimetypes();
|
Set<String> getSupportedMimetypes();
|
||||||
Set<QName> getSupportedContentTypes();
|
Set<QName> getSupportedContentTypes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the URL for a piece of content represented by the supplied <code>node</code>.
|
||||||
|
* @param node The published content node in the live environment.
|
||||||
|
* @return a URL for the published content.
|
||||||
|
*/
|
||||||
String getNodeUrl(NodeRef node);
|
String getNodeUrl(NodeRef node);
|
||||||
int getMaximumStatusLength();
|
int getMaximumStatusLength();
|
||||||
|
|
||||||
String getAuthorisationUrl(Channel channel, String callbackUrl);
|
String getAuthorisationUrl(Channel channel, String callbackUrl);
|
||||||
public boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders,
|
boolean acceptAuthorisationCallback(Channel channel, Map<String, String[]> callbackHeaders, Map<String, String[]> callbackParams);
|
||||||
Map<String, String[]> callbackParams);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user