[google-docs-upload] r18 committed - - The tool has been fixed and tested for working properly with Google ...

6 views
Skip to first unread message

google-do...@googlecode.com

unread,
Mar 20, 2011, 6:29:12 PM3/20/11
to google-docs-u...@googlegroups.com
Revision: 18
Author: anton.be...@gmail.com
Date: Sun Mar 20 15:27:32 2011
Log: - The tool has been fixed and tested for working properly with
Google Apps Business accounts
- Fixed a bug due to empty file names
- Updated the dependencies
http://code.google.com/p/google-docs-upload/source/detail?r=18

Added:
/trunk/jars/google-docs-upload-1.4.3.jar
Deleted:
/trunk/libs/activation.jar
Modified:
/trunk/.classpath
/trunk/libs/gdata-client-1.0.jar
/trunk/libs/gdata-client-meta-1.0.jar
/trunk/libs/gdata-core-1.0.jar
/trunk/libs/gdata-docs-3.0.jar
/trunk/libs/gdata-docs-meta-3.0.jar
/trunk/libs/gdata-media-1.0.jar
/trunk/libs/gdata-spreadsheet-3.0.jar
/trunk/libs/gdata-spreadsheet-meta-3.0.jar
/trunk/libs/mail.jar
/trunk/src/DocumentList.java
/trunk/src/GoogleDocsUpload.java

=======================================
--- /dev/null
+++ /trunk/jars/google-docs-upload-1.4.3.jar Sun Mar 20 15:27:32 2011
File is too large to display a diff.
=======================================
--- /trunk/libs/activation.jar Thu Sep 3 23:10:30 2009
+++ /dev/null
Binary file, no diff available.
=======================================
--- /trunk/.classpath Thu Sep 3 23:10:30 2009
+++ /trunk/.classpath Sun Mar 20 15:27:32 2011
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="libs/activation.jar"/>
<classpathentry kind="lib" path="libs/gdata-client-1.0.jar"/>
<classpathentry kind="lib" path="libs/gdata-client-meta-1.0.jar"/>
<classpathentry kind="lib" path="libs/gdata-core-1.0.jar"/>
=======================================
--- /trunk/libs/gdata-client-1.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-client-1.0.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/libs/gdata-client-meta-1.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-client-meta-1.0.jar Sun Mar 20 15:27:32 2011
@@ -2,9 +2,7 @@
âf ; META-INF/þÊ PK
áf ;7OÒ}\ j META-INF/MANIFEST.MFóMÌËLK-.Ñ
K-*ÎÌϳR0Ô3àårÌC q,HLÎHU Š %ÍAÒÎE©‰%©)ºN• õ¦z ñ†æºI &
- Á¥y
-¾™ÉEùÅ•Å%©¹Å
-žyÉzš¼\¼\ PK
+Ìt“ L 4‚Kó |3“‹ò‹+‹KRs‹ <ó’õ4y¹x¹ PK
Ûf ; META-INF/gdata/PK
âf ; META-INF/gdata/kinds/PK

âf ;̤[Ñj ž 6 META-INF/gdata/kinds/com.google.schemas.g.2005.contactSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕO×7200UNÎÏ+IL.á
@@ -12,7 +10,7 @@

âf ;ƒ<“xg ˜ 4 META-INF/gdata/kinds/com.google.schemas.g.2005.event Œ;
€0 {O±`Ÿˆ`c'ø)<E0k tW²‹èíý€½Í+f†—BW;uÐÏä¡ònSŽ #G˜T·ÒZ &\ ˜À
4 ¯6Ø<ËŠ w$Mnð¹àï'ó
-Š$3“˜æÉ Òxþl[DŸ\PK
+Š$3“˜æÉZDÿ3mHã™\PK

âf ;ò Ypj ž 6 META-INF/gdata/kinds/com.google.schemas.g.2005.messageSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕO×7200UÎM-.NLOå
ÁdÓS€fé ‰ÔŠ’Ô¼âÌü¼b=_ˆB×¼’¢J¢U»¥¦¦p PK
âf ; íA META-INF/þÊ PK
=======================================
--- /trunk/libs/gdata-core-1.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-core-1.0.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/libs/gdata-docs-3.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-docs-3.0.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/libs/gdata-docs-meta-3.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-docs-meta-3.0.jar Sun Mar 20 15:27:32 2011
@@ -2,22 +2,30 @@
g ; META-INF/þÊ PK
g ;7OÒ}\ j META-INF/MANIFEST.MFóMÌËLK-.Ñ
K-*ÎÌϳR0Ô3àårÌC q,HLÎHU Š %ÍAÒÎE©‰%©)ºN• õ¦z ñ†æºI &
- Á¥y
-¾™ÉEùÅ•Å%©¹Å
-žyÉzš¼\¼\ PK
+Ìt“ L 4‚Kó |3“‹ò‹+‹KRs‹ <ó’õ4y¹x¹ PK
ýf ; META-INF/gdata/PK
g ; META-INF/gdata/kinds/PK

g ;Umª¶^ p : META-INF/gdata/kinds/com.google.schemas.docs.2007.documentSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W ²JsSóJ¸€Â0 é)@óô
P¡ž T k^IQ% PK

g ;<Êœ0] l 8 META-INF/gdata/kinds/com.google.schemas.docs.2007.folderSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200WNËÏII-â
+ ;{D>&ø)œ[ h 6 META-INF/gdata/kinds/com.google.schemas.docs.2007.fileSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200WNËÌIå
+ÁdÓS€féA  "=7 ¼k^IQ% PK
+ ;{D><Êœ0] l 8 META-INF/gdata/kinds/com.google.schemas.docs.2007.folderSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200WNËÏII-â
ÂäÓS€¦éA  2=7°
×¼’¢J. PK

g ;ðLœuZ f 5 META-INF/gdata/kinds/com.google.schemas.docs.2007.pdfSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W.HIã ŠÀ$ÓS€FéA   ½€”4×¼’¢J. PK
- g ;æ‡ •\ j 7 META-INF/gdata/kinds/com.google.schemas.docs.2007.photoSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W.ÈÈ/Éç ŠÁ¤ÓS€†éA  *½ ×¼’¢J. PK
+ÁdÓS€féA  "=—üäÒÜÔ¼ ŸÌâ ×¼’¢Jb »¥¦¦p PK
+ ;{D>îG ác ˜ : META-INF/gdata/kinds/com.google.schemas.docs.2007.metadataSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200WÎM-IL jç
+ÃT¤ƒ ô P¡ž/T k^IQ%1
+ÝRSS¸ PK

g ;Ó"Œ:c x > META-INF/gdata/kinds/com.google.schemas.docs.2007.presentationSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W.(J-NÍ+I,ÉÌÏã JÁT¥§ ÍÔƒ @Åz Hê\óJŠ*¹ PK

g ;}¢Èéb v = META-INF/gdata/kinds/com.google.schemas.docs.2007.spreadsheetSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W..(JML)ÎHM-á ÊÀ ¥§ Ôƒ @µzÁ e®y%E•\ PK

g ;æå.¥e s 9 META-INF/gdata/kinds/com.google.schemas.docs.2007.unknown5Œ1
-€0 w_ poÅEp ýDik m"MDü½ q¹á8®„±7b`ÚÐAçÌ)” J°Šœ­ÖlW
-«@ ¯,EíȲ®«ª)/Ü‘n,²ýƒàòN}È êÉ^Ñ£Ì Ë€’žâ PK
+ÃT¤§ ÍÓƒ @
+zAP5n©©)\ PK
+ ;{D>}¢Èéb v = META-INF/gdata/kinds/com.google.schemas.docs.2007.spreadsheetSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕOÉO.Ö7200W..(JML)ÎHM-á ÊÀ ¥§ Ôƒ @µzÁ e®y%E•\ PK
+ ;{D> íA META-INF/þÊ PK
+ :{D>Æä¦.^ j ¤ + META-INF/MANIFEST.MFPK
+ 9{D> íA» META-INF/gdata/PK
g ; íA META-INF/þÊ PK
g ;7OÒ}\ j ¤ + META-INF/MANIFEST.MFPK
ýf ; íA¹ META-INF/gdata/PK
=======================================
--- /trunk/libs/gdata-media-1.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-media-1.0.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/libs/gdata-spreadsheet-3.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-spreadsheet-3.0.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/libs/gdata-spreadsheet-meta-3.0.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/gdata-spreadsheet-meta-3.0.jar Sun Mar 20 15:27:32 2011
@@ -2,9 +2,7 @@
ýf ; META-INF/þÊ PK
üf ;7OÒ}\ j META-INF/MANIFEST.MFóMÌËLK-.Ñ
K-*ÎÌϳR0Ô3àårÌC q,HLÎHU Š %ÍAÒÎE©‰%©)ºN• õ¦z ñ†æºI &
- Á¥y
-¾™ÉEùÅ•Å%©¹Å
-žyÉzš¼\¼\ PK
+Ìt“ L 4‚Kó |3“‹ò‹+‹KRs‹ <ó’õ4y¹x¹ PK
úf ; META-INF/gdata/PK
üf ; META-INF/gdata/kinds/PK

üf ;ï¿-§j ¢ > META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.cellSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200SNNÍÉá JÁT¥§ ÍÔ HŠõœ ÊÜRSSˆTêšWRTÉ PK
@@ -12,8 +10,9 @@

üf ;êµp k ¨ @ META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.recordSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200S.JMÎ/Já JÂÔ¥§ MÕ HÊõ‚À
ÝRS‰WìšWRTÉ PK

üf ; Vã h · E META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.spreadsheetSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200SF á ª€)NO ­ & Tè #Ø®y%E•¤iqKMMá PK
- üf ;`Ð{|
k ¥ ? META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.tableSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200S.ILÊIå ÊÁ”¥§
-Õ HªõB@ê\óJŠ*‰Uì–ššÂ PK
+wKh · E META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.spreadsheetSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200SF á ª€)NO ­ & Tè #Øn©©)¤épÍ+)ªä PK
+ 9{D>c¢} k ¥ ? META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.tableSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200S.ILÊIå ÊÁ”¥§
+Õ HªõB@êÜRSSˆUëšWRTÉ PK

üf ;s–ÈÅl ± C META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.worksheetSVpwI,ITðÎÌKQpLI,(É/*VHË/RÈ())°Ò×/NÎHÍM,ÖKÏÏOÏIÕKÎÏÕ/.(JML)ÎHM-)Ö7200S.Ï/Ê ó¹€ò0¥é)@ƒõÀ ’ ½p˜Z×¼’¢JR4¸¥¦¦p PK
ýf ; íA META-INF/þÊ PK
üf ;7OÒ}\ j ¤ + META-INF/MANIFEST.MFPK
@@ -23,6 +22,7 @@
üf ;|
I j ¢ > ¤ ß META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.listPK

üf ;êµp k ¨ @ ¤ ¥ META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.recordPK

üf ; Vã h · E ¤ n META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.spreadsheetPK
+wKh · E ¤ p META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.spreadsheetPK
üf ;`Ð{|
k ¥ ? ¤ 9 META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.tablePK

üf ;s–ÈÅl ± C ¤ META-INF/gdata/kinds/com.google.schemas.spreadsheets.2006.worksheetPK

=======================================
--- /trunk/libs/mail.jar Thu Sep 3 23:10:30 2009
+++ /trunk/libs/mail.jar Sun Mar 20 15:27:32 2011
Binary file, no diff available.
=======================================
--- /trunk/src/DocumentList.java Tue Jan 18 03:09:35 2011
+++ /trunk/src/DocumentList.java Sun Mar 20 15:27:32 2011
@@ -52,9 +52,6 @@
* Service can be used to search your documents, upload and download files,
* change sharing permission, file documents in folders, and view revisions
* history.
- *
- *
- *
*/
public class DocumentList {
public DocsService service;
@@ -134,48 +131,34 @@

/**
* Constructor.
- *
- * @param applicationName
- * name of the application.
- *
- * @throws DocumentListException
+ *
+ * @param applicationName name of the application.
+ * @throws DocumentListException the document list exception
*/
public DocumentList(String applicationName) throws DocumentListException {
- this(applicationName, DEFAULT_AUTH_PROTOCOL, DEFAULT_AUTH_HOST,
- DEFAULT_PROTOCOL, DEFAULT_HOST);
+ this(applicationName, DEFAULT_AUTH_PROTOCOL, DEFAULT_AUTH_HOST,
DEFAULT_PROTOCOL, DEFAULT_HOST);
}

/**
- * Constructor
- *
- * @param applicationName
- * name of the application
- * @param authProtocol
- * the protocol to use for authentication
- * @param authHost
- * the host to use for authentication
- * @param protocol
- * the protocol to use for the http calls.
- * @param host
- * the host that contains the feeds
- *
- * @throws DocumentListException
+ * Constructor.
+ *
+ * @param applicationName name of the application
+ * @param authProtocol the protocol to use for authentication
+ * @param authHost the host to use for authentication
+ * @param protocol the protocol to use for the http calls.
+ * @param host the host that contains the feeds
+ * @throws DocumentListException the document list exception
*/
- public DocumentList(String applicationName, String authProtocol,
- String authHost, String protocol, String host)
- throws DocumentListException {
- if (authProtocol == null || authHost == null || protocol == null
- || host == null) {
- throw new DocumentListException(
- "null passed in required parameters");
+ public DocumentList(String applicationName, String authProtocol, String
authHost, String protocol, String host) throws DocumentListException {
+ if (authProtocol == null || authHost == null || protocol == null || host
== null) {
+ throw new DocumentListException("null passed in required parameters");
}

service = new DocsService(applicationName);

// Creating a spreadsheets service is necessary for downloading
// spreadsheets
- spreadsheetsService = new GoogleService(SPREADSHEETS_SERVICE_NAME,
- applicationName);
+ spreadsheetsService = new GoogleService(SPREADSHEETS_SERVICE_NAME,
applicationName);

this.applicationName = applicationName;
this.authProtocol = authProtocol;
@@ -186,17 +169,13 @@

/**
* Set user credentials based on a username and password.
- *
- * @param user
- * username to log in with.
- * @param pass
- * password for the user logging in.
- *
- * @throws AuthenticationException
- * @throws DocumentListException
+ *
+ * @param user username to log in with.
+ * @param pass password for the user logging in.
+ * @throws AuthenticationException the authentication exception
+ * @throws DocumentListException the document list exception
*/
- public void login(String user, String pass) throws
AuthenticationException,
- DocumentListException {
+ public void login(String user, String pass) throws
AuthenticationException, DocumentListException {
if (user == null || pass == null) {
throw new DocumentListException("null login credentials");
}
@@ -210,15 +189,12 @@

/**
* Allow a user to login using an AuthSub token.
- *
- * @param token
- * the token to be used when logging in.
- *
- * @throws AuthenticationException
- * @throws DocumentListException
+ *
+ * @param token the token to be used when logging in.
+ * @throws AuthenticationException the authentication exception
+ * @throws DocumentListException the document list exception
*/
- public void loginWithAuthSubToken(String token)
- throws AuthenticationException, DocumentListException {
+ public void loginWithAuthSubToken(String token) throws
AuthenticationException, DocumentListException {
if (token == null) {
throw new DocumentListException("null login credentials");
}
@@ -233,21 +209,17 @@

/**
* Create a new item in the DocList.
- *
- * @param title
- * the title of the document to be created.
- * @param type
- * the type of the document to be created. One
of "spreadsheet",
- * "presentation", or "document".
- *
- * @throws DocumentListException
- * @throws ServiceException
- * @throws IOException
- * @throws MalformedURLException
+ *
+ * @param title the title of the document to be created.
+ * @param type the type of the document to be created. One
of "spreadsheet",
+ * "presentation", or "document".
+ * @return the document list entry
+ * @throws MalformedURLException the malformed url exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListEntry createNew(String title, String type)
- throws MalformedURLException, IOException, ServiceException,
- DocumentListException {
+ public DocumentListEntry createNew(String title, String type) throws
MalformedURLException, IOException, ServiceException, DocumentListException
{
if (title == null || type == null) {
throw new DocumentListException("null title or type");
}
@@ -264,18 +236,15 @@
}

newEntry.setTitle(new PlainTextConstruct(title));
- return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED),
- newEntry);
- }
-
+ return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED),
newEntry);
+ }
+
/**
* Creates the new sub folder.
- *
+ *
* @param title the title
* @param folderResourceId the folder resource id
- *
* @return the document list entry
- *
* @throws IOException Signals that an I/O exception has occurred.
* @throws ServiceException the service exception
* @throws DocumentListException the document list exception
@@ -286,7 +255,6 @@
URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" +
folderResourceId + URL_FOLDERS);
return service.insert(url, newEntry);
}
-

/**
* Gets a feed containing the documents.
@@ -305,9 +273,7 @@
* @throws ServiceException
* @throws DocumentListException
*/
- public DocumentListFeed getDocsListFeed(String category)
- throws IOException, MalformedURLException, ServiceException,
- DocumentListException {
+ public DocumentListFeed getDocsListFeed(String category) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (category == null) {
throw new DocumentListException("null category");
}
@@ -318,38 +284,31 @@
url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED);
} else if (category.equals("folders")) {
String[] parameters = { PARAMETER_SHOW_FOLDERS };
- url = buildUrl(
- URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_FOLDER,
- parameters);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_FOLDER,
parameters);
} else if (category.equals("documents")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_DOCUMENT);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_DOCUMENT);
} else if (category.equals("spreadsheets")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_SPREADSHEET);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED +
URL_CATEGORY_SPREADSHEET);
} else if (category.equals("pdfs")) {
url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_PDF);
} else if (category.equals("presentations")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_PRESENTATION);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED +
URL_CATEGORY_PRESENTATION);
} else if (category.equals("starred")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_STARRED);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_STARRED);
} else if (category.equals("trashed")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_TRASHED);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_TRASHED);
} else {
return null;
}

DocumentQuery query = new DocumentQuery(url);
-// if (!category.equals("folders")) {
-// query.setMaxResults(101);
-// }
+ // if (!category.equals("folders")) {
+ // query.setMaxResults(101);
+ // }

return service.getFeed(query, DocumentListFeed.class);
}
-
+
public DocumentListFeed getDocsListFeed(Link link) throws
MalformedURLException, IOException, ServiceException, DocumentListException
{
if (link != null) {
return service.getFeed(new URL(link.getHref()), DocumentListFeed.class);
@@ -359,18 +318,15 @@

/**
* Gets the entry for the provided object id.
- *
- * @param resourceId
- * the resource id of the object to fetch an entry for.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to fetch an entry for.
+ * @return the docs list entry
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListEntry getDocsListEntry(String resourceId)
- throws IOException, MalformedURLException, ServiceException,
- DocumentListException {
+ public DocumentListEntry getDocsListEntry(String resourceId) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (resourceId == null) {
throw new DocumentListException("null resourceId");
}
@@ -381,88 +337,75 @@

/**
* Gets the feed for all the objects contained in a folder.
- *
- * @param folderResourceId
- * the resource id of the folder to return the feed for the
- * contents.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param folderResourceId the resource id of the folder to return the
feed for the
+ * contents.
+ * @return the folder docs list feed
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListFeed getFolderDocsListFeed(String folderResourceId)
- throws IOException, MalformedURLException, ServiceException,
+ public DocumentListFeed getFolderDocsListFeed(String folderResourceId)
throws IOException, MalformedURLException, ServiceException,
DocumentListException {
if (folderResourceId == null) {
throw new DocumentListException("null folderResourceId");
}
- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/"
- + folderResourceId + URL_FOLDERS);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" +
folderResourceId + URL_FOLDERS);
return service.getFeed(url, DocumentListFeed.class);
}
-

/**
* Gets the feed for all the folders contained in a folder.
- *
- * @param folderResourceId
- * the resource id of the folder to return the feed for the
- * contents.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param folderResourceId the resource id of the folder to return the
feed for the
+ * contents.
+ * @return the sub folders
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListFeed getSubFolders(String folderResourceId)
- throws IOException, MalformedURLException, ServiceException,
- DocumentListException {
+ public DocumentListFeed getSubFolders(String folderResourceId) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (folderResourceId == null) {
throw new DocumentListException("null folderResourceId");
}
String[] parameters = { PARAMETER_SHOW_FOLDERS };
- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/"
- + folderResourceId + URL_FOLDERS + URL_CATEGORY_FOLDER, parameters);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" +
folderResourceId + URL_FOLDERS + URL_CATEGORY_FOLDER, parameters);
return service.getFeed(url, DocumentListFeed.class);
}

/**
* Gets a feed containing the documents.
- *
- * @param resourceId
- * the resource id of the object to fetch revisions for.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to fetch revisions for.
+ * @return the revisions feed
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public RevisionFeed getRevisionsFeed(String resourceId) throws
IOException,
- MalformedURLException, ServiceException, DocumentListException {
+ public RevisionFeed getRevisionsFeed(String resourceId) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (resourceId == null) {
throw new DocumentListException("null resourceId");
}

- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId
- + URL_REVISIONS);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId +
URL_REVISIONS);

return service.getFeed(url, RevisionFeed.class);
}

/**
* Search the documents, and return a feed of docs that match.
- *
- * @param searchParameters
- * parameters to be used in searching criteria.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param searchParameters parameters to be used in searching criteria.
+ * @return the document list feed
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListFeed search(Map<String, String> searchParameters)
- throws IOException, MalformedURLException, ServiceException,
+ public DocumentListFeed search(Map<String, String> searchParameters)
throws IOException, MalformedURLException, ServiceException,
DocumentListException {
return search(searchParameters, null);
}
@@ -512,8 +455,7 @@
* @throws ServiceException
* @throws DocumentListException
*/
- public DocumentListFeed search(Map<String, String> searchParameters,
- String category) throws IOException, MalformedURLException,
+ public DocumentListFeed search(Map<String, String> searchParameters,
String category) throws IOException, MalformedURLException,
ServiceException, DocumentListException {
if (searchParameters == null) {
throw new DocumentListException("searchParameters null");
@@ -524,20 +466,15 @@
if (category == null || category.equals("")) {
url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED);
} else if (category.equals("documents")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_DOCUMENT);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_DOCUMENT);
} else if (category.equals("spreadsheets")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_SPREADSHEET);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED +
URL_CATEGORY_SPREADSHEET);
} else if (category.equals("presentations")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_PRESENTATION);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED +
URL_CATEGORY_PRESENTATION);
} else if (category.equals("starred")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_STARRED);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_STARRED);
} else if (category.equals("trashed")) {
- url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED
- + URL_CATEGORY_TRASHED);
+ url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_TRASHED);
} else if (category.equals("folders")) {
url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_FOLDER);
} else {
@@ -555,40 +492,37 @@

/**
* Upload a file.
- *
- * @param filepath
- * path to uploaded file.
- * @param title
- * title to use for uploaded file.
- *
- * @throws ServiceException
- * when the request causes an error in the Doclist service.
- * @throws IOException
- * when an error occurs in communication with the Doclist
- * service.
- * @throws DocumentListException
+ *
+ * @param filepath path to uploaded file.
+ * @param title title to use for uploaded file.
+ * @param convert the convert
+ * @param hidden the hidden
+ * @return the document list entry
+ * @throws IOException when an error occurs in communication with the
Doclist
+ * service.
+ * @throws ServiceException when the request causes an error in the
Doclist service.
+ * @throws DocumentListException the document list exception
*/
- public DocumentListEntry uploadFile(String filepath, String title,
boolean convert, boolean hidden)
- throws IOException, ServiceException, DocumentListException {
+ public DocumentListEntry uploadFile(String filepath, String title,
boolean convert, boolean hidden) throws IOException, ServiceException,
+ DocumentListException {
if (filepath == null || title == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

File file = new File(filepath);

DocumentEntry newDocument = new DocumentEntry();
-
+
String mimeType = "";
try {
mimeType =
DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
} catch (IllegalArgumentException e) {
}
-
+
if (mimeType != "") {
newDocument.setFile(file, mimeType);
}
-
+
newDocument.setTitle(new PlainTextConstruct(title));
newDocument.setHidden(hidden);

@@ -598,88 +532,77 @@
}
return service.insert(buildUrl(url), newDocument);
}
-

/**
* Upload a file to a folder.
- *
- * @param filepath
- * path to uploaded file.
- * @param title
- * title to use for uploaded file.
- *
- * @throws ServiceException
- * when the request causes an error in the Doclist service.
- * @throws IOException
- * when an error occurs in communication with the Doclist
- * service.
- * @throws DocumentListException
+ *
+ * @param filepath path to uploaded file.
+ * @param title title to use for uploaded file.
+ * @param folderResourceId the folder resource id
+ * @param convert the convert
+ * @param hidden the hidden
+ * @return the document list entry
+ * @throws IOException when an error occurs in communication with the
Doclist
+ * service.
+ * @throws ServiceException when the request causes an error in the
Doclist service.
+ * @throws DocumentListException the document list exception
*/
public DocumentListEntry uploadFileToFolder(String filepath, String
title, String folderResourceId, boolean convert, boolean hidden)
throws IOException, ServiceException, DocumentListException {
if (filepath == null || title == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

File file = new File(filepath);

DocumentEntry newDocument = new DocumentEntry();
-
+
String mimeType = "";
try {
mimeType =
DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
} catch (IllegalArgumentException e) {
}
-
+
if (mimeType != "") {
newDocument.setFile(file, mimeType);
}
-
+
newDocument.setTitle(new PlainTextConstruct(title));
newDocument.setHidden(hidden);
-
+
String url = URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderResourceId +
URL_FOLDERS;
if (!convert) {
url += "?convert=false";
}
-
+
return service.insert(buildUrl(url), newDocument);
}
-
- public DocumentListEntry updateFile(String filepath, String title,
DocumentListEntry entry, boolean hidden)
- throws IOException, ServiceException, DocumentListException {
+
+ public DocumentListEntry updateFile(String filepath, String title,
DocumentListEntry entry, boolean hidden) throws IOException,
ServiceException,
+ DocumentListException {
if (filepath == null || title == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
- }
-
+ throw new DocumentListException("null passed in for required
parameters");
+ }
+
File file = new File(filepath);
- String mimeType = DocumentListEntry.MediaType.fromFileName(
- file.getName()).getMimeType();
-
+ String mimeType =
DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
+
entry.setFile(file, mimeType);
entry.setHidden(hidden);
return entry.updateMedia(true);
}
-

/**
* Trash an object.
- *
- * @param resourceId
- * the resource id of object to be trashed.
- * @param delete
- * true to delete the permanently, false to move it to the
trash.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of object to be trashed.
+ * @param delete true to delete the permanently, false to move it to the
trash.
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void trashObject(String resourceId, boolean delete)
- throws IOException, MalformedURLException, ServiceException,
- DocumentListException {
+ public void trashObject(String resourceId, boolean delete) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (resourceId == null) {
throw new DocumentListException("null resourceId");
}
@@ -689,55 +612,42 @@
feedUrl += "?delete=true";
}

- service.delete(buildUrl(feedUrl), getDocsListEntry(resourceId)
- .getEtag());
+ service.delete(buildUrl(feedUrl),
getDocsListEntry(resourceId).getEtag());
}

/**
* Remove an object from a folder.
- *
- * @param resourceId
- * the resource id of an object to be removed from the folder.
- * @param folderResourceId
- * the resource id of the folder to remove the object from.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of an object to be removed from the
folder.
+ * @param folderResourceId the resource id of the folder to remove the
object from.
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void removeFromFolder(String resourceId, String folderResourceId)
- throws IOException, MalformedURLException, ServiceException,
+ public void removeFromFolder(String resourceId, String folderResourceId)
throws IOException, MalformedURLException, ServiceException,
DocumentListException {
if (resourceId == null || folderResourceId == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/"
- + folderResourceId + URL_FOLDERS + "/" + resourceId);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" +
folderResourceId + URL_FOLDERS + "/" + resourceId);
service.delete(url, getDocsListEntry(resourceId).getEtag());
}

/**
* Downloads a file.
- *
- * @param exportUrl
- * the full url of the export link to download the file from.
- * @param filepath
- * path and name of the object to be saved as.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param exportUrl the full url of the export link to download the file
from.
+ * @param filepath path and name of the object to be saved as.
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void downloadFile(URL exportUrl, String filepath)
- throws IOException, MalformedURLException, ServiceException,
- DocumentListException {
+ public void downloadFile(URL exportUrl, String filepath) throws
IOException, MalformedURLException, ServiceException, DocumentListException
{
if (exportUrl == null || filepath == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

MediaContent mc = new MediaContent();
@@ -768,49 +678,38 @@

/**
* Downloads a spreadsheet file.
- *
- * @param filepath
- * path and name of the object to be saved as.
- * @param resourceId
- * the resource id of the object to be downloaded.
- * @param format
- * format to download the file to. The following file types are
- * supported: spreadsheets: "ods", "pdf", "xls", "csv", "html",
- * "tsv"
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to be downloaded.
+ * @param filepath path and name of the object to be saved as.
+ * @param format format to download the file to. The following file types
are
+ * supported: spreadsheets: "ods", "pdf", "xls", "csv", "html",
+ * "tsv"
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void downloadSpreadsheet(String resourceId, String filepath,
- String format) throws IOException, MalformedURLException,
- ServiceException, DocumentListException {
+ public void downloadSpreadsheet(String resourceId, String filepath,
String format) throws IOException, MalformedURLException, ServiceException,
+ DocumentListException {
if (resourceId == null || filepath == null || format == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

- UserToken docsToken = (UserToken) service.getAuthTokenFactory()
- .getAuthToken();
- UserToken spreadsheetsToken = (UserToken) spreadsheetsService
- .getAuthTokenFactory().getAuthToken();
+ UserToken docsToken = (UserToken)
service.getAuthTokenFactory().getAuthToken();
+ UserToken spreadsheetsToken = (UserToken)
spreadsheetsService.getAuthTokenFactory().getAuthToken();
service.setUserToken(spreadsheetsToken.getValue());

HashMap<String, String> parameters = new HashMap<String, String>();
- parameters.put("key", resourceId
- .substring(resourceId.lastIndexOf(':') + 1));
+ parameters.put("key", resourceId.substring(resourceId.lastIndexOf(':') +
1));
parameters.put("exportFormat", format);

// If exporting to .csv or .tsv, add the gid parameter to specify which
// sheet to export
- if (format.equals(DOWNLOAD_SPREADSHEET_FORMATS.get("csv"))
- || format.equals(DOWNLOAD_SPREADSHEET_FORMATS.get("tsv"))) {
+ if (format.equals(DOWNLOAD_SPREADSHEET_FORMATS.get("csv")) ||
format.equals(DOWNLOAD_SPREADSHEET_FORMATS.get("tsv"))) {
parameters.put("gid", "0"); // download only the first sheet
}

- URL url = buildUrl(SPREADSHEETS_HOST, URL_DOWNLOAD + "/spreadsheets"
- + URL_CATEGORY_EXPORT, parameters);
+ URL url = buildUrl(SPREADSHEETS_HOST, URL_DOWNLOAD + "/spreadsheets" +
URL_CATEGORY_EXPORT, parameters);

downloadFile(url, filepath);

@@ -820,224 +719,178 @@

/**
* Downloads a document.
- *
- * @param filepath
- * path and name of the object to be saved as.
- * @param resourceId
- * the resource id of the object to be downloaded.
- * @param format
- * format to download the file to. The following file types are
- * supported: documents: "doc", "txt", "odt", "png", "pdf",
- * "rtf", "html"
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to be downloaded.
+ * @param filepath path and name of the object to be saved as.
+ * @param format format to download the file to. The following file types
are
+ * supported: documents: "doc", "txt", "odt", "png", "pdf",
+ * "rtf", "html"
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void downloadDocument(String resourceId, String filepath,
- String format) throws IOException, MalformedURLException,
- ServiceException, DocumentListException {
+ public void downloadDocument(String resourceId, String filepath, String
format) throws IOException, MalformedURLException, ServiceException,
+ DocumentListException {
if (resourceId == null || filepath == null || format == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}
String[] parameters = { "docID=" + resourceId, "exportFormat=" + format
};
- URL url = buildUrl(URL_DOWNLOAD + "/documents" + URL_CATEGORY_EXPORT,
- parameters);
+ URL url = buildUrl(URL_DOWNLOAD + "/documents" + URL_CATEGORY_EXPORT,
parameters);

downloadFile(url, filepath);
}

/**
* Downloads a presentation.
- *
- * @param filepath
- * path and name of the object to be saved as.
- * @param resourceId
- * the resource id of the object to be downloaded.
- * @param format
- * format to download the file to. The following file types are
- * supported: presentations: "pdf", "ppt", "png", "swf", "txt"
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to be downloaded.
+ * @param filepath path and name of the object to be saved as.
+ * @param format format to download the file to. The following file types
are
+ * supported: presentations: "pdf", "ppt", "png", "swf", "txt"
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public void downloadPresentation(String resourceId, String filepath,
- String format) throws IOException, MalformedURLException,
- ServiceException, DocumentListException {
+ public void downloadPresentation(String resourceId, String filepath,
String format) throws IOException, MalformedURLException, ServiceException,
+ DocumentListException {
if (resourceId == null || filepath == null || format == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

String[] parameters = { "docID=" + resourceId, "exportFormat=" + format
};
- URL url = buildUrl(URL_DOWNLOAD + "/presentations"
- + URL_CATEGORY_EXPORT, parameters);
+ URL url = buildUrl(URL_DOWNLOAD + "/presentations" +
URL_CATEGORY_EXPORT, parameters);

downloadFile(url, filepath);
}

/**
* Moves a object to a folder.
- *
- * @param resourceId
- * the resource id of the object to be moved to the folder.
- * @param folderId
- * the id of the folder to move the object to.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to be moved to the
folder.
+ * @param folderId the id of the folder to move the object to.
+ * @return the document list entry
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public DocumentListEntry moveObjectToFolder(String resourceId,
- String folderId) throws IOException, MalformedURLException,
- ServiceException, DocumentListException {
+ public DocumentListEntry moveObjectToFolder(String resourceId, String
folderId) throws IOException, MalformedURLException, ServiceException,
+ DocumentListException {
if (resourceId == null || folderId == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

DocumentListEntry doc = new DocumentListEntry();
- doc.setId(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId)
- .toString());
-
- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderId
- + URL_FOLDERS);
+ doc.setId(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" +
resourceId).toString());
+
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderId +
URL_FOLDERS);
return service.insert(url, doc);
}

/**
* Gets the access control list for a object.
- *
- * @param resourceId
- * the resource id of the object to retrieve the ACL for.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param resourceId the resource id of the object to retrieve the ACL
for.
+ * @return the acl feed
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public AclFeed getAclFeed(String resourceId) throws IOException,
- MalformedURLException, ServiceException, DocumentListException {
+ public AclFeed getAclFeed(String resourceId) throws IOException,
MalformedURLException, ServiceException, DocumentListException {
if (resourceId == null) {
throw new DocumentListException("null resourceId");
}

- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId
- + URL_ACL);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId +
URL_ACL);

return service.getFeed(url, AclFeed.class);
}

/**
* Add an ACL role to an object.
- *
- * @param role
- * the role of the ACL to be added to the object.
- * @param scope
- * the scope for the ACL.
- * @param resourceId
- * the resource id of the object to set the ACL for.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param role the role of the ACL to be added to the object.
+ * @param scope the scope for the ACL.
+ * @param resourceId the resource id of the object to set the ACL for.
+ * @return the acl entry
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public AclEntry addAclRole(AclRole role, AclScope scope, String
resourceId)
- throws IOException, MalformedURLException, ServiceException,
+ public AclEntry addAclRole(AclRole role, AclScope scope, String
resourceId) throws IOException, MalformedURLException, ServiceException,
DocumentListException {
if (role == null || scope == null || resourceId == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
}

AclEntry entry = new AclEntry();
entry.setRole(role);
entry.setScope(scope);
- URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId
- + URL_ACL);
+ URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId +
URL_ACL);

return service.insert(url, entry);
}

/**
* Change the ACL role of a file.
- *
- * @param role
- * the new role of the ACL to be updated.
- * @param scope
- * the new scope for the ACL.
- * @param resourceId
- * the resource id of the object to be updated.
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws ServiceException
- * @throws DocumentListException
+ *
+ * @param role the new role of the ACL to be updated.
+ * @param scope the new scope for the ACL.
+ * @param resourceId the resource id of the object to be updated.
+ * @return the acl entry
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws MalformedURLException the malformed url exception
+ * @throws ServiceException the service exception
+ * @throws DocumentListException the document list exception
*/
- public AclEntry changeAclRole(AclRole role, AclScope scope,
- String resourceId) throws IOException, MalformedURLException,
- ServiceException, DocumentListException {
+ public AclEntry changeAclRole(AclRole role, AclScope scope, String
resourceId) throws IOException, MalformedURLException, ServiceException,
+ DocumentListException {
if (role == null || scope == null || resourceId == null) {
- throw new DocumentListException(
- "null passed in for required parameters");
+ throw new DocumentListException("null passed in for required
parameters");
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/src/GoogleDocsUpload.java Tue Jan 18 03:09:35 2011
+++ /trunk/src/GoogleDocsUpload.java Sun Mar 20 15:27:32 2011
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2010 Anton Beloglazov, http://beloglazov.info
+/* Copyright (c) 2009-2011 Anton Beloglazov, http://beloglazov.info
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@
*
* @author Anton Beloglazov
* @since 03/09/2009
- * @version 1.4.2 18/01/2010
+ * @version 1.4.3 21/03/2011
*/
public class GoogleDocsUpload {

@@ -130,14 +130,14 @@

/** Welcome message, introducing the program. */
protected static final String[] WELCOME_MESSAGE = { "",
- "Google Docs Upload 1.4.2",
+ "Google Docs Upload 1.4.3",
"Using this tool, you can batch upload your documents to a Google Docs
account preserving folder structure.",
"Type 'help' for a list of parameters.", ""
};

/** The message for displaying the usage parameters. */
protected static final String[] USAGE_MESSAGE = { "",
- "Google Docs Upload 1.4.2",
+ "Google Docs Upload 1.4.3",
"",
"Usage: java -jar google-docs-upload.jar",
"Usage: java -jar google-docs-upload.jar <path> --recursive",
@@ -203,12 +203,11 @@

/**
* Runs the application.
- *
+ *
* @param args the command-line arguments
- *
* @throws DocumentListException the document list exception
- * @throws ServiceException the service exception
* @throws IOException Signals that an I/O exception has occurred.
+ * @throws ServiceException the service exception
*/
public static void main(String[] args) throws DocumentListException,
IOException, ServiceException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
@@ -309,12 +308,11 @@

/**
* Authenticates the client using ClientLogin.
- *
+ *
* @param username User's username
* @param password User's password
- *
- * @throws DocumentListException the document list exception
* @throws AuthenticationException the authentication exception
+ * @throws DocumentListException the document list exception
*/
public void login(String username, String password) throws
AuthenticationException, DocumentListException {
getDocumentList().login(username, password);
@@ -322,11 +320,10 @@

/**
* Authenticates the client using AuthSub.
- *
+ *
* @param authSubToken the auth sub token
- *
- * @throws DocumentListException the document list exception
* @throws AuthenticationException the authentication exception
+ * @throws DocumentListException the document list exception
*/
public void login(String authSubToken) throws AuthenticationException,
DocumentListException {
getDocumentList().loginWithAuthSubToken(authSubToken);
@@ -496,10 +493,17 @@
printLine(" - Uploading without conversion");
}
}
+ String name = null;
+ if (convert) {
+ name = getFileName(file);
+ } else {
+ name = file.getName();
+ }
+
if (remoteFolder == null) {
- return getDocumentList().uploadFile(file.getAbsolutePath(),
getFileName(file), convert, isOptionHideAll());
+ return getDocumentList().uploadFile(file.getAbsolutePath(), name,
convert, isOptionHideAll());
} else {
- return getDocumentList().uploadFileToFolder(file.getAbsolutePath(),
getFileName(file), remoteFolder.getResourceId(), convert,
isOptionHideAll());
+ return getDocumentList().uploadFileToFolder(file.getAbsolutePath(),
name, remoteFolder.getResourceId(), convert, isOptionHideAll());
}
} catch (ServiceForbiddenException e) {
printLine(" - Uploading without conversion is only available to
Google Apps for Business accounts");
@@ -645,7 +649,7 @@
DocumentListEntry parentRemoteFolder = null;
DocumentListEntry currentRemoteFolder = null;
for (String folder : pathArray) {
- if (folder.length() == 0) {
+ if (folder.isEmpty()) {
continue;
}
currentRemoteFolder = documentListFindByTitle(folder, remoteSubFolders);
@@ -655,7 +659,7 @@
currentRemoteFolder = getDocumentList().createNew(folder, "folder");
} else {
currentRemoteFolder = getDocumentList().createNewSubFolder(folder,
parentRemoteFolder.getResourceId());
- }
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -717,10 +721,16 @@
* @return the file name
*/
protected static String getFileName(File file) {
+ String name = null;
if (file.getName().lastIndexOf(".") != -1) {
- return file.getName().substring(0, file.getName().lastIndexOf("."));
- }
- return file.getName();
+ name = file.getName().substring(0, file.getName().lastIndexOf("."));
+ } else {
+ name = file.getName();
+ }
+ if (name == null || name.isEmpty()) {
+ name = "Unnamed";
+ }
+ return name;
}

/**
Reply all
Reply to author
Forward
0 new messages