Google Doc Integration

- improved logging



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20062 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-04-30 14:08:44 +00:00
parent 3a8e5b4cfe
commit f827a88a31

View File

@@ -475,9 +475,10 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
/** /**
* Sets the resource details on the node reference
* *
* @param nodeRef * @param nodeRef node reference
* @param folderId * @param documentListEntry document list entry
*/ */
private void setResourceDetails(final NodeRef nodeRef, final DocumentListEntry documentListEntry) private void setResourceDetails(final NodeRef nodeRef, final DocumentListEntry documentListEntry)
{ {
@@ -601,9 +602,11 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
/** /**
* Gets the document list entry that corresponds to the google resource
* related to the node reference provided.
* *
* @param docNodeRef * @param docNodeRef node reference
* @return * @return DocumentListEntry document list entry
*/ */
private DocumentListEntry getDocumentListEntry(NodeRef docNodeRef) private DocumentListEntry getDocumentListEntry(NodeRef docNodeRef)
{ {
@@ -613,9 +616,10 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
/** /**
* Gets the document resource entry for a document resource id
* *
* @param docResourceId * @param docResourceId document resource id
* @return * @return DocumentListEntry document list entry
*/ */
private DocumentListEntry getDocumentListEntry(String docResourceId) private DocumentListEntry getDocumentListEntry(String docResourceId)
{ {
@@ -623,11 +627,12 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
/** /**
* Gets the entry for a given resource id.
* *
* @param <E> * @param <E> Entry class
* @param resourceId * @param resourceId resource id
* @param entryClass * @param entryClass entry class
* @return * @return E entry instance
*/ */
private <E extends IEntry> E getEntry(String resourceId, Class<E> entryClass) private <E extends IEntry> E getEntry(String resourceId, Class<E> entryClass)
{ {
@@ -661,6 +666,12 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
{ {
DocumentListEntry document = null; DocumentListEntry document = null;
// Log details
if (logger.isDebugEnabled() == true)
{
logger.debug("Creating google document with name " + name);
}
try try
{ {
// Create the media content object // Create the media content object
@@ -700,10 +711,24 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
catch (IOException e) catch (IOException e)
{ {
// Log details of exception
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to create google document with name " + name + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to create google document", e); throw new AlfrescoRuntimeException("Unable to create google document", e);
} }
catch (ServiceException e) catch (ServiceException e)
{ {
// Log details of exception
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to create google document with name " + name + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to create google document", e); throw new AlfrescoRuntimeException("Unable to create google document", e);
} }
@@ -718,7 +743,13 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
* @param is input stream * @param is input stream
*/ */
private void updateGoogleDocContent(DocumentListEntry document, String mimeType, InputStream is) private void updateGoogleDocContent(DocumentListEntry document, String mimeType, InputStream is)
{ {
// Log details
if (logger.isDebugEnabled() == true)
{
logger.debug("Updating content of document " + document.getResourceId());
}
try try
{ {
// Update the existing content // Update the existing content
@@ -729,19 +760,34 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
catch (ServiceException e) catch (ServiceException e)
{ {
// Log details of the error
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to update the content of document " + document.getResourceId() + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to update documents content in google docs", e); throw new AlfrescoRuntimeException("Unable to update documents content in google docs", e);
} }
catch (IOException e) catch (IOException e)
{ {
// Log details of the error
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to update the content of document " + document.getResourceId() + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to update documents content in google docs", e); throw new AlfrescoRuntimeException("Unable to update documents content in google docs", e);
} }
} }
/** /**
* Creates a google folder, returning the folder resource.
* *
* @param folderName * @param folderName folder name
* @param parentFolderId * @param parentFolder parent folder resource
* @return * @return DocumentListEntry created folder resource
*/ */
private DocumentListEntry createGoogleFolder(String folderName, DocumentListEntry parentFolder) private DocumentListEntry createGoogleFolder(String folderName, DocumentListEntry parentFolder)
{ {
@@ -749,6 +795,12 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
try try
{ {
// Log details
if (logger.isDebugEnabled() == true)
{
logger.debug("Creating folder " + folderName);
}
// Parent folder url // Parent folder url
String parentFolderUrl = url; String parentFolderUrl = url;
if (parentFolder != null) if (parentFolder != null)
@@ -767,10 +819,24 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
} }
catch (IOException e) catch (IOException e)
{ {
// Log details of the failure
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to create folder " + folderName + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to create Google Folder", e); throw new AlfrescoRuntimeException("Unable to create Google Folder", e);
} }
catch (ServiceException e) catch (ServiceException e)
{ {
// Log details of the failure
if (logger.isDebugEnabled() == true)
{
logger.debug("Unable to create folder " + folderName + ", because " + e.getMessage());
}
// Rethrow as runtime exception
throw new AlfrescoRuntimeException("Unable to create Google Folder", e); throw new AlfrescoRuntimeException("Unable to create Google Folder", e);
} }
@@ -786,11 +852,12 @@ public class GoogleDocsServiceImpl implements GoogleDocsService, GoogleDocsModel
*/ */
private void setGoogleResourcePermission(DocumentListEntry resource, String email, String role) private void setGoogleResourcePermission(DocumentListEntry resource, String email, String role)
{ {
// Check mandatory parameters have been set
ParameterCheck.mandatory("resource", resource); ParameterCheck.mandatory("resource", resource);
ParameterCheck.mandatory("email", email); ParameterCheck.mandatory("email", email);
ParameterCheck.mandatory("role", role); ParameterCheck.mandatory("role", role);
// Log details of failure // Log details
if (logger.isDebugEnabled() == true) if (logger.isDebugEnabled() == true)
{ {
logger.debug("Setting the role " + role + " on the google resource " + resource.getResourceId() + " for email " + email + "."); logger.debug("Setting the role " + role + " on the google resource " + resource.getResourceId() + " for email " + email + ".");