forked from xwiki-contrib/application-googleapps
-
Notifications
You must be signed in to change notification settings - Fork 7
Java ize2 #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
polx
wants to merge
17
commits into
xwikisas:master
Choose a base branch
from
polx:java-ize2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Java ize2 #39
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
861f2b8
Style comments on the PR.
polx 80ac30e
Forgotten to address this request. Thanks for the reminder.
polx 38eeefa
Readability comments from @acotiuga and @mflorea. Thanks.
polx a5a6938
Introducing GoogleAppsException and thus removing the API-level depen…
polx 0f0139b
Changing package to com.xwiki.googleapps.
polx cc89974
Moved a few components to the internal package (and making their role…
polx bda0e8e
Code-style automatic adjustments with correct (XWiki) style.
polx 782b36d
Unstability for complete classes.
polx 70368b2
Do use the GoogleAppsListener!
polx 48c0b31
Indenting.
polx 4e44d34
Indenting and normalising spaces.
polx 1927504
Refactoring methods to fetch drive-documents to get rid of gdata and …
polx 8bc27e8
Refactoring for complexity and syntax style.
polx c823813
Comments' fixes: mostly cleaned up code a bit (see https://github.co…
polx 643fb3c
Comments' fixes: do not fix version in the POM and do not make half b…
polx d810949
Removing complex constructors in favor of internal components.
polx 0952fbd
The redirect URL is not OAuth anymore.
polx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,4 +38,6 @@ nbproject | |
| *.log.* | ||
| *.log | ||
| .sonar-ide.properties | ||
| .clover | ||
| .clover | ||
| .DS_Store | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
203 changes: 203 additions & 0 deletions
203
api/src/main/java/com/xwiki/googleapps/DriveDocMetadata.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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<>(); | ||
|
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. | ||
|
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() | ||
|
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
84
api/src/main/java/com/xwiki/googleapps/GoogleAppsException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why |
||
| { | ||
| private static final long serialVersionUID = 3000; | ||
|
|
||
| /** | ||
|
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; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.