本文整理汇总了Java中com.google.gdata.data.MediaContent类的典型用法代码示例。如果您正苦于以下问题:Java MediaContent类的具体用法?Java MediaContent怎么用?Java MediaContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaContent类属于com.google.gdata.data包,在下文中一共展示了MediaContent类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: uploadWebAttachment
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
/**
* Creates a web attachment under the selected file cabinet.
*
* @param contentUrl The full URL of the hosted file.
* @param filecabinet File cabinet to create the web attachment on.
* @param title A title for the attachment.
* @param description A description for the attachment.
* @return The created web attachment.
* @throws ServiceException
* @throws IOException
* @throws MalformedURLException
*/
public WebAttachmentEntry uploadWebAttachment(String contentUrl,
FileCabinetPageEntry filecabinet, String title, String description)
throws MalformedURLException, IOException, ServiceException {
MediaContent content = new MediaContent();
content.setUri(contentUrl);
WebAttachmentEntry webAttachment = new WebAttachmentEntry();
webAttachment.setTitle(new PlainTextConstruct(title));
webAttachment.setSummary(new PlainTextConstruct(description));
webAttachment.setContent(content);
webAttachment.addLink(SitesLink.Rel.PARENT, Link.Type.ATOM,
filecabinet.getSelfLink().getHref());
return service.insert(new URL(getContentFeedUrl()), webAttachment);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:28,代码来源:SitesHelper.java
示例2: createEntryFromArgs
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private GlossaryEntry createEntryFromArgs(String[] args)
throws IOException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
System.out.println("You asked to add a glossary...");
GlossaryEntry entry = new GlossaryEntry();
String title = parser.getValue("title");
System.out.println("...with title " + title);
entry.setTitle(new PlainTextConstruct(title));
String filename = parser.getValue("file");
System.out.println("...with contents from " + filename);
File file = new File(filename);
String mimeType = "text/csv";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
entry.setContent(content);
return entry;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:25,代码来源:AddGlossaryCommand.java
示例3: downloadFile
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
/**
* Downloads a file.
*
* @param exportUrl the full url of the export link to download the file from.
* @param filepath path and name of the object to be saved as.
*
* @throws IOException
* @throws MalformedURLException
* @throws ServiceException
* @throws DocumentListException
*/
public void downloadFile(URL exportUrl, String filepath) throws IOException,
MalformedURLException, ServiceException, DocumentListException {
if (exportUrl == null || filepath == null) {
throw new DocumentListException("null passed in for required parameters");
}
MediaContent mc = new MediaContent();
mc.setUri(exportUrl.toString());
MediaSource ms = service.getMedia(mc);
InputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = ms.getInputStream();
outStream = new FileOutputStream(filepath);
int c;
while ((c = inStream.read()) != -1) {
outStream.write(c);
}
} finally {
if (inStream != null) {
inStream.close();
}
if (outStream != null) {
outStream.flush();
outStream.close();
}
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:43,代码来源:DocumentList.java
示例4: downloadFile
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
/**
* Downloads a file from the specified URL to disk.
*
* @param downloadUrl The full URL to download the file from.
* @param fullFilePath The local path to save the file to on disk.
* @throws ServiceException
* @throws IOException
*/
private void downloadFile(String downloadUrl, String fullFilePath) throws IOException,
ServiceException {
System.out.println("Downloading file from: " + downloadUrl);
MediaContent mc = new MediaContent();
mc.setUri(downloadUrl);
MediaSource ms = service.getMedia(mc);
InputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = ms.getInputStream();
outStream = new FileOutputStream(fullFilePath);
int c;
while ((c = inStream.read()) != -1) {
outStream.write(c);
}
} finally {
if (inStream != null) {
inStream.close();
}
if (outStream != null) {
outStream.flush();
outStream.close();
}
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:38,代码来源:SitesHelper.java
示例5: execute
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public void execute(GttService service, String[] args)
throws IOException, ServiceException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
String id = parser.getValue("id");
URL feedUrl = FeedUris.getDocumentDownloadFeedUrl(id);
String targetFile = parser.getValue("file");
System.out.print("Downloading document with id :" + id + " ....");
System.out.flush();
MediaContent mc = new MediaContent();
mc.setUri(feedUrl.toString());
MediaSource ms = service.getMedia(mc);
InputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = ms.getInputStream();
outStream = new FileOutputStream(targetFile);
int c;
while ((c = inStream.read()) != -1) {
outStream.write(c);
}
} finally {
if (inStream != null) {
inStream.close();
}
if (outStream != null) {
outStream.flush();
outStream.close();
}
}
System.out.print("....done. Saved translation to '" + targetFile + "' .");
}
开发者ID:google,项目名称:gdata-java-client,代码行数:39,代码来源:DownloadDocumentCommand.java
示例6: createEntryFromArgs
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private TranslationMemoryEntry createEntryFromArgs(String[] args)
throws IOException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
System.out.println("You asked to add translation memory...");
TranslationMemoryEntry entry = new TranslationMemoryEntry();
String title = parser.getValue("title");
System.out.println("...with title " + title);
entry.setTitle(new PlainTextConstruct(title));
if (parser.containsKey("file")) {
String filename = parser.getValue("file");
System.out.println("...with contents from " + filename);
File file = new File(filename);
String mimeType = "text/xml";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
entry.setContent(content);
}
if (parser.containsKey("private")) {
System.out.println("...with private access");
entry.setScope(new ScopeEntry(ScopeEntry.Value.PRIVATE));
} else {
System.out.println("...with public access");
entry.setScope(new ScopeEntry(ScopeEntry.Value.PUBLIC));
}
return entry;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:37,代码来源:AddTranslationMemoryCommand.java
示例7: setFile
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
/**
* Associate a File with this entry with the specified mime type
*/
public void setFile(File file, String mimeType) {
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
setContent(content);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:11,代码来源:DocumentListEntry.java
示例8: getMediaSource
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public MediaSource getMediaSource() {
if (state.content instanceof MediaContent) {
MediaContent mediaContent = (MediaContent) state.content;
if (mediaContent != null) {
return mediaContent.getMediaSource();
}
}
return null;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:10,代码来源:MediaEntry.java
示例9: getContentHandlerInfo
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
@Override
protected Content.ChildHandlerInfo getContentHandlerInfo(
ExtensionProfile extProfile, Attributes attrs)
throws ParseException, IOException {
// Use the extended child handler that supports out-of-line media content.
return MediaContent.getChildHandler(extProfile, attrs);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:8,代码来源:MediaEntry.java
示例10: syncAchievementToPicasa
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public ParameterAchievementParser syncAchievementToPicasa(ParameterAchievementParser achievement) {
log.info("Sync achievement '" + achievement.getId() + "'");
if(!QuizConstant.YES.equals(achievement.getIsProcessed())) {
try {
GphotoEntry achievementTopic = albumMapByTopicId.get(QuizParserConstant.ACHIEVEMENT_NAME);
// Check image file is valid or not
java.nio.file.Path achievementImagePath = FileUtils.getPath(settings.getSyncDataFolder(), achievementTopic.getTitle().getPlainText(), achievement.getImageUrl());
if(!achievementImagePath.toFile().exists()) {
log.error("File is not found at '" + achievementImagePath.toString() + "'. Please put the file and start this app again.");
System.exit(1);
}
// Check image at picasa
Map<String, GphotoEntry> photoEntryCollections = photoMapByAlbumId.get(achievementTopic.getId());
GphotoEntry photoEntry = photoEntryCollections != null ? photoEntryCollections.get(achievement.getImageUrl()) : null;
if(photoEntryCollections == null) photoEntryCollections = new HashMap<String, GphotoEntry>();
photoEntry = (GphotoEntry) webClient.uploadImageToAlbum(achievementImagePath.toFile(), photoEntry, achievementTopic, MD5Checksum.getMD5Checksum(achievementImagePath.toString()));
photoEntryCollections.put(((MediaContent)photoEntry.getContent()).getUri(), photoEntry);
photoMapByAlbumId.put(achievementTopic.getId(), photoEntryCollections);
achievement.setImagePicasaUrl( ((MediaContent)photoEntry.getContent()).getUri() );
achievement.setPicasaId( photoEntry.getGphotoId() );
} catch (Exception e) {
e.printStackTrace();
}
} else {
if(StringUtils.hasValue(achievement.getImagePicasaUrl())) {
FileUtils.downloadFileToLocal(achievement.getImagePicasaUrl(), Paths.get(settings.getSyncDataFolder(), QuizParserConstant.ACHIEVEMENT_NAME, achievement.getImageUrl()).toString(), settings.getReplaced());
}
}
return achievement;
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:37,代码来源:OldApp.java
示例11: exportURL
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private String exportURL(String title) throws IOException, ServiceException, MalformedURLException {
DocumentQuery query = documentQuery(title);
List<DocumentListEntry> entries = service.getFeed(query, DocumentListFeed.class).getEntries();
if (entries.isEmpty()) {
throw new GoogleDocumentNotFound(title);
}
return ((MediaContent) entries.get(0).getContent()).getUri() + "&exportFormat=odt";
}
开发者ID:vactowb,项目名称:jbehave-core,代码行数:9,代码来源:LoadOdtFromGoogle.java
示例12: shouldGetResourceFromDocsService
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
@Test
public void shouldGetResourceFromDocsService() throws IOException, ServiceException {
DocsService service = mock(DocsService.class);
DocumentListFeed feed = mock(DocumentListFeed.class);
DocumentListEntry entry = mock(DocumentListEntry.class);
MediaSource mediaSource = mock(MediaSource.class);
InputStream inputStream = mock(InputStream.class);
final MediaContent content = mock(MediaContent.class);
final DocumentQuery query = mock(DocumentQuery.class);
when(service.getFeed(query, DocumentListFeed.class)).thenReturn(feed);
when(service.getMedia(content)).thenReturn(mediaSource);
when(feed.getEntries()).thenReturn(asList(entry));
when(entry.getContent()).thenReturn(content);
when(content.getUri()).thenReturn("http://docs.google.com");
when(mediaSource.getInputStream()).thenReturn(inputStream);
LoadOdtFromGoogle storyLoader = new LoadOdtFromGoogle("user", "password", "https://docs.google.com/feeds/default/private/full/", service){
@Override
DocumentQuery documentQuery(String title) throws MalformedURLException {
return query;
}
@Override
protected MediaContent mediaContent(String url) {
return content;
}
};
InputStream resourceStream = storyLoader.resourceAsStream("a_story");
MatcherAssert.assertThat(resourceStream, Matchers.equalTo(inputStream));
}
开发者ID:vactowb,项目名称:jbehave-core,代码行数:33,代码来源:GoogleOdtLoaderBehaviour.java
示例13: execute
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public void execute(GttService service, String[] args)
throws IOException, ServiceException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
String id = parser.getValue("id");
URL feedUrl = FeedUris.getTranslationMemoryFeedUrl(id);
TranslationMemoryEntry requestEntry = service.getEntry(feedUrl,
TranslationMemoryEntry.class);
System.out.println("You want to update translation memory with id:"
+ id + " ...");
if (parser.containsKey("title")) {
String title = parser.getValue("title");
System.out.println("...by changing title to " + title);
requestEntry.setTitle(new PlainTextConstruct(title));
}
if (parser.containsKey("file")) {
String filename = parser.getValue("file");
System.out.println("...by appending contents from file " + filename);
File file = new File(filename);
String mimeType = "text/xml";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
requestEntry.setContent(content);
}
System.out.print("Updating translation memory....");
System.out.flush();
TranslationMemoryEntry resultEntry = null;
if (requestEntry.getContent() == null) {
resultEntry = service.update(feedUrl, requestEntry);
} else {
resultEntry = service.updateMedia(feedUrl, requestEntry);
}
printResults(resultEntry);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:46,代码来源:UpdateTranslationMemoryCommand.java
示例14: execute
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public void execute(GttService service, String[] args)
throws IOException, ServiceException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
String id = parser.getValue("id");
URL feedUrl = FeedUris.getGlossaryFeedUrl(id);
GlossaryEntry requestEntry = service.getEntry(feedUrl, GlossaryEntry.class);
System.out.println("You want to update glossary with id:" + id + " ...");
if (parser.containsKey("title")) {
String title = parser.getValue("title");
System.out.println("...by changing title to " + title);
requestEntry.setTitle(new PlainTextConstruct(title));
}
if (parser.containsKey("file")) {
String filename = parser.getValue("file");
System.out.println("...by appending contents from file " + filename);
File file = new File(filename);
String mimeType = "text/csv";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
requestEntry.setContent(content);
}
System.out.print("Updating glossaries....");
System.out.flush();
GlossaryEntry resultEntry = null;
if (requestEntry.getContent() == null) {
resultEntry = service.update(feedUrl, requestEntry);
} else {
resultEntry = service.updateMedia(feedUrl, requestEntry);
}
printResults(resultEntry);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:43,代码来源:UpdateGlossaryCommand.java
示例15: syncTopicToPicasa
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
public DataTopicsParser syncTopicToPicasa(DataTopicsParser topic) {
log.info("Sync Topics '" + topic.getId() + "'");
try {
GphotoEntry albumEntry;
if(albumMapByTitle.containsKey(topic.getId())) {
albumEntry = albumMapByTitle.get(topic.getId());
} else {
// Upload photo as QuestionAnswer
AlbumEntry myAlbum = new AlbumEntry();
myAlbum.setAccess(GphotoAccess.Value.PUBLIC);
myAlbum.setTitle(new PlainTextConstruct(topic.getId()));
myAlbum.setDescription(new PlainTextConstruct(topic.getDescription()));
albumEntry = (GphotoEntry) webClient.insertAlbum(myAlbum);
}
if(!QuizConstant.YES.equals(topic.getIsProcessed())) {
Map<String, GphotoEntry> photoEntryCollections = (Map<String, GphotoEntry>) photoMapByAlbumId.get(albumEntry.getId());
GphotoEntry photoEntry = photoEntryCollections != null ? photoEntryCollections.get(topic.getImageUrl()) : null;
if(photoEntryCollections == null) photoEntryCollections = new HashMap<String, GphotoEntry>();
// Upload album as topic
// log.info("there is no image '"+ topic.getImageUrl() +"' at '" + topic.getId() + "'. Wait for uploading...");
java.nio.file.Path topicImagePath = FileUtils.getPath(settings.getSyncDataFolder(), topic.getId(), topic.getImageUrl());
if(topicImagePath.getParent().toFile().exists()) {
if(!topicImagePath.toFile().exists()) {
log.error("File is not found at '" + topicImagePath.toString() + "'. Please put the file and start this app again.");
System.exit(1);
}
photoEntry = (GphotoEntry) webClient.uploadImageToAlbum(topicImagePath.toFile(), photoEntry, albumEntry, MD5Checksum.getMD5Checksum(topicImagePath.toString()));
photoEntryCollections.put(((MediaContent)photoEntry.getContent()).getUri(), photoEntry);
photoMapByAlbumId.put(albumEntry.getId(), photoEntryCollections);
topic.setImagePicasaUrl( ((MediaContent)photoEntry.getContent()).getUri() );
topic.setPicasaId(albumEntry.getGphotoId());
}
} else {
if(StringUtils.hasValue(topic.getImagePicasaUrl())) {
FileUtils.downloadFileToLocal(topic.getImagePicasaUrl(), Paths.get(settings.getSyncDataFolder(), topic.getId(), topic.getImageUrl()).toString(), settings.getReplaced());
}
}
albumMapByTopicId.put(topic.getId(), albumEntry);
} catch (Exception e) {
e.printStackTrace();
}
return topic;
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:48,代码来源:OldApp.java
示例16: mediaContent
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
MediaContent mediaContent(String url) {
MediaContent mc = new MediaContent();
mc.setUri(url);
return mc;
}
开发者ID:vactowb,项目名称:jbehave-core,代码行数:6,代码来源:LoadOdtFromGoogle.java
示例17: getDocument
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private void getDocument(NodeRef nodeRef, String resourceID)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException
{
log.debug("Get Google Document for node: " + nodeRef);
DocsService docsService = getDocsService(getConnection());
try
{
MediaContent mc = new MediaContent();
String mimeType = null;
String exportFormat = null;
mimeType = validateMimeType(fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype());
log.debug("Current mimetype: " + fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype()
+ "; Mimetype of Google Doc: " + mimeType);
exportFormat = getExportFormat(getContentType(nodeRef), mimeType);
log.debug("Export format: " + exportFormat);
mc.setUri(GoogleDocsConstants.URL_DOCUMENT_DOWNLOAD + "?id=" + resourceID.substring(resourceID.lastIndexOf(':') + 1)
+ "&exportFormat=" + exportFormat);
log.debug("Export URL: " + mc.getUri());
MediaSource ms = docsService.getMedia(mc);
ContentWriter writer = fileFolderService.getWriter(nodeRef);
writer.setMimetype(mimeType);
writer.putContent(ms.getInputStream());
DocumentListEntry documentListEntry = getDocumentListEntry(resourceID);
renameNode(nodeRef, documentListEntry.getTitle().getPlainText());
deleteContent(nodeRef, documentListEntry);
postActivity(nodeRef);
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
{
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
log.debug("Temporary Aspect Removed");
}
}
catch (IOException ioe)
{
throw ioe;
}
catch (ServiceException se)
{
throw new GoogleDocsServiceException(se.getMessage(), se.getHttpErrorCodeOverride());
}
catch (JSONException jsonException)
{
throw new GoogleDocsAuthenticationException("Unable to create activity entry: " + jsonException.getMessage(), jsonException);
}
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:60,代码来源:GoogleDocsServiceImpl.java
示例18: getSpreadSheet
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private void getSpreadSheet(NodeRef nodeRef, String resourceID)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException
{
log.debug("Get Google Spreadsheet for node: " + nodeRef);
DocsService docsService = getDocsService(getConnection());
try
{
MediaContent mc = new MediaContent();
String mimeType = null;
String exportFormat = null;
mimeType = validateMimeType(fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype());
log.debug("Current mimetype: " + fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype()
+ "; Mimetype of Google Doc: " + mimeType);
exportFormat = getExportFormat(getContentType(nodeRef), mimeType);
log.debug("Export format: " + exportFormat);
mc.setUri(GoogleDocsConstants.URL_SPREADSHEET_DOWNLOAD + "?key="
+ resourceID.substring(resourceID.lastIndexOf(':') + 1) + "&exportFormat=" + exportFormat);
log.debug("Export URL: " + mc.getUri());
MediaSource ms = docsService.getMedia(mc);
ContentWriter writer = fileFolderService.getWriter(nodeRef);
writer.setMimetype(mimeType);
writer.putContent(ms.getInputStream());
DocumentListEntry documentListEntry = getDocumentListEntry(resourceID);
renameNode(nodeRef, documentListEntry.getTitle().getPlainText());
deleteContent(nodeRef, documentListEntry);
postActivity(nodeRef);
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
{
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
log.debug("Temporary Aspect Removed");
}
}
catch (IOException ioe)
{
throw ioe;
}
catch (ServiceException se)
{
throw new GoogleDocsServiceException(se.getMessage(), se.getHttpErrorCodeOverride());
}
catch (JSONException jsonException)
{
throw new GoogleDocsAuthenticationException("Unable to create activity entry: " + jsonException.getMessage(), jsonException);
}
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:60,代码来源:GoogleDocsServiceImpl.java
示例19: getPresentation
import com.google.gdata.data.MediaContent; //导入依赖的package包/类
private void getPresentation(NodeRef nodeRef, String resourceID)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException
{
log.debug("Get Google Presentation for node: " + nodeRef);
DocsService docsService = getDocsService(getConnection());
try
{
MediaContent mc = new MediaContent();
String mimeType = null;
String exportFormat = null;
mimeType = validateMimeType(fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype());
log.debug("Current mimetype: " + fileFolderService.getFileInfo(nodeRef).getContentData().getMimetype()
+ "; Mimetype of Google Doc: " + mimeType);
exportFormat = getExportFormat(getContentType(nodeRef), mimeType);
log.debug("Export format: " + exportFormat);
mc.setUri(GoogleDocsConstants.URL_PRESENTATION_DOWNLOAD + "?id="
+ resourceID.substring(resourceID.lastIndexOf(':') + 1) + "&exportFormat=" + exportFormat);
log.debug("Export URL: " + mc.getUri());
MediaSource ms = docsService.getMedia(mc);
ContentWriter writer = fileFolderService.getWriter(nodeRef);
writer.setMimetype(mimeType);
writer.putContent(ms.getInputStream());
DocumentListEntry documentListEntry = getDocumentListEntry(resourceID);
renameNode(nodeRef, documentListEntry.getTitle().getPlainText());
deleteContent(nodeRef, documentListEntry);
postActivity(nodeRef);
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
{
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
log.debug("Temporary Aspect Removed");
}
}
catch (IOException ioe)
{
throw ioe;
}
catch (ServiceException se)
{
throw new GoogleDocsServiceException(se.getMessage(), se.getHttpErrorCodeOverride());
}
catch (JSONException jsonException)
{
throw new GoogleDocsAuthenticationException("Unable to create activity entry: " + jsonException.getMessage(), jsonException);
}
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:60,代码来源:GoogleDocsServiceImpl.java
注:本文中的com.google.gdata.data.MediaContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论