From 017af1a65c317b0875ddb88492f478614155d28d Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 22 Jul 2014 16:13:06 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 76635: Merged EOL2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 76545: ACE-2016: EOL Google Docs v1 in 5.0 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77670 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/bootstrap-context.xml | 9 - config/alfresco/slingshot-context.xml | 5 - .../googledocs/default/googledocs-context.xml | 45 - .../googledocs/default/googledocs-model.xml | 71 - .../googledocs/default/googledocs.properties | 18 - .../subsystems/googledocs/default/test.docx | Bin 10060 -> 0 bytes .../subsystems/googledocs/default/test.xlsx | Bin 8276 -> 0 bytes .../googledocs/default/testBook.xls | Bin 16896 -> 0 bytes .../templates/following-email-templates.xml | 2 +- .../templates/invite-email-templates.xml | 14 +- .../alfresco/templates/new-user-templates.xml | 14 +- .../templates/notify_email_templates.xml | 14 +- .../repo/googledocs/GoogleDocsModel.java | 37 - .../GoogleDocsPermissionContext.java | 30 - .../repo/googledocs/GoogleDocsService.java | 78 - .../googledocs/GoogleDocsServiceImpl.java | 1347 ----------------- .../GoogleDocsServiceInitException.java | 48 - .../repo/googledocs/GoogleEditableAspect.java | 294 ---- ...oolgeDocsUnsupportedMimetypeException.java | 75 - .../jscript/app/GoogleDocsCustomResponse.java | 76 - .../GoogleDocumentServiceSystemTest.java | 371 ----- 21 files changed, 22 insertions(+), 2526 deletions(-) delete mode 100755 config/alfresco/subsystems/googledocs/default/googledocs-context.xml delete mode 100755 config/alfresco/subsystems/googledocs/default/googledocs-model.xml delete mode 100755 config/alfresco/subsystems/googledocs/default/googledocs.properties delete mode 100755 config/alfresco/subsystems/googledocs/default/test.docx delete mode 100644 config/alfresco/subsystems/googledocs/default/test.xlsx delete mode 100644 config/alfresco/subsystems/googledocs/default/testBook.xls delete mode 100755 source/java/org/alfresco/repo/googledocs/GoogleDocsModel.java delete mode 100644 source/java/org/alfresco/repo/googledocs/GoogleDocsPermissionContext.java delete mode 100755 source/java/org/alfresco/repo/googledocs/GoogleDocsService.java delete mode 100755 source/java/org/alfresco/repo/googledocs/GoogleDocsServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/googledocs/GoogleDocsServiceInitException.java delete mode 100755 source/java/org/alfresco/repo/googledocs/GoogleEditableAspect.java delete mode 100644 source/java/org/alfresco/repo/googledocs/GoolgeDocsUnsupportedMimetypeException.java delete mode 100644 source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java delete mode 100644 source/test-java/org/alfresco/repo/googledocs/GoogleDocumentServiceSystemTest.java diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 0ac2642858..deca0b7235 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -575,15 +575,6 @@ true - - - diff --git a/config/alfresco/slingshot-context.xml b/config/alfresco/slingshot-context.xml index 274be16aba..c0280730b8 100644 --- a/config/alfresco/slingshot-context.xml +++ b/config/alfresco/slingshot-context.xml @@ -41,8 +41,6 @@ - - slingshotDocLib @@ -52,9 +50,6 @@ - - - diff --git a/config/alfresco/subsystems/googledocs/default/googledocs-context.xml b/config/alfresco/subsystems/googledocs/default/googledocs-context.xml deleted file mode 100755 index 05ffc3a7f8..0000000000 --- a/config/alfresco/subsystems/googledocs/default/googledocs-context.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - alfresco/subsystems/googledocs/default/googledocs-model.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/alfresco/subsystems/googledocs/default/googledocs-model.xml b/config/alfresco/subsystems/googledocs/default/googledocs-model.xml deleted file mode 100755 index d8b650348e..0000000000 --- a/config/alfresco/subsystems/googledocs/default/googledocs-model.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Google Docs Model - unknown - 1.0 - - - - - - - - - - - - - - - - Google Editable - - - Property who's only purpose is to allow the marker aspect to be automatically added. - d:boolean - true - true - - - - - - Google Document - - - GoogleDocs URL - d:text - false - - - GoogleDocs id - d:text - false - - - GoogleDocs Type - d:text - false - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/subsystems/googledocs/default/googledocs.properties b/config/alfresco/subsystems/googledocs/default/googledocs.properties deleted file mode 100755 index fcafc00d4d..0000000000 --- a/config/alfresco/subsystems/googledocs/default/googledocs.properties +++ /dev/null @@ -1,18 +0,0 @@ - -# Enables GoogleDocsV1 functionality -googledocs.googleeditable.enabled=false - -# Google docs application name -googledocs.application.name=Alfresco ECM system - -# Google docs URL -googledocs.url=https://docs.google.com/feeds/default/private/full -googledocs.downloadurl=https://docs.google.com/feeds/download - -# System google docs authentication credentials -googledocs.username= -googledocs.password= - -# Google docs spreadsheet service name -googledocs.spreadsheet.service.name=wise -googledocs.spreadsheet.downloadurl=https://spreadsheet.google.com/feeds/download \ No newline at end of file diff --git a/config/alfresco/subsystems/googledocs/default/test.docx b/config/alfresco/subsystems/googledocs/default/test.docx deleted file mode 100755 index e04a931e44464c0cb05a15104cefa28b0641c4c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10060 zcmeHNWmH_rwr<=txVr^+4;oy8TX1Wvad!yrBqV6i1a}SY?(P~O1b63ka__v!WM;kf z{@;6k)Tv(G-|nhi+jl9;K|x~yU;*#|0Dv5@eE*Ke90C9!g8=}Z0pKBZ#X)w?W_Hd7 zY997xPOq8WZEeW1p&{uq0g&L||M&S1=0LUDpj`(mdXwhf3yBtu@T}0nLU^KE-dgEA zQp0@|tqZx!)7v{cNC|Z$QHHOW^x8*5`}Qey1W~WDVNK1a z$v6>Dp!6HwlZn6PQ!M}PMQNR_5f?4lrD-GsYjBfaf9hxi49Oc0v>*)y!p!^s0B#9@eI|F~C2-ZF%uzDIen%Ow9F#j0;tCs)4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Lve3S^Dqk3@u5%hy{o@_u^#*Di=dGx$(6Wb# zBAR+EQu_&&mwn%L0jcYD-$?0_wp~dwl-Q-7rUNwmNY?8QP@>%xB#ZMIXKZL4S%um7 zk04#;^(wwIocE(d#7yRAXE0HH*N`-+iW1=`6zmpx{AqNx9e2wzuUFj|gZ4e80lAMmrBduZJ9(@Yhp2Ml1+R0i4!6;U#lHeO!QTG= z>K*@1>G$5@pR}I9cdP!^N&FrDd+X;6+|2?Pv6Tge|Z~Si=_U{z_nyCJX2LPtQS^V#5>+k5l<_^E2 u{Rw_S|B*@j4*xxl`;!0%@gLm#->6Pm4hAe9KQ7@Q0ouX2iVM|`PyYidh;ShQ diff --git a/config/alfresco/subsystems/googledocs/default/test.xlsx b/config/alfresco/subsystems/googledocs/default/test.xlsx deleted file mode 100644 index 64d4a40495241a4468235908ace7b7852444b74f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8276 zcmeHMby!sE_MQQWAtWRe7`jtJKtWoCfuTV{y1P4+9!ijIBqao-JBC(LN?-&L1*E${ zeuL-S>pAFsp8NOxojuRq-!sqN>z&zaz3W@+dp|{4)N4clbO0s*0H6UlT))d^4+H>S zq5%Lm00^MAq@As^iLJAqs)xOalMbi5jWu=l2O#rH01EQ?e~$kx5A?@D|U1X$9SzA?W7Bh^c2vZ$FOO;aM+iX5IU0e3nPBumb zR#)C7H=|2<7B6qn*gv(}C+Rsr7}3sZkQS7-4w&+G_2u`O@@NYz;#hng@&1$j^NK)- z{-UtPiAtSfsC1^m+vaGt@@pcuB1`L>`TZj;Uf-FtK9K_Yt4Fg-!J@Khsaoy`$B4uc2}qwNfvGDBI>7N_^V;3o0zAWY^1kvNCl%{2=#bBw%FM`x}}pfUC2q+_ZMOvG7|hW!>VfQR0uD_dSg< zIx0LP$76p0*r!09QDzb?)vG>Tbex1Pqfm%OpWiAi7UGW)I9y#r1pqECPyvd6%e`u~ z+jRR#LdhXh3mY&9)N?ekcH-i^yi#Ys`zPo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a/config/alfresco/subsystems/googledocs/default/testBook.xls b/config/alfresco/subsystems/googledocs/default/testBook.xls deleted file mode 100644 index 15d493339dbc3334390062fa609379cf9218a706..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16896 zcmeHOdvH|M8UOC?CfN{#1VTWNuqM1oB4h)CJT`#OF+4_buvG^`*oBms&~>9QBSW#1-OY2Z`HIt`5%L<}L8A+pUY5W|R-h@%jz5Jw}PhByXsEFw%mY7oaEjz_FT zoPbz|I1zCY;^~N!5vL&1P8jPg?Cy7h0$IPzQ@K6%#mU8BJ~4LvW$*sln2O|KolQ1^ds4Q`W+lgVYxbhv$4S7T-I_8KQ;4j; z9@RO^V6TlkWey_l9Fz`_xga&27mfM_8-dNlhyX=rEIE9&IN}qB|}`b zKxy(U27j~e#qy`Vsi3z9j+qdFTk9B7a7_Qg+ZcB>Q$< zANhZURZ50VgEAb3tjmpZNEd*fhw-e2U*Q+DKAz*%^AVNzY4u!=FFWzK@v0AJE=CTH zQK$FdP~tQaAOAu)$OoRS*S zHbM?T4*%9SFfQ7)?&QKz(;p*%G15PW0V^DdOQk19eP|MVGsfkH`x+XX8XM;?y|USS ztq)DbD39^kBrLt+lK7UZtQqPt1;F5KW@wpjEss=vs1f2}D7WTtpr~vMWvLj9U+$=y_lW!_6G1O9!{G?&bRmlVL2-0;WVifYbfUWD|0>fB ziLiP)1hk$xYgKx9EK3jFqx4@$|CtB<0T24a9`pkq^hZ4C4|&kP??J!SgYG4d7ycoI z!&$jqKR@uGYk3OuYk3OkKlZ?R)Pw$*2mM(O`nNskPkGQwmFE`8goYKU( z8n0LYY8O0NbRb0yNr^3b0X1DnK(YsQ~*|Nd@RoN-DsfQBnbR zy^;#BFO^h)&ab2b^GYqyRBD0dQVX<{THu^g3oNx2VE?l^0b_S~rNe71K$c+6Yd8x8 z!dZ91j>&m&1fdY5wHT00%pZhXAR|iB8nuHsonRY4@>Wt%okG#E7RYj?cY{C9SQQos zq5k~v{6Bw_@vi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ta(+UZrGl=psx>xy3~$qOwNSl0w}G|VXE8_H?hFX#2SNpURXg~ z81LND-Mck{wSq&?U^O&*Aq1lBcSF#v5KylXlnJ22OuJ~ehNCG~Kr-zJhXP};$gqIJ z_c_69T)?&e^8nApescIvs0hKMR&e-0C-^uQaP0>@!1dH1pupR#;P8bGhY%d^0#1LZ zTdcyWmZ88XS%`*|i+XqT!xZ}MO%|v{eRy+p2W*jzp6_TG?E9OI#>0Wn+5M|AL4sfE z=60^R;I8n(OJWOgp&>f?8Sq%ZpwXpQ0x`0clto9AO z<`=7#xYz}VwSB4hV0g0~BQOg6g%~La#l1$ZdXy;Gs5V_1H<|N}R;NstrcG+3MOSvtKpAv5-7Z2| z85&|e>YU6i{HZdU>Qb8OhVE1kw6(xqDmWI+vjNtTLc>vCh1PBmVwr;IOVI)xdk?|W z6$BNoTR)_X%C^5iy_I)wouA@VNuwgz>lGvw9pCD3BGT&FB3pMyPUD@M^2 zT;(FUT3r#o1+`klBV|~|rQ721)B;l0@38_O}_BSAV!FI3Z%c^$_IRM%L3yosl2HI^F8Uc70Lf;y%w%r=93e@tm z3OsS@z|qYy#M5A6?2-W}e5`t}!IS?z5|&SX`u^|MY+fJRr08=MeV%&Wq$mT(V}=>% z2qI0!jrejTL|zjRzol~Dte!KGJE6j{*euKY>>SFwu{oCad$Cp^q5=5~sFqrYs_^@m z`P#2G&tGSUA9AAHFx~wl~HKX-rsYpDNwz|E&?x zDFZrVKAj3E4VtMSQZNH~2G?+zhZi>f72{Ld`3$RPb$d`=g#7ya!j}!aU9|{M9x135V7lv361{$(C^}xw)Qp(@mQH<_)lf{ zaZPjFSkv8=?7Oxvk&2wRvn$@Ccn%UeMAlswORq<%1;$ yzX{^0@P%l=$nLrAz-o50e4}I@{0~g4S1bmA{U=#W#v=2S%D+h1qO+aM{Qn0~^G109 diff --git a/config/alfresco/templates/following-email-templates.xml b/config/alfresco/templates/following-email-templates.xml index 7fe18b5870..2890f12552 100644 --- a/config/alfresco/templates/following-email-templates.xml +++ b/config/alfresco/templates/following-email-templates.xml @@ -1,7 +1,7 @@ - + ${spaces.templates.email.following.name} ${spaces.templates.email.following.name} diff --git a/config/alfresco/templates/invite-email-templates.xml b/config/alfresco/templates/invite-email-templates.xml index 89c8719290..ccc6afaa37 100644 --- a/config/alfresco/templates/invite-email-templates.xml +++ b/config/alfresco/templates/invite-email-templates.xml @@ -3,7 +3,7 @@ /app:company_home/app:dictionary/app:email_templates/cm:invite - + @@ -19,7 +19,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/config/alfresco/templates/new-user-templates.xml b/config/alfresco/templates/new-user-templates.xml index 2bd4c2217b..238e0b05da 100644 --- a/config/alfresco/templates/new-user-templates.xml +++ b/config/alfresco/templates/new-user-templates.xml @@ -3,7 +3,7 @@ /app:company_home/app:dictionary/app:email_templates/cm:invite - + @@ -19,7 +19,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/config/alfresco/templates/notify_email_templates.xml b/config/alfresco/templates/notify_email_templates.xml index bae5de53d2..83f0799ca5 100644 --- a/config/alfresco/templates/notify_email_templates.xml +++ b/config/alfresco/templates/notify_email_templates.xml @@ -1,6 +1,6 @@ - + @@ -15,7 +15,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/source/java/org/alfresco/repo/googledocs/GoogleDocsModel.java b/source/java/org/alfresco/repo/googledocs/GoogleDocsModel.java deleted file mode 100755 index bd13306260..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleDocsModel.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -import org.alfresco.service.namespace.QName; - -/** - * Google docs model constants - */ -public interface GoogleDocsModel -{ - static final String GOOGLE_DOCS_PREFIX = "gd"; - static final String GOOGLE_DOCS_MODEL_1_0_URI = "http://www.alfresco.org/model/googledocs/1.0"; - - static final QName ASPECT_GOOGLEEDITABLE = QName.createQName(GOOGLE_DOCS_MODEL_1_0_URI, "googleEditable"); - - static final QName ASPECT_GOOGLERESOURCE = QName.createQName(GOOGLE_DOCS_MODEL_1_0_URI, "googleResource"); - static final QName PROP_URL = QName.createQName(GOOGLE_DOCS_MODEL_1_0_URI, "url"); - static final QName PROP_RESOURCE_ID = QName.createQName(GOOGLE_DOCS_MODEL_1_0_URI, "resourceId"); - static final QName PROP_RESOURCE_TYPE = QName.createQName(GOOGLE_DOCS_MODEL_1_0_URI, "resourceType"); -} diff --git a/source/java/org/alfresco/repo/googledocs/GoogleDocsPermissionContext.java b/source/java/org/alfresco/repo/googledocs/GoogleDocsPermissionContext.java deleted file mode 100644 index d5e13def06..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleDocsPermissionContext.java +++ /dev/null @@ -1,30 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -/** - * Google docs permission context - */ -public enum GoogleDocsPermissionContext -{ - PRIVATE, - SHARE_READ, - SHARE_WRITE, - SHARE_READWRITE -} diff --git a/source/java/org/alfresco/repo/googledocs/GoogleDocsService.java b/source/java/org/alfresco/repo/googledocs/GoogleDocsService.java deleted file mode 100755 index 12b473aac0..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleDocsService.java +++ /dev/null @@ -1,78 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -import java.io.InputStream; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Google docs integration service interface - */ -public interface GoogleDocsService -{ - /** - * Indicates whether the GoogleDocs service is enabled or not. - * @return boolean true if enabled, false otherwise - */ - boolean isEnabled(); - - /** - * Indicates whether the mimetype is supported for creation in google docs. - * - * NOTE: This method presumes that the account being used is not for a "premium" customer - * - * @param mimetype mimetype - * @return boolean true if mimetype is supported, false otherwise - */ - boolean isSupportedMimetype(String mimetype); - - /** - * Create a google doc from a given node. The content of the node will be used - * as a basis of the associated google doc. If the node has no content a new, empty google - * doc of the correct type will be created. - * - * The permission context provides information about how google sharing permissions should be - * set on the created google doc. - * - * @param nodeRef node reference - * @param permissionContext permission context - * @throws GoogleDocsUnsupportedMimetypeException - */ - void createGoogleDoc(NodeRef nodeRef, GoogleDocsPermissionContext permissionContext); - - /** - * Deletes the google resource associated with the node reference. This could be a folder or - * document. - * - * @param nodeRef node reference - */ - void deleteGoogleResource(NodeRef nodeRef); - - /** - * Gets the content as an input stream of google doc associated with the given node. The - * node must have the google resource aspect and the associated resource should not be a - * folder. - * - * @param nodeRef node reference - * @return InputStream the content of the associated google doc - */ - InputStream getGoogleDocContent(NodeRef nodeRef); - -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceImpl.java b/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceImpl.java deleted file mode 100755 index c5d27e5c87..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceImpl.java +++ /dev/null @@ -1,1347 +0,0 @@ -/* -* Copyright (C) 2005-2014 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 . -*/ -package org.alfresco.repo.googledocs; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.TransactionListener; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessPermission; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.OwnableService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.google.gdata.client.GoogleAuthTokenFactory.UserToken; -import com.google.gdata.client.docs.DocsService; -import com.google.gdata.client.media.MediaService; -import com.google.gdata.data.IEntry; -import com.google.gdata.data.MediaContent; -import com.google.gdata.data.PlainTextConstruct; -import com.google.gdata.data.acl.AclEntry; -import com.google.gdata.data.acl.AclFeed; -import com.google.gdata.data.acl.AclRole; -import com.google.gdata.data.acl.AclScope; -import com.google.gdata.data.docs.DocumentEntry; -import com.google.gdata.data.docs.DocumentListEntry; -import com.google.gdata.data.docs.FolderEntry; -import com.google.gdata.data.docs.PdfEntry; -import com.google.gdata.data.docs.PresentationEntry; -import com.google.gdata.data.docs.SpreadsheetEntry; -import com.google.gdata.data.docs.DocumentListEntry.MediaType; -import com.google.gdata.data.media.MediaSource; -import com.google.gdata.data.media.MediaStreamSource; -import com.google.gdata.util.AuthenticationException; -import com.google.gdata.util.ContentType; -import com.google.gdata.util.ServiceException; - -/** - * Google docs integration service implementation - */ -public class GoogleDocsServiceImpl extends TransactionListenerAdapter - implements GoogleDocsService, GoogleDocsModel -{ - /** Log */ - private static Log logger = LogFactory.getLog(GoogleDocsServiceImpl.class); - - /** Google document types */ - public static final String TYPE_DOCUMENT = "document"; - public static final String TYPE_SPREADSHEET = "spreadsheet"; - public static final String TYPE_PRESENTATION = "presentation"; - public static final String TYPE_PDF = "pdf"; - - /** Transaction resource keys */ - private final static String KEY_MARKED_CREATE = "google_doc_service.marked_resources"; - private final static String KEY_MARKED_DELETE = "google_doc_service.marked_delete"; - - /** Services */ - private NodeService nodeService; - private ContentService contentService; - private PersonService personService; - private MimetypeService mimetypeService; - private PermissionService permissionService; - private OwnableService ownableService; - private AuthorityService authorityService; - private DictionaryService dictionaryService; - - /** Indicates whether the GDoc integration is enabled or not */ - private boolean enabled = false; - - /** GoogleDoc base feed url */ - private String url = "https://docs.google.com/feeds/default/private/full"; - private String downloadUrl = "https://docs.google.com/feeds/download"; - private String spreadsheetDownloadUrl = "https://spreadsheet.google.com/feeds/download"; - - /** Authentication credentials */ - private String applicationName; - private String spreadSheetServiceName; - private String username; - private String password; - - /** Cached service tokens */ - private Map serviceTokens = new HashMap(2); - - /** Permission map */ - private Map permissionMap; - - // TODO: need a way of indicating if a customer is a premium user or not - - /** - * List of supported GoogleDoc supported mimetypes. - * Taken from list found at http://code.google.com/apis/documents/faq.html#WhatKindOfFilesCanIUpload - * NOTE: this restriction only applies to non-premium users. - */ - // TODO make this list configurable - private List supportedMimetypes = Arrays.asList( - "text/csv", - "text/tab-separated-values", - "text/html", - "application/msword", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "application/x-vnd.oasis.opendocument.spreadsheet", - "application/vnd.oasis.opendocument.text", - "application/rtf", - "application/vnd.sun.xml.writer", - "text/plain", - "application/vnd.ms-excel", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "application/pdf", - "application/vnd.ms-powerpoint", - "image/x-wmf" - ); - - /** - * Get a new instance of the spread sheet service - * - * @return spreadsheet service - */ - public MediaService getSpreadSheetService() - { - if (spreadSheetServiceName == null) - { - throw new GoogleDocsServiceInitException("No Google Docs spreadsheet service has been specified."); - } - - return getMediaService(spreadSheetServiceName); - } - - /** - * Get a new instance of a document service - * - * @return document service - */ - public DocsService getDocumentService() - { - return (DocsService)getMediaService(DocsService.DOCS_SERVICE); - } - - /** - * - * @param serviceName - * @return - */ - public MediaService getMediaService(String serviceName) - { - if (applicationName == null) - { - throw new GoogleDocsServiceInitException("Google Docs service " + serviceName + " could not be initialised, because no Google Doc application name has been specified."); - } - - MediaService service = null; - if (serviceName.equals(DocsService.DOCS_SERVICE) == true) - { - service = new DocsService(applicationName); - } - else - { - service = new MediaService(serviceName, applicationName); - - // MNT-11647: Changes in Google Docs API lead to setting 'Domain: .docs.google.com' cookie. This setting is causing the following exception: - // 'java.lang.IllegalArgumentException: Trying to set foreign cookie'. Operations with spreadsheets cannot be completed - if (serviceName.equals(spreadSheetServiceName) == true) - { - if (logger.isDebugEnabled()) - { - logger.debug("Disabling handling cookies for '" + serviceName + "' Google Docs service"); - } - - service.setHandlesCookies(false); - } - } - service.setChunkedMediaUpload(-1); - - String token = serviceTokens.get(serviceName); - if (token == null) - { - try - { - if (username == null ||username.length() == 0 || password == null) - { - throw new GoogleDocsServiceInitException("No Google Docs credentials found. Please set the Google Docs authentication configuration."); - } - - if (logger.isDebugEnabled() == true) - { - logger.debug("Setting user credentials for GDoc service. (serviceName=" + serviceName + ", userName=" + username + ", password=" + password + ")"); - } - - service.setUserCredentials(username, password); - serviceTokens.put(serviceName, ((UserToken)service.getAuthTokenFactory().getAuthToken()).getValue()); - } - catch (AuthenticationException e) - { - throw new GoogleDocsServiceInitException("Unable to connect to Google Docs. Please check the Google Docs authentication configuration.", e); - } - } - else - { - service.setUserToken(token); - } - - return service; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param personService person service - */ - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - /** - * @param mimetypeService mime type service - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - /** - * @param permissionService permission service - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - /** - * @param ownableService ownable service - */ - public void setOwnableService(OwnableService ownableService) - { - this.ownableService = ownableService; - } - - /** - * @param authorityService authority service - */ - public void setAuthorityService(AuthorityService authorityService) - { - this.authorityService = authorityService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param url root googleDoc URL - */ - public void setUrl(String url) - { - this.url = url; - } - - /** - * @param downloadUrl root download URL - */ - public void setDownloadUrl(String downloadUrl) - { - this.downloadUrl = downloadUrl; - } - - /** - * @param spreadsheetDownloadUrl root spreadsheet download URL - */ - public void setSpreadsheetDownloadUrl(String spreadsheetDownloadUrl) - { - this.spreadsheetDownloadUrl = spreadsheetDownloadUrl; - } - - /** - * @param applicationName GDoc application name - */ - public void setApplicationName(String applicationName) - { - this.applicationName = applicationName; - } - - /** - * @param spreadSheetServiceName GDoc spread sheet service name - */ - public void setSpreadSheetServiceName(String spreadSheetServiceName) - { - this.spreadSheetServiceName = spreadSheetServiceName; - } - - /** - * @param username google service user name - */ - public void setUsername(String username) - { - this.username = username; - updatedAuthenticationCredentials(); - } - - /** - * @param password google service password - */ - public void setPassword(String password) - { - this.password = password; - updatedAuthenticationCredentials(); - } - - /** - * @param permissionMap permission map - */ - public void setPermissionMap(Map permissionMap) - { - this.permissionMap = permissionMap; - } - - /** - * Set whether the service is enabled or not. - * @param enabled true if enabled, false otherwise - */ - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - updatedAuthenticationCredentials(); - } - - /** - * @see org.alfresco.repo.googledocs.GoogleDocsService#isEnabled() - */ - public boolean isEnabled() - { - return enabled; - } - - /** - * @see org.alfresco.repo.googledocs.GoogleDocsService#isSupportedMimetype(java.lang.String) - */ - @Override - public boolean isSupportedMimetype(String mimetype) - { - return supportedMimetypes.contains(mimetype); - } - - /** - * @throws GoogleDocsUnsupportedMimetypeException - * @see org.alfresco.google.docs.GoogleDocsService#upload(org.alfresco.service.cmr.repository.NodeRef) - */ - public void createGoogleDoc(NodeRef nodeRef, GoogleDocsPermissionContext permissionContext) - { - // Check for mandatory parameters - ParameterCheck.mandatory("nodeRef", nodeRef); - - // Get property values - String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - - // TODO should be checking to make sure this doesn't already have an associated google doc - - // Get content reader - String mimetype = null; - InputStream is = null; - ContentReader contentReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - if (contentReader == null) - { - // Determine the mimetype from the file extension only - // (We've no content so we can't include that in our check) - mimetype = mimetypeService.guessMimetype(name); - } - else - { - // Get the mime type and input stream from the content reader - mimetype = contentReader.getMimetype(); - if (contentReader.getSize() != 0) - { - is = contentReader.getContentInputStream(); - } - } - - // Hack to modify the mimetype of ods file so GDoc upload works - if ("application/vnd.oasis.opendocument.spreadsheet".equals(mimetype) == true) - { - mimetype = "application/x-vnd.oasis.opendocument.spreadsheet"; - } - - // Check that we support the mimetype - if (isSupportedMimetype(mimetype) == false) - { - throw new GoolgeDocsUnsupportedMimetypeException(nodeRef, ContentModel.PROP_CONTENT, mimetype); - } - - // Get the parent folder id - DocumentListEntry parentFolder = getParentFolder(nodeRef); - - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating google document (" + name + "," + mimetype + ")"); - } - - // Create the new google document - DocumentListEntry document = createGoogleDocument(name, mimetype, parentFolder, is); - - // Set permissions - setGoogleResourcePermissions(nodeRef, document, permissionContext); - - // Set the google document details - setResourceDetails(nodeRef, document); - } - - /** - * @see org.alfresco.google.docs.GoogleDocsService#deleteGoogleResource(org.alfresco.service.cmr.repository.NodeRef) - */ - public void deleteGoogleResource(NodeRef nodeRef) - { - // Check for mandatory parameters - ParameterCheck.mandatory("nodeRef", nodeRef); - - if (nodeService.hasAspect(nodeRef, ASPECT_GOOGLERESOURCE) == true) - { - // Get the entry - DocumentListEntry entry = getDocumentListEntry(nodeRef); - if (entry != null) - { - // Mark the resource for deletion upon completion of the transaction - markResource(KEY_MARKED_DELETE, entry.getResourceId()); - } - - // Remove the aspect from the node - nodeService.removeAspect(nodeRef, ASPECT_GOOGLERESOURCE); - } - } - - /** - * Set a google permission on a specified resource - * - * @param nodeRef node reference - * @param resource document resource - * @param permissionContext permission context - */ - private void setGoogleResourcePermissions(NodeRef nodeRef, DocumentListEntry resource, GoogleDocsPermissionContext permissionContext) - { - if (GoogleDocsPermissionContext.PRIVATE.equals(permissionContext) == false) - { - Set accessPermissions = permissionService.getAllSetPermissions(nodeRef); - for (AccessPermission accessPermission : accessPermissions) - { - String authorityName = accessPermission.getAuthority(); - AuthorityType authorityType = accessPermission.getAuthorityType(); - String permission = accessPermission.getPermission(); - if (permissionMap.containsKey(permission) == true) - { - String aclRole = permissionMap.get(permission); - if (GoogleDocsPermissionContext.SHARE_READ.equals(permissionContext) == true && - ("reader".equals(aclRole) == true || "writer".equals(aclRole) == true)) - { - // Set the permission to read - setGoogleResourcePermission(resource, authorityType, authorityName, "reader"); - } - else if (GoogleDocsPermissionContext.SHARE_WRITE.equals(permissionContext) == true && - "writer".equals(aclRole) == true) - { - // Set the permission to write - setGoogleResourcePermission(resource, authorityType, authorityName, "writer"); - } - else if (GoogleDocsPermissionContext.SHARE_READWRITE.equals(permissionContext) == true && - ("reader".equals(aclRole) == true || "writer".equals(aclRole) == true)) - { - // Set the permission to the current acl - setGoogleResourcePermission(resource, authorityType, authorityName, aclRole); - } - } - } - } - - // Always make sure the owner has write permissions on the document - String owner = ownableService.getOwner(nodeRef); - setGoogleResourcePermission(resource, AuthorityType.USER, owner, "writer"); - } - - /** - * Set a google permission on a specified resource - * - * @param resource document resource - * @param authorityType authority type - * @param authorityName authority name - * @param role role - */ - private void setGoogleResourcePermission(DocumentListEntry resource, AuthorityType authorityType, String authorityName, String role) - { - if (AuthorityType.USER.equals(authorityType) == true) - { - // Set the user permissions on the resource - String userEMail = getUserEMail(authorityName); - if (userEMail != null && userEMail.length() != 0) - { - setGoogleResourcePermission(resource, userEMail, role); - } - } - else if (AuthorityType.GROUP.equals(authorityType) == true) - { - Set childAuthorities = authorityService.getContainedAuthorities(AuthorityType.USER, authorityName, false); - for (String childAuthority : childAuthorities) - { - setGoogleResourcePermission(resource, AuthorityType.USER, childAuthority, role); - } - } - } - - /** - * Gets the users email used to identify their google account. - * - * @param userName user name - * @return String google account email, null if none - */ - private String getUserEMail(String userName) - { - String email = null; - NodeRef personNodeRef = personService.getPerson(userName); - if (personNodeRef != null) - { - // First see if the google user information has been set - email = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_GOOGLEUSERNAME); - - // If no google user information then default back to the user's email - if (email == null || email.length() == 0) - { - email = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL); - } - } - return email; - } - - /** - * Gets the nodes parent folder google resource. - * - * @param nodeRef node reference - * @return DocumentList Entry folder resource - */ - private DocumentListEntry getParentFolder(final NodeRef nodeRef) - { - DocumentListEntry folder = null; - - NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - if (parentNodeRef != null) - { - if (nodeService.hasAspect(parentNodeRef, ASPECT_GOOGLERESOURCE) == true) - { - String resourceType = (String)nodeService.getProperty(parentNodeRef, PROP_RESOURCE_TYPE); - String resourceId = (String)nodeService.getProperty(parentNodeRef, PROP_RESOURCE_ID); - folder = getDocumentListEntry(resourceType + ":" + resourceId); - - if (logger.isDebugEnabled() == true) - { - logger.debug("Found existing google folder + " + resourceId); - } - } - else - { - // Get the parent folder - DocumentListEntry parentFolder = getParentFolder(parentNodeRef); - - // Determine the name of the new google folder - String name = null; - QName parentNodeType = nodeService.getType(parentNodeRef); - if (dictionaryService.isSubClass(parentNodeType, ContentModel.TYPE_STOREROOT) == true) - { - name = parentNodeRef.getStoreRef().getIdentifier(); - } - else - { - name = (String)nodeService.getProperty(parentNodeRef, ContentModel.PROP_NAME); - } - - // Create the folder and set the meta data in Alfresco - folder = createGoogleFolder(name, parentFolder); - setResourceDetails(parentNodeRef, folder); - } - } - - return folder; - } - - /** - * Sets the resource details on the node reference - * - * @param nodeRef node reference - * @param documentListEntry document list entry - */ - private void setResourceDetails(final NodeRef nodeRef, final DocumentListEntry documentListEntry) - { - AuthenticationUtil.RunAsWork runAsWork = new AuthenticationUtil.RunAsWork() - { - public Object doWork() throws Exception - { - // Create a map of the property values - Map props = new HashMap(1); - props.put(GoogleDocsModel.PROP_RESOURCE_ID, documentListEntry.getDocId()); - props.put(GoogleDocsModel.PROP_RESOURCE_TYPE, documentListEntry.getType()); - props.put(GoogleDocsModel.PROP_URL, documentListEntry.getDocumentLink().getHref()); - - // Add the google resource aspect - nodeService.addAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE, props); - return null; - } - }; - - // Run as admin - AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName()); - } - - /** - * @see org.alfresco.google.docs.GoogleDocsService#getGoogleDocContent(org.alfresco.service.cmr.repository.NodeRef) - */ - public InputStream getGoogleDocContent(NodeRef nodeRef) - { - InputStream result = null; - - // Check for mandatory parameters - ParameterCheck.mandatory("nodeRef", nodeRef); - - try - { - if (nodeService.hasAspect(nodeRef, ASPECT_GOOGLERESOURCE) == true) - { - String downloadUrl = null; - DocumentListEntry document = getDocumentListEntry(nodeRef); - if (document != null) - { - String docType = document.getType(); - - ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); - String fileExtension = mimetypeService.getExtension(contentData.getMimetype()); - - if (docType.equals(TYPE_DOCUMENT) || docType.equals(TYPE_PRESENTATION)) - { - StringBuffer buffer = new StringBuffer(this.downloadUrl); - buffer.append("/"). - append(docType).append("s"). - append("/Export?id=").append(document.getDocId()). - append("&exportFormat=").append(fileExtension); - - downloadUrl = buffer.toString(); - } - else if (docType.equals(TYPE_SPREADSHEET)) - { - StringBuffer buffer = new StringBuffer(spreadsheetDownloadUrl); - buffer.append("/"). - append(docType).append("s"). - append("/Export?key=").append(document.getDocId()). - append("&exportFormat=").append(fileExtension); - - // If exporting to .csv or .tsv, add the gid parameter to specify which sheet to export - if (fileExtension.equals("csv") || fileExtension.equals("tsv")) - { - buffer.append("&gid=0"); // gid=0 will download only the first sheet - } - - downloadUrl = buffer.toString(); - - } - else if (docType.equals(TYPE_PDF)) - { - MediaContent mc = (MediaContent)document.getContent(); - downloadUrl = mc.getUri(); - } - else - { - throw new AlfrescoRuntimeException("Unsupported document type: " + docType); - } - - // Log the download URI - if (logger.isDebugEnabled() == true) - { - logger.debug("Download URL for " + docType + " is " + downloadUrl); - } - - MediaService service = null; - if (docType.equals(TYPE_SPREADSHEET) == true) - { - service = getSpreadSheetService(); - } - else - { - service = getDocumentService(); - } - - MediaContent mc = new MediaContent(); - mc.setUri(downloadUrl); - MediaSource ms = service.getMedia(mc); - - result = ms.getInputStream(); - } - else - { - throw new AlfrescoRuntimeException("Can not download google doc content since no corresponsing google resource could be found"); - } - } - else - { - // error since we are trying to download a non-google resource - throw new AlfrescoRuntimeException("Can not download google doc content since no corresponsing google resource could be found"); - } - } - catch (ServiceException e) - { - throw new AlfrescoRuntimeException("Unable to get google document stream.", e); - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unable to get google document stream.", e); - } - - return result; - } - - /** - * Gets the document list entry that corresponds to the google resource - * related to the node reference provided. - * - * @param docNodeRef node reference - * @return DocumentListEntry document list entry - */ - private DocumentListEntry getDocumentListEntry(NodeRef docNodeRef) - { - DocumentListEntry result = null; - String docType = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_TYPE); - String docId = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_ID); - if (docType != null && docId != null) - { - result = getDocumentListEntry(docType + ":" + docId); - } - return result; - } - - /** - * Gets the document resource entry for a document resource id - * - * @param docResourceId document resource id - * @return DocumentListEntry document list entry - */ - private DocumentListEntry getDocumentListEntry(String docResourceId) - { - return getEntry(docResourceId, DocumentListEntry.class); - } - - /** - * Gets the entry for a given resource id. - * - * @param Entry class - * @param resourceId resource id - * @param entryClass entry class - * @return E entry instance - */ - private E getEntry(String resourceId, Class entryClass) - { - E result = null; - try - { - URL docEntryURL = new URL(url + "/" + resourceId); - result = getDocumentService().getEntry(docEntryURL, entryClass); - } - catch (ServiceException e) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to get document list entry for resource " + resourceId + " because " + e.getMessage()); - } - result = null; - } - catch (IOException e) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to get document list entry for resource " + resourceId + " because " + e.getMessage()); - } - result = null; - } - return result; - } - - /** - * Create a google document - * - * @param name document name - * @param mimetype mime type - * @param parentFolder parent folder resource - * @param is input stream for content - * @return DocumentListEntry resource for created document - */ - private DocumentListEntry createGoogleDocument(String name, String mimetype, DocumentListEntry parentFolder, InputStream is) - { - DocumentListEntry document = null; - - // Log details - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating google document with name " + name); - } - - try - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating media content object for mimetype " + mimetype); - } - - // Create the media content object - MediaContent mediaContent = new MediaContent(); - mediaContent.setMimeType(new ContentType(mimetype)); - - if (is != null) - { - if (logger.isDebugEnabled() == true) - { - logger.debug(" ... input stream has been set"); - } - mediaContent.setMediaSource(new MediaStreamSource(is, mimetype)); - } - - // Parent folder url - String parentFolderUrl = url; - if (parentFolder != null) - { - parentFolderUrl = ((MediaContent)parentFolder.getContent()).getUri(); - if (logger.isDebugEnabled() == true) - { - logger.debug(" ... parent folder URL is " + parentFolderUrl); - } - } - - // Create the document entry object - DocumentListEntry docEntry = null; - if (MediaType.XLS.getMimeType().equals(mimetype) == true || - MediaType.XLSX.getMimeType().equals(mimetype) == true || - MediaType.ODS.getMimeType().equals(mimetype) == true) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating SpreadsheetEntry for mimetype " + mimetype); - } - docEntry = new SpreadsheetEntry(); - } - else if (MediaType.PPS.getMimeType().equals(mimetype) == true || - MediaType.PPT.getMimeType().equals(mimetype) == true) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating PresentationEntry for mimetype " + mimetype); - } - docEntry = new PresentationEntry(); - } - else if (MediaType.PDF.getMimeType().equals(mimetype) == true) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating PdfEntry for mimetype " + mimetype); - } - docEntry = new PdfEntry(); - } - else - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating DocumentEntry for mimetype " + mimetype); - } - docEntry = new DocumentEntry(); - } - - // Set the content and the title of the document - docEntry.setContent(mediaContent); - docEntry.setTitle(new PlainTextConstruct(name)); - - // Upload the document into the parent folder - document = getDocumentService().insert( - new URL(parentFolderUrl), - docEntry); - - // Mark create entry - markResource(KEY_MARKED_CREATE, document.getResourceId()); - } - 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); - } - 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); - } - - return document; - } - - /** - * Updates the content of a google document - * - * @param document document resource - * @param mimeType mimetype - * @param is input stream - */ - @SuppressWarnings("unused") - private void updateGoogleDocContent(DocumentListEntry document, String mimeType, InputStream is) - { - // Log details - if (logger.isDebugEnabled() == true) - { - logger.debug("Updating content of document " + document.getResourceId()); - } - - try - { - // Update the existing content - DocsService service = getDocumentService(); - service.getRequestFactory().setHeader("If-Match", "*"); - document.setMediaSource(new MediaStreamSource(is, mimeType)); - document.updateMedia(false); - } - 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); - } - 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); - } - } - - /** - * Creates a google folder, returning the folder resource. - * - * @param folderName folder name - * @param parentFolder parent folder resource - * @return DocumentListEntry created folder resource - */ - private DocumentListEntry createGoogleFolder(String folderName, DocumentListEntry parentFolder) - { - DocumentListEntry folderEntry = null; - - try - { - // Log details - if (logger.isDebugEnabled() == true) - { - logger.debug("Creating folder " + folderName); - } - - // Parent folder url - String parentFolderUrl = url; - if (parentFolder != null) - { - parentFolderUrl = ((MediaContent)parentFolder.getContent()).getUri(); - } - - // Create the folder entry - FolderEntry folder = new FolderEntry(); - folder.setTitle(new PlainTextConstruct(folderName)); - - // Create the folder - folderEntry = getDocumentService().insert( - new URL(parentFolderUrl), - folder); - - // Mark create entry - markResource(KEY_MARKED_CREATE, folderEntry.getResourceId()); - } - 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); - } - 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); - } - - return folderEntry; - } - - /** - * Set permissions on a googleDoc resource - * - * @param resourceId - * @param email - * @param role - */ - private void setGoogleResourcePermission(DocumentListEntry resource, String email, String role) - { - // Check mandatory parameters have been set - ParameterCheck.mandatory("resource", resource); - ParameterCheck.mandatory("email", email); - ParameterCheck.mandatory("role", role); - - // Log details - if (logger.isDebugEnabled() == true) - { - logger.debug("Setting the role " + role + " on the google resource " + resource.getResourceId() + " for email " + email + "."); - } - - try - { - AclRole aclRole = new AclRole(role); - AclScope scope = new AclScope(AclScope.Type.USER, email); - - // Get the URL - URL aclFeedLinkURL = new URL(resource.getAclFeedLink().getHref()); - - // See if we have already set this permission or not - AclEntry aclEntry = null; - AclFeed aclFeed = getDocumentService().getFeed(aclFeedLinkURL, AclFeed.class); - if (aclFeed != null) - { - List aclEntries = aclFeed.getEntries(); - for (AclEntry tempAclEntry : aclEntries) - { - AclScope tempScope = tempAclEntry.getScope(); - if (tempScope.equals(scope) == true) - { - // Existing ACL entry found - aclEntry = tempAclEntry; - break; - } - } - } - - // Set the permission details - if (aclEntry == null) - { - aclEntry = new AclEntry(); - aclEntry.setRole(aclRole); - aclEntry.setScope(scope); - getDocumentService().insert(aclFeedLinkURL, aclEntry); - } - else - { - // Log details of failure - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to the role " + role + " on the google resource " + resource.getResourceId() + " for email " + email + "." + - " This user already has a role on this document."); - } - } - - // TODO for now we will not 'update' the permissions if they have already been set .... - // - //else - //{ - // AclRole currentAclRole = aclEntry.getRole(); - // if (currentAclRole.toString().equals(aclRole.toString()) == false) - // { - // aclEntry.setRole(aclRole); - // googleDocumentService.update(new URL(aclEntry.getEditLink().getHref()), aclEntry); - // } - //} - } - catch (ServiceException e) - { - // Ignore this exception since we don't want to roll back the entire transaction because - // a single users permissions can not be set. - // It seems the google API will return a server exception if the email does not correspond to - // a google account, so catching this exception in this indiscriminate way is the best thing to - // do for now. - - // Log details of failure - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to the role " + role + " on the google resource " + resource.getResourceId() + " for email " + email + "." + - " Check that this is a valid google account."); - } - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unable to set premissions on google document", e); - } - } - - /** - * Marks a resource as created in this transaction - * - * @param resourceId resource id of created resource - */ - @SuppressWarnings("unchecked") - private void markResource(String key, String resourceId) - { - List resources = (List)AlfrescoTransactionSupport.getResource(key); - if (resources == null) - { - // bind pending rules to the current transaction - resources = new ArrayList(); - AlfrescoTransactionSupport.bindResource(key, resources); - // bind the rule transaction listener - AlfrescoTransactionSupport.bindListener(this); - } - - if (resources.contains(resourceId) == false) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Marking resource " + resourceId + " with key " + key); - } - - resources.add(resourceId); - } - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit() - */ - @SuppressWarnings("unchecked") - @Override - public void afterCommit() - { - List resources = (List)AlfrescoTransactionSupport.getResource(KEY_MARKED_DELETE); - if (resources != null) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Transaction commited, deleting Google resources"); - } - - for (String resourceId : resources) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Deleting resource " + resourceId); - } - - // Delete resource - try - { - DocumentListEntry entry = getDocumentListEntry(resourceId); - if (entry != null) - { - getDocumentService().delete(new URL(entry.getEditLink().getHref() + "?delete=true"), entry.getEtag()); - } - else - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to delete resource " + resourceId + " during commit."); - } - } - } - catch (Throwable e) - { - // Ignore, but log - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to delete resource " + resourceId + " during commit.", e); - } - } - } - } - } - - /** - * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback() - */ - @SuppressWarnings("unchecked") - @Override - public void afterRollback() - { - List resources = (List)AlfrescoTransactionSupport.getResource(KEY_MARKED_CREATE); - if (resources != null) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Transaction rolled back, manually deleting created Google Resources"); - } - - for (String resourceId : resources) - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Deleting created resource " + resourceId); - } - - // Delete resource - try - { - DocumentListEntry entry = getDocumentListEntry(resourceId); - if (entry != null) - { - getDocumentService().delete(new URL(entry.getEditLink().getHref() + "?delete=true"), entry.getEtag()); - } - else - { - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to delete resource " + resourceId + " during rollback."); - } - } - } - catch (Throwable e) - { - // Ignore, but log - if (logger.isDebugEnabled() == true) - { - logger.debug("Unable to delete resource " + resourceId + " during rollback.", e); - } - } - } - } - } - - private TransactionListener validateCredentials = new TransactionListener() - { - - @Override - public void afterCommit() - { - } - - @Override - public void afterRollback() - { - } - - @Override - public void beforeCommit(boolean readOnly) - { - if (enabled == true) - { - if (username == null || username.length() == 0 || password == null) - { - throw new GoogleDocsServiceInitException("No Google Docs credentials found. Please set the Google Docs authentication configuration."); - } - } - } - - @Override - public void beforeCompletion() - { - } - - @Override - public void flush() - { - } - }; - - private void updatedAuthenticationCredentials() - { - // Reset the token map - serviceTokens = new HashMap(2); - if (RetryingTransactionHelper.getActiveUserTransaction() != null) - { - AlfrescoTransactionSupport.bindListener(validateCredentials); - } - } -} diff --git a/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceInitException.java b/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceInitException.java deleted file mode 100644 index 85b1e4c101..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleDocsServiceInitException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -import org.alfresco.error.AlfrescoRuntimeException; - - -/** - * Google docs service initialisation exception class. - */ -public class GoogleDocsServiceInitException extends AlfrescoRuntimeException -{ - /** Serial version UUID */ - private static final long serialVersionUID = -2104024155137888545L; - - /** - * @param message error message - */ - public GoogleDocsServiceInitException(String message) - { - super(message); - } - - /** - * @param message error message - * @param cause causing exception - */ - public GoogleDocsServiceInitException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/source/java/org/alfresco/repo/googledocs/GoogleEditableAspect.java b/source/java/org/alfresco/repo/googledocs/GoogleEditableAspect.java deleted file mode 100755 index 785ddcc536..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoogleEditableAspect.java +++ /dev/null @@ -1,294 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.coci.CheckOutCheckInServicePolicies; -import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.BeforeCheckIn; -import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckIn; -import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut; -import org.alfresco.repo.copy.CopyBehaviourCallback; -import org.alfresco.repo.copy.CopyDetails; -import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; -import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy; -import org.alfresco.repo.policy.BehaviourDefinition; -import org.alfresco.repo.policy.ClassBehaviourBinding; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.springframework.beans.factory.DisposableBean; - -/** - * Behaviour associated with google editable documents - * - */ -public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPolicy, - CheckOutCheckInServicePolicies.OnCheckOut, - CheckOutCheckInServicePolicies.BeforeCheckIn, - CheckOutCheckInServicePolicies.OnCheckIn, - NodeServicePolicies.BeforeDeleteNodePolicy, - DisposableBean -{ - /** Policy component */ - private PolicyComponent policyComponent; - - /** Google docs service */ - private GoogleDocsService googleDocsService; - - /** Node service */ - private NodeService nodeService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Content service */ - private ContentService contentService; - - /** binded behaviours definitions*/ - private Set> behaviours; - - /** - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * @param googleDocsService google docs service - */ - public void setGoogleDocsService(GoogleDocsService googleDocsService) - { - this.googleDocsService = googleDocsService; - } - - /** - * @param nodeService node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dictionaryService dictionary service - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Initialise method - */ - public void init() - { - behaviours = new HashSet>(); - // GoogleEditable resource behaviours - behaviours.add(policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, - GoogleDocsModel.ASPECT_GOOGLEEDITABLE , - new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT))); - behaviours.add(policyComponent.bindClassBehaviour(OnCheckOut.QNAME, - GoogleDocsModel.ASPECT_GOOGLEEDITABLE, - new JavaBehaviour(this, "onCheckOut", NotificationFrequency.FIRST_EVENT))); - - // Google resource behaviours - behaviours.add(policyComponent.bindClassBehaviour(BeforeCheckIn.QNAME, - GoogleDocsModel.ASPECT_GOOGLERESOURCE, - new JavaBehaviour(this, "beforeCheckIn", NotificationFrequency.FIRST_EVENT))); - behaviours.add(policyComponent.bindClassBehaviour(OnCheckIn.QNAME, - GoogleDocsModel.ASPECT_GOOGLERESOURCE, - new JavaBehaviour(this, "onCheckIn", NotificationFrequency.FIRST_EVENT))); - behaviours.add(policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, - GoogleDocsModel.ASPECT_GOOGLERESOURCE, - new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT))); - - // Copy behaviours - behaviours.add(policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), - GoogleDocsModel.ASPECT_GOOGLEEDITABLE, - new JavaBehaviour(this, "getGoogleEditableCopyCallback"))); - behaviours.add(policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), - GoogleDocsModel.ASPECT_GOOGLERESOURCE, - new JavaBehaviour(this, "getGoogleResourceCopyCallback"))); - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) - */ - public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) - { - if (googleDocsService.isEnabled() == true && nodeService.exists(nodeRef) == true) - { - // Can only make cm:content descendant google editable - QName type = nodeService.getType(nodeRef); - if (dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == false) - { - // Prevent aspect from being applied - throw new AlfrescoRuntimeException("The node (" + nodeRef.toString() + ") can not be made google editable, because it is not a sub type of cm:content."); - } - } - } - - /** - * @see org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut#onCheckOut(org.alfresco.service.cmr.repository.NodeRef) - */ - public void onCheckOut(NodeRef workingCopy) - { - if (googleDocsService.isEnabled() == true && nodeService.exists(workingCopy) == true && isUpload() == false) - { - // Upload the content of the working copy to google docs - googleDocsService.createGoogleDoc(workingCopy, GoogleDocsPermissionContext.SHARE_WRITE); - } - } - - private boolean isUpload() - { - boolean result = false; - String value = (String)AlfrescoTransactionSupport.getResource("checkoutforupload"); - if (value != null) - { - result = Boolean.parseBoolean(value); - } - return result; - } - - public void beforeCheckIn(NodeRef workingCopyNodeRef, - Map versionProperties, String contentUrl, - boolean keepCheckedOut) - { - if (googleDocsService.isEnabled() == true && - nodeService.exists(workingCopyNodeRef) == true && - nodeService.hasAspect(workingCopyNodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE) == true && - isUpload() == false) - { - // Get input stream for the google doc - InputStream is = googleDocsService.getGoogleDocContent(workingCopyNodeRef); - if (is == null) - { - throw new AlfrescoRuntimeException("Unable to complete check in, because the working copy content could not be retrieved from google docs."); - } - - // Write the google content into the node - ContentWriter writer = contentService.getWriter(workingCopyNodeRef, ContentModel.PROP_CONTENT, true); - writer.putContent(is); - } - } - - /** - * @see org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckIn#onCheckIn(org.alfresco.service.cmr.repository.NodeRef) - */ - @Override - public void onCheckIn(NodeRef nodeRef) - { - if (googleDocsService.isEnabled() == true && nodeService.exists(nodeRef) == true) - { - nodeService.removeAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE); - } - } - - /** - * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) - */ - public void beforeDeleteNode(NodeRef nodeRef) - { - if (googleDocsService.isEnabled() == true && - nodeService.exists(nodeRef) == true && - isUpload() == false) - { - // Delete the associated google resource - googleDocsService.deleteGoogleResource(nodeRef); - } - } - - public CopyBehaviourCallback getGoogleEditableCopyCallback(QName classRef, CopyDetails copyDetails) - { - return GoogleEditableCopyBehaviourCallback.INSTANCE; - } - - private static class GoogleEditableCopyBehaviourCallback extends DefaultCopyBehaviourCallback - { - private static final CopyBehaviourCallback INSTANCE = new GoogleEditableCopyBehaviourCallback(); - - /** - * @return Returns an empty map - */ - @Override - public Map getCopyProperties(QName classQName, CopyDetails copyDetails, Map properties) - { - return Collections.emptyMap(); - } - } - - public CopyBehaviourCallback getGoogleResourceCopyCallback(QName classRef, CopyDetails copyDetails) - { - return GoogleResourceCopyBehaviourCallback.INSTANCE; - } - - private static class GoogleResourceCopyBehaviourCallback extends DefaultCopyBehaviourCallback - { - private static final CopyBehaviourCallback INSTANCE = new GoogleEditableCopyBehaviourCallback(); - - /** - * @return Returns an empty map - */ - @Override - public Map getCopyProperties(QName classQName, CopyDetails copyDetails, Map properties) - { - return Collections.emptyMap(); - } - } - - @Override - public void destroy() throws Exception - { - for(BehaviourDefinition definition : behaviours) - { - policyComponent.removeClassDefinition(definition); - } - } -} diff --git a/source/java/org/alfresco/repo/googledocs/GoolgeDocsUnsupportedMimetypeException.java b/source/java/org/alfresco/repo/googledocs/GoolgeDocsUnsupportedMimetypeException.java deleted file mode 100644 index 274810c870..0000000000 --- a/source/java/org/alfresco/repo/googledocs/GoolgeDocsUnsupportedMimetypeException.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - */ -package org.alfresco.repo.googledocs; - -import java.text.MessageFormat; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Roy Wetherall - */ -public class GoolgeDocsUnsupportedMimetypeException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = 7505645425492536907L; - - private static Log logger = LogFactory.getLog(GoolgeDocsUnsupportedMimetypeException.class); - - /** - * @param msgId - */ - public GoolgeDocsUnsupportedMimetypeException(String msgId) - { - super(msgId); - } - - /** - * @param msgId - * @param msgParams - */ - public GoolgeDocsUnsupportedMimetypeException(String msgId, Object[] msgParams) - { - super(msgId, msgParams); - } - - /** - * @param msgId - * @param cause - */ - public GoolgeDocsUnsupportedMimetypeException(String msgId, Throwable cause) - { - super(msgId, cause); - } - - /** - * @param msgId - * @param msgParams - * @param cause - */ - public GoolgeDocsUnsupportedMimetypeException(String msgId, Object[] msgParams, Throwable cause) - { - super(msgId, msgParams, cause); - } - - /** - * @param nodeRef node reference - * @param contentProp content property - * @param mimetype mimetype - */ - public GoolgeDocsUnsupportedMimetypeException(NodeRef nodeRef, QName contentProp, String mimetype) - { - // TODO I18N - this(MessageFormat.format("The mimetype {0} is not supported by Google Docs", mimetype)); - - if (logger.isDebugEnabled() == true) - { - logger.debug(MessageFormat.format("The mimetype {0} is not supported by Google Docs. (nodeRef = {1}, contentProp = {2})", mimetype, nodeRef.toString(), contentProp.toString())); - } - } - -} diff --git a/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java b/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java deleted file mode 100644 index 8162aef528..0000000000 --- a/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java +++ /dev/null @@ -1,76 +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 . - */ - -package org.alfresco.repo.jscript.app; - -import org.alfresco.repo.googledocs.GoogleDocsService; -import org.alfresco.repo.management.subsystems.ApplicationContextFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Return current status of Google Docs subsystem - * - * @author: mikeh - */ -public class GoogleDocsCustomResponse implements CustomResponse, ApplicationContextAware -{ - private static Log logger = LogFactory.getLog(GoogleDocsCustomResponse.class); - - private ApplicationContext applicationContext; - - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - this.applicationContext = applicationContext; - } - - /** - * Populates the DocLib webscript response with custom metadata - * - * @return JSONObject or null - */ - public Serializable populate() - { - try - { - ApplicationContextFactory subsystem = (ApplicationContextFactory)applicationContext.getBean("googledocs"); - ConfigurableApplicationContext childContext = (ConfigurableApplicationContext)subsystem.getApplicationContext(); - GoogleDocsService googleDocsService = (GoogleDocsService)childContext.getBean("googleDocsService"); - - Map jsonObj = new LinkedHashMap(4); - jsonObj.put("enabled", googleDocsService.isEnabled()); - - return (Serializable)jsonObj; - } - catch (Exception e) - { - logger.warn("Could not add custom Google Docs status response to DocLib webscript"); - } - return null; - } -} diff --git a/source/test-java/org/alfresco/repo/googledocs/GoogleDocumentServiceSystemTest.java b/source/test-java/org/alfresco/repo/googledocs/GoogleDocumentServiceSystemTest.java deleted file mode 100644 index 59e0ba316d..0000000000 --- a/source/test-java/org/alfresco/repo/googledocs/GoogleDocumentServiceSystemTest.java +++ /dev/null @@ -1,371 +0,0 @@ -/* -* Copyright (C) 2005-2010 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 . -*/ -package org.alfresco.repo.googledocs; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; - -import javax.transaction.UserTransaction; - -import junit.framework.TestCase; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.transform.AbstractContentTransformerTest; -import org.alfresco.repo.management.subsystems.ApplicationContextFactory; -import org.alfresco.repo.node.archive.NodeArchiveService; -import org.alfresco.repo.rendition.executer.AbstractRenderingEngine; -import org.alfresco.repo.rendition.executer.ReformatRenderingEngine; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.site.SiteServiceImpl; -import org.alfresco.service.cmr.coci.CheckOutCheckInService; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.rendition.RenditionDefinition; -import org.alfresco.service.cmr.rendition.RenditionService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; - -import com.google.gdata.util.ServiceException; - -public class GoogleDocumentServiceSystemTest extends TestCase implements GoogleDocsModel -{ - private NodeService nodeService; - private GoogleDocsService googleDocsService; - private SiteService siteService; - private TransactionService transactionService; - private FileFolderService fileFolderService; - private ContentService contentService; - private CheckOutCheckInService checkOutCheckInService; - private MutableAuthenticationService authenticationService; - private PersonService personService; - private ApplicationContextFactory subsystem; - private RenditionService renditionService; - private NodeArchiveService nodeArchiveService; - - private static final String USER_ONE = "GoogleDocUserOne"; - private static final String USER_TWO = "GoogleDocUserTwo"; - private static final String USER_THREE = "GoogleDocUserThree"; - private static final String USER_FOUR = "GoogleDocUserFour"; - private static final String USER_FIVE = "GoogleDocUserFive"; - private static final String USER_SIX = "GoogleDocUserSix"; - private static final String USER_SEVEN = "GoogleDocUserSeven"; - - private NodeRef folder; - private NodeRef nodeRefDoc; - private NodeRef nodeRefSpread; - private NodeRef nodeRefPres; - private NodeRef nodeRefPdf; - private NodeRef nodeRef2; - private UserTransaction userTransaction; - private String siteId; - - @Override - protected void setUp() throws Exception - { - ApplicationContext appContext = ApplicationContextHelper.getApplicationContext(); - - nodeService = (NodeService)appContext.getBean("nodeService"); - siteService = (SiteService)appContext.getBean("siteService"); - transactionService = (TransactionService)appContext.getBean("transactionService"); - fileFolderService = (FileFolderService)appContext.getBean("fileFolderService"); - contentService = (ContentService)appContext.getBean("contentService"); - checkOutCheckInService = (CheckOutCheckInService)appContext.getBean("checkOutCheckInService"); - authenticationService = (MutableAuthenticationService)appContext.getBean("authenticationService"); - personService = (PersonService)appContext.getBean("personService"); - renditionService = (RenditionService)appContext.getBean("renditionService"); - nodeArchiveService = (NodeArchiveService)appContext.getBean("nodeArchiveService"); - - // Start the user transaction - userTransaction = transactionService.getUserTransaction(); - userTransaction.begin(); - - // Get the sub-system and make sure the googleeditable feature is turned on - subsystem = (ApplicationContextFactory)appContext.getBean("googledocs"); - if (subsystem.getProperty("googledocs.googleeditable.enabled").equals("false") == true) - { - subsystem.stop(); - subsystem.setProperty("googledocs.googleeditable.enabled", "true"); - subsystem.start(); - } - - // Get the google docs service - ConfigurableApplicationContext childContext = (ConfigurableApplicationContext)subsystem.getApplicationContext(); - googleDocsService = (GoogleDocsService)childContext.getBean("googleDocsService"); - - // Create the test users - createUser(USER_ONE, "rwetherall@alfresco.com", null); - createUser(USER_TWO, "admin@alfresco.com", "rwetherall@activiti.com"); - createUser(USER_THREE, "roy.wetherall@alfresco.com", null); - createUser(USER_FOUR, "roy.wetherall@activiti.com", null); - createUser(USER_FIVE, "admin@alfresco.com", "admin@alfresco.com"); - createUser(USER_SIX, "admin@alfresco.com", null); - createUser(USER_SEVEN, null, null); - - // Authenticate as user one - AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE); - - siteId = GUID.generate(); - - // Create a site to use as holder for our test google documents - siteService.createSite("sitePreset", siteId, "My Title", "My Description", SiteVisibility.PUBLIC); - NodeRef container = siteService.createContainer(siteId, "testComponent", null, null); - - // Add some memberships to the site - siteService.setMembership(siteId, USER_TWO, SiteServiceImpl.SITE_COLLABORATOR); - siteService.setMembership(siteId, USER_THREE, SiteServiceImpl.SITE_CONTRIBUTOR); - siteService.setMembership(siteId, USER_FOUR, SiteServiceImpl.SITE_CONSUMER); - siteService.setMembership(siteId, USER_FIVE, SiteServiceImpl.SITE_COLLABORATOR); - siteService.setMembership(siteId, USER_SIX, SiteServiceImpl.SITE_COLLABORATOR); - siteService.setMembership(siteId, USER_SEVEN, SiteServiceImpl.SITE_COLLABORATOR); - - // Create a folder in our site container - folder = fileFolderService.create(container, "myfolder" + GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); - - // Create test documents - nodeRefDoc = createTestDocument("mydoc.docx", "alfresco/subsystems/googledocs/default/test.docx", MimetypeMap.MIMETYPE_WORD); - nodeRefSpread = createTestDocument("mydoc.xls", "alfresco/subsystems/googledocs/default/testBook.xls", MimetypeMap.MIMETYPE_EXCEL); - //nodeRefSpread = createTestDocument("mydoc2.xlsx", "alfresco/subsystems/googledocs/default/test.xlsx", MimetypeMap.MIMETYPE_EXCEL); - - // Create an empty content node (simulate creation of a new google doc in UI) - nodeRef2 = fileFolderService.create(folder, "mygoogledoc.xls", ContentModel.TYPE_CONTENT).getNodeRef(); - nodeService.addAspect(nodeRef2, ASPECT_GOOGLEEDITABLE, null); - ContentWriter contentWriter = contentService.getWriter(nodeRef2, ContentModel.PROP_CONTENT, true); - contentWriter.setEncoding("UTF-8"); - contentWriter.setMimetype(MimetypeMap.MIMETYPE_EXCEL); - contentWriter.putContent(""); - } - - private NodeRef createTestDocument(String name, String contentPath, String mimetype) - { - NodeRef nodeRef = fileFolderService.create(folder, name, ContentModel.TYPE_CONTENT).getNodeRef(); - ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.setMimetype(mimetype); - InputStream is = getClass().getClassLoader().getResourceAsStream(contentPath); - writer.putContent(is); - return nodeRef; - } - - private void createUser(String userName, String email, String googleEmail) - { - if (authenticationService.authenticationExists(userName) == false) - { - authenticationService.createAuthentication(userName, "PWD".toCharArray()); - - PropertyMap ppOne = new PropertyMap(4); - ppOne.put(ContentModel.PROP_USERNAME, userName); - ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName"); - ppOne.put(ContentModel.PROP_LASTNAME, "lastName"); - ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); - - if (email != null) - { - ppOne.put(ContentModel.PROP_EMAIL, email); - } - - if (googleEmail != null) - { - ppOne.put(ContentModel.PROP_GOOGLEUSERNAME, googleEmail); - } - - personService.createPerson(ppOne); - } - } - - @Override - protected void tearDown() throws Exception - { - SiteInfo siteInfo = siteService.getSite(siteId); - siteService.deleteSite(siteId); - - if (userTransaction != null) - { - userTransaction.commit(); - } - nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef())); - } - - private boolean isGoogleServiceAvailable() - { - return googleDocsService.isEnabled(); - } - - public void testGoogleDocUploadDownload() throws Exception - { - if (isGoogleServiceAvailable() == true) - { - googleDocsService.createGoogleDoc(nodeRefDoc, GoogleDocsPermissionContext.SHARE_WRITE); - - assertTrue(nodeService.hasAspect(nodeRefDoc, ASPECT_GOOGLERESOURCE)); - assertNotNull(nodeService.getProperty(nodeRefDoc, PROP_URL)); - assertNotNull(nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_ID)); - assertNotNull(nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_TYPE)); - - System.out.println("For node ref " + nodeRefDoc.toString()); - System.out.println("Google doc URL: " + nodeService.getProperty(nodeRefDoc, PROP_URL)); - System.out.println("Google doc type: " + nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_TYPE)); - System.out.println("Google doc id: " + nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_ID)); - String downloadFile = downloadFile(googleDocsService.getGoogleDocContent(nodeRefDoc), ".doc"); - System.out.println("Download file: " + downloadFile); - - googleDocsService.createGoogleDoc(nodeRefSpread, GoogleDocsPermissionContext.SHARE_WRITE); - - assertTrue(nodeService.hasAspect(nodeRefSpread, ASPECT_GOOGLERESOURCE)); - assertNotNull(nodeService.getProperty(nodeRefSpread, PROP_URL)); - assertNotNull(nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_ID)); - assertNotNull(nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_TYPE)); - - System.out.println("Google doc URL: " + nodeService.getProperty(nodeRefSpread, PROP_URL)); - System.out.println("Google doc type: " + nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_TYPE)); - System.out.println("Google doc id: " + nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_ID)); - downloadFile = downloadFile(googleDocsService.getGoogleDocContent(nodeRefSpread), ".xls"); - System.out.println("Download file: " + downloadFile); - - googleDocsService.createGoogleDoc(nodeRef2, GoogleDocsPermissionContext.SHARE_WRITE); - } - - } - - public void testCheckOutCheckIn() throws Exception - { - if (isGoogleServiceAvailable() == true) - { - // Check out the empty google document - NodeRef workingCopy = checkOutCheckInService.checkout(nodeRef2); - - assertTrue(nodeService.hasAspect(workingCopy, ASPECT_GOOGLERESOURCE)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_URL)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_RESOURCE_ID)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_RESOURCE_TYPE)); - - System.out.println("Google doc URL: " + nodeService.getProperty(workingCopy, PROP_URL)); - System.out.println("Google doc type: " + nodeService.getProperty(workingCopy, PROP_RESOURCE_TYPE)); - System.out.println("Google doc id: " + nodeService.getProperty(workingCopy, PROP_RESOURCE_ID)); - - checkOutCheckInService.checkin(workingCopy, null); - - assertFalse(nodeService.hasAspect(nodeRef2, ASPECT_GOOGLERESOURCE)); - ContentReader contentReader = contentService.getReader(nodeRef2, ContentModel.PROP_CONTENT); - assertNotNull(contentReader); - - // Lets try and delete the checked in node reference - nodeService.deleteNode(nodeRef2); - } - } - - /** - * http://issues.alfresco.com/jira/browse/ALF-5060 - */ - public void testALF5060() throws Exception - { - if (isGoogleServiceAvailable() == true) - { - // Create a rendition definition (doc -> pdf) - RenditionDefinition def = renditionService.createRenditionDefinition( - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDef"), - ReformatRenderingEngine.NAME); - def.setExecuteAsynchronously(false); - def.setParameterValue(AbstractRenderingEngine.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_FLASH); - - // Create a word document - File fileDoc = AbstractContentTransformerTest.loadQuickTestFile("doc"); - NodeRef nodeRef = fileFolderService.create(folder, "testing.doc", ContentModel.TYPE_CONTENT).getNodeRef(); - nodeService.addAspect(nodeRef, ASPECT_GOOGLEEDITABLE, null); - ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); - contentWriter.setEncoding("UTF-8"); - contentWriter.setMimetype(MimetypeMap.MIMETYPE_WORD); - contentWriter.putContent(fileDoc); - - renditionService.render(nodeRef, def); - - NodeRef workingCopy = checkOutCheckInService.checkout(nodeRef); - assertTrue(nodeService.hasAspect(workingCopy, ASPECT_GOOGLERESOURCE)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_URL)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_RESOURCE_ID)); - assertNotNull(nodeService.getProperty(workingCopy, PROP_RESOURCE_TYPE)); - System.out.println("Google doc URL: " + nodeService.getProperty(workingCopy, PROP_URL)); - System.out.println("Google doc type: " + nodeService.getProperty(workingCopy, PROP_RESOURCE_TYPE)); - System.out.println("Google doc id: " + nodeService.getProperty(workingCopy, PROP_RESOURCE_ID)); - checkOutCheckInService.checkin(workingCopy, null); - - renditionService.render(nodeRef, def); - - } - } - - /** - * Utility method to download input stream to a file for inspection - * - * @param inStream - * @param ext - * @return - * @throws IOException - * @throws MalformedURLException - * @throws ServiceException - */ - private String downloadFile(InputStream inStream, String ext) throws IOException, MalformedURLException, ServiceException - { - File file = File.createTempFile("googleDocTest", ext); - String filePath = file.getAbsolutePath(); - FileOutputStream outStream = null; - try - { - 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(); - } - } - - return filePath; - } -}