Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ nbproject
*.log.*
*.log
.sonar-ide.properties
.clover
.clover
.DS_Store

40 changes: 6 additions & 34 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>application-googleapps-api</artifactId>
<version>3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Google Apps Integration (API)</name>
<description>This is the XWiki-API part of the Google Apps which allows to connect Google Apps to XWiki.</description>
Expand All @@ -42,11 +41,6 @@
<artifactId>google-api-client</artifactId>
<version>1.24.1</version>
</dependency>
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
<version>1.47.1</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-people</artifactId>
Expand All @@ -57,33 +51,11 @@
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev358-1.24.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
Comment thread
polx marked this conversation as resolved.
Outdated
<scope>provided</scope>
</dependency>
</dependencies>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/xwikisas/application-googleapps/issues</url>
</issueManagement>
<scm>
<connection>scm:git:git://github.com/xwikisas/application-googleapps.git</connection>
<developerConnection>scm:git:git@github.com:xwikisas/application-googleapps.git</developerConnection>
<url>https://github.com/xwikisas/application-googleapps</url>
<tag>HEAD</tag>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>false</failOnViolation>
</configuration>
<executions>
<execution>
<id>checkstyle-validation</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
203 changes: 203 additions & 0 deletions api/src/main/java/com/xwiki/googleapps/DriveDocMetadata.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This 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 2.1 of
* the License, or (at your option) any later version.
*
* This software 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 this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.googleapps;

import java.util.LinkedList;
import java.util.List;

import org.xwiki.stability.Unstable;

/**
* Simple pojo for metadata about a doc in Google Drive.
*
* @version $Id$
* @since 3.0
*/
@Unstable
public class DriveDocMetadata
{
/**
* Google's internal id to find the document again.
*/
public String id;

/**
* URL to direct the user to for editing.
*/
public String editLink;

/**
* URL to pull from in order to fetch the document.
*/
public String exportLink;

/**
* URL to use to show an embedded view.
*/
public String embedLink;

/**
* A stringified version number.
*/
public String version;

/**
* The name of the file in case it is an uploaded file.
*/
public String fileName;

/**
* The email-address of the user with which this document's connection was created.
*/
public String user;

/**
* A list of export possibilities.
*/
public List<ExportAlternative> exportLinksAlternatives = new LinkedList<>();
Comment thread
polx marked this conversation as resolved.
Outdated

/**
* @return the internal Google Id of the document.
*/
public String getId()
{
return id;
}

/**
* @return the version number
*/
public String getVersion()
{
return version;
}

/**
* @return the URL to direct the user to for editing.
*/
public String getEditLink()
{
return editLink;
}

/**
* @return the URL to pull from in order to fetch the document.
*/
public String getExportLink()
{
return exportLink;
}

/**
* @return a list of export alternatives.
*/
public List<ExportAlternative> getExportLinksAlternatives()
{
return exportLinksAlternatives;
}

/**
* Inserts one of the information about one of the export-alternatives.
*
* @param extension understood the file type.
Comment thread
polx marked this conversation as resolved.
Outdated
* @param newFileName the filename when this file is stored on a desktop with this type
* @param exportUrl the url to pull from.
*/
public void addExportAlternative(String extension, String newFileName, String exportUrl)
{
ExportAlternative ea = new ExportAlternative();
ea.extension = extension;
ea.exportUrl = exportUrl;
ea.newFileName = newFileName;
if (ea.newFileName == null) {
ea.newFileName = "unnamed";
}
exportLinksAlternatives.add(ea);
}

/**
* @return the name of the file in case it is an uploaded file.
*/
public String getFileName()
{
return fileName;
}

/**
* @return the same as {#getFileName}.
*/
public String getTitle()
{
return fileName;
}

/**
* @return a useful string representation
*/
public String toString()
{
return "id " + id + " edit: " + editLink + " export " + exportLink;
}

/**
* A class to denote export possibilities of a drive file.
*/
public static class ExportAlternative
{
/**
* a short nickname of the file type, typically the file-ending.
*/
public String extension;

/**
* the revised filename if exported to this extension.
*/
public String newFileName;

/**
* the URL to pull from.
*/
public String exportUrl;

/**
* @return a short nickname of the file type, typically the file-ending.
*/
public String getExtension()
Comment thread
polx marked this conversation as resolved.
{
return extension;
}

/**
* @return the revised filename if exported to this extension.
*/
public String getNewFileName()
{
return newFileName;
}

/**
* @return the URL to pull from.
*/
public String getExportUrl()
{
return exportUrl;
}
}
}
84 changes: 84 additions & 0 deletions api/src/main/java/com/xwiki/googleapps/GoogleAppsException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This 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 2.1 of
* the License, or (at your option) any later version.
*
* This software 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 this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.googleapps;

import java.io.IOException;

import org.xwiki.stability.Unstable;

import com.xpn.xwiki.XWikiException;

/**
* Generic class to denote an exception condition within the GoogleApps code. Wraps XWikiException and IOException.
*
* @version $Id$
* @since 3.0
*/
@Unstable
public class GoogleAppsException extends RuntimeException
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why RuntimeException and not Exception? Since you have methods throwing it then it means its an "expected" exception, so code calling such a method should handle it.

{
private static final long serialVersionUID = 3000;

/**
Comment thread
polx marked this conversation as resolved.
* @param msg Message to denote the error for programmers.
* @param wrapped Exception that has caused this one.
* @since 3.0
*/
public GoogleAppsException(String msg, Exception wrapped)
{
super(msg, wrapped);
}

/**
* @param msg Message to denote the error for programmers.
* @since 3.0
*/
public GoogleAppsException(String msg)
{
super(msg);
}

/**
* @param wrapped Exception that has caused this one.
* @since 3.0
*/
public GoogleAppsException(Exception wrapped)
{
super(wrapped);
}

/**
* @return true if the wrapped exception of XWiki origin.
* @since 3.0
*/
public boolean isWikiException()
{
return getCause() instanceof XWikiException;
}

/**
* @return true if the wrapped exception of Google origin (for now: any IO-related exception).
* @since 3.0
*/
public boolean isGoogleException()
{
return getCause() instanceof IOException;
}
}
Loading