Publishing:

- Added start of the Flickr channel. Channel creation and authorisation is complete (written as a new Spring Social module). API not currently working.
- Fixed a problem with SlideShare API: it relies on the file extension to determine the type of the file, so needed to alter the way the files are sent.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29085 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-07-15 15:47:26 +00:00
parent 176a08d093
commit aeb467a3d8
34 changed files with 1520 additions and 61 deletions

View File

@@ -22,9 +22,7 @@ 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;
@@ -36,28 +34,11 @@ 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);
}
private SlideSharePublishingHelper publishingHelper;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
@@ -68,13 +49,9 @@ public class SlideShareChannelType extends AbstractChannelType
this.actionService = actionService;
}
public void setPermittedMimeTypes(Set<String> permittedMimeTypes)
public void setPublishingHelper(SlideSharePublishingHelper publishingHelper)
{
if (permittedMimeTypes == null)
{
permittedMimeTypes = Collections.emptySet();
}
this.permittedMimeTypes = Collections.unmodifiableSet(permittedMimeTypes);
this.publishingHelper = publishingHelper;
}
@Override
@@ -116,7 +93,7 @@ public class SlideShareChannelType extends AbstractChannelType
@Override
public Set<String> getSupportedMimetypes()
{
return permittedMimeTypes;
return publishingHelper.getAllowedMimeTypes().keySet();
}
@Override

View File

@@ -24,7 +24,6 @@ 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;
@@ -38,6 +37,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.benfante.jslideshare.SlideShareAPI;
import com.benfante.jslideshare.messages.Slideshow;
public class SlideSharePublishAction extends ActionExecuterAbstractBase
{
@@ -84,20 +84,19 @@ public class SlideSharePublishAction extends ActionExecuterAbstractBase
if (reader.exists())
{
File contentFile;
String mime = reader.getMimetype();
String extension = slideShareHelper.getAllowedMimeTypes().get(mime);
if (extension == null) extension = "";
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;
}
//SlideShare seems to work entirely off file extension, so we always copy onto the
//file system and upload from there.
File tempDir = TempFileProvider.getLongLifeTempDir("slideshare");
contentFile = TempFileProvider.createTempFile("slideshare", extension, tempDir);
reader.getContent(contentFile);
deleteContentFileOnCompletion = true;
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
@@ -121,8 +120,17 @@ public class SlideSharePublishAction extends ActionExecuterAbstractBase
String assetId = api.uploadSlideshow(usernamePassword.getFirst(), usernamePassword.getSecond(), title,
contentFile, description, tags.toString(), false, false, false, false, false);
// String url = api.getSlideshow(assetId).getPermalink();
String url = null;
Slideshow slides = api.getSlideshow(assetId);
if (slides != null)
{
url = slides.getPermalink();
if (log.isInfoEnabled())
{
log.info("SlideShare has provided a URL for asset " + assetId + ": " + url);
}
}
if (log.isInfoEnabled())
{
log.info("File " + name + " has been published to SlideShare with id " + assetId + " at URL " + url);

View File

@@ -18,6 +18,11 @@
*/
package org.alfresco.repo.publishing.slideshare;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -28,6 +33,24 @@ import com.benfante.jslideshare.SlideShareConnector;
public class SlideSharePublishingHelper
{
private final static Map<String,String> DEFAULT_MIME_TYPES = new TreeMap<String,String>();
static
{
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_PPT, ".ppt");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_PDF, ".pdf");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, ".odp");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, ".pptx");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, "");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_IWORK_PAGES, "");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_TEXT_PLAIN, ".txt");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_TEXT, ".odt");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_TEXT_CSV, ".csv");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_EXCEL, ".xls");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, ".docx");
DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_SPREADSHEET, ".ods");
}
private Map<String, String> allowedMimeTypes = Collections.unmodifiableMap(DEFAULT_MIME_TYPES);
private NodeService nodeService;
private SlideShareConnector slideshareConnector;
@@ -41,6 +64,16 @@ public class SlideSharePublishingHelper
this.slideshareConnector = slideshareConnector;
}
public Map<String, String> getAllowedMimeTypes()
{
return allowedMimeTypes;
}
public void setAllowedMimeTypes(Map<String, String> allowedMimeTypes)
{
this.allowedMimeTypes = Collections.unmodifiableMap(allowedMimeTypes);
}
public SlideShareAPI getSlideShareApi()
{
return createApiObject();