Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cetra3 committed Jul 20, 2016
2 parents 0e124ec + 2edfc22 commit 9544dc4
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 206 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.gradle/
.idea/
*.iml
build/
gradle/
gradlew*
113 changes: 40 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,57 @@
# Alfresco Onlyoffice Integration
# Alfresco ONLYOFFICE integration

This Share plugin enables users to edit Office documents within Onlyoffice from Alfresco Share. Tested with Enterprise 5.0.\*
This Share plugin enables users to edit Office documents within ONLYOFFICE from Alfresco Share. This will create a new **Edit in ONLYOFFICE** action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to Alfresco.

## Features
* This will create a new **Edit in Onlyoffice** action within the document library for Office documents.
* This allows multiple users to collaborate in real time and to save back those changes to Alfresco.
Tested with Enterprise 5.0.\*, 5.1.\* and Community 5.1.\*


## Requirements
* For Alfresco Enterprise 5.0.\* and later
## Compiling

## Installation
You will need:

### OnlyOffice
* Java 7 SDK or above

You will need an instance of onlyoffice that is resolvable and
connectable both from alfresco and any end clients. Onlyoffice must
also be able to POST to alfresco directly.
* Gradle

The easiest way to start an instance of onlyoffice is to use Docker: https://github.com/ONLYOFFICE/Docker-DocumentServer
* Parashift's alfresco amp plugin from here: https://bitbucket.org/parashift/alfresco-amp-plugin

### Alfresco
* Run `gradle amp` from the `share` and `repo` directories

* Deploy the amp to both the repo and share end using alfresco-mmt or
other methods

* Add the `onlyoffice.url` property to alfresco-global.properties:
* e.g: `onlyoffice.url=http://onlyoffice.mycompany.com/` or `onlyoffice.url=http://localhost/`

This will tell Alfresco to find onlyoffice instance via port 80, if you need to start onlyoffice via other port rather than 80, then you need to add port information as well
Also, you need to make sure the `/etc/hosts` file contain the right mapping, i.e., `127.0.0.1 localhost`
## Installation

## Compiling
If you've alfready downloaded the compiled amps, please skip this section
### ONLYOFFICE

You will need:
You will need an instance of ONLYOFFICE that is resolvable and connectable both from alfresco and any end clients. ONLYOFFICE must also be able to POST to alfresco directly.

* Java 7 SDK or above
The easiest way to start an instance of ONLYOFFICE is to use Docker: https://github.com/ONLYOFFICE/Docker-DocumentServer

* Gradle

* Parashift's alfresco amp plugin from here: https://bitbucket.org/parashift/alfresco-amp-plugin
### Alfresco

* Run the command below under the project folder
```
gradle -b repo/build.gradle amp
gradle -b share/build.gradle amp
```

## Usage
In document detail page, new action option `Edit in OnlyOffice` will be able to use as below:

![editinonlyoffice](edit_in_onlyoffice.png)

### How it works

The Onlyoffice integration follows the API documented here
https://api.onlyoffice.com/editors/basic:

* User navigates to a document within Alfresco Share and selects the
`Edit in Onlyoffice` action
* Alfresco Share makes a request to the repo end (URL of the form: `/parashift/onlyoffice/prepare?nodeRef={nodeRef}`)
* Alfresco Repo end prepares a JSON object for Share with the following
properties:
* **docUrl**: the URL that onlyoffice uses to download the document
(includes the `alf_ticket` of the current user)
* **callbackUrl**: the URL that onlyoffice needs to POST a callback to
when finished editing
* **onlyofficeUrl**: the URL that the client needs to talk to onlyoffice
(given by the onlyoffice.url property)
* **key**: the UUID+Modified Timestamp to instruct onlyoffice whether to download the document again or not
* **docTitle**: the Title (name) of the document
* Alfresco Share takes this object and constructs a page from a
freemarker template, filling in all of those values so that the client
browser can load up the editor
* The client browser makes a request for the javascript library from
onlyoffice and sends onlyoffice the docEditor configuration with the
properties as above
* Onlyoffice then downloads the document from alfresco and the user begins editing
* Onlyoffice sends a POST request to the callback URL to inform Alfresco
that a user is editing the document
* Alfresco locks the document, but still allows other users with write access
the ability to collaborate in real time with onlyoffice by leaving the Action present
* When all users and client browsers are finished, they close the
editing window
* After 10 seconds of inactivity, onlyoffice sends a POST to the
callback URL letting Alfresco know that the clients have finished.
* Alfresco downloads the new version of the document, replacing the old
one
* Deploy the amp to both the repo and share end using alfresco-mmt or other methods

* Add the `onlyoffice.url` property to alfresco-global.properties:
* e.g: `onlyoffice.url=http://documentserver/`


## How it works

The ONLYOFFICE integration follows the API documented here https://api.onlyoffice.com/editors/basic:

* User navigates to a document within Alfresco Share and selects the `Edit in ONLYOFFICE` action.
* Alfresco Share makes a request to the repo end (URL of the form: `/parashift/onlyoffice/prepare?nodeRef={nodeRef}`).
* Alfresco Repo end prepares a JSON object for Share with the following properties:
* **docUrl**: the URL that ONLYOFFICE uses to download the document (includes the `alf_ticket` of the current user),
* **callbackUrl**: the URL that ONLYOFFICE informs about status of the document editing,
* **onlyofficeUrl**: the URL that the client needs to talk to ONLYOFFICE (given by the onlyoffice.url property),
* **key**: the UUID+Modified Timestamp to instruct ONLYOFFICE whether to download the document again or not,
* **docTitle**: the Title (name) of the document.
* Alfresco Share takes this object and constructs a page from a freemarker template, filling in all of those values so that the client browser can load up the editor.
* The client browser makes a request for the javascript library from ONLYOFFICE and sends ONLYOFFICE the docEditor configuration with the properties as above.
* ONLYOFFICE then downloads the document from alfresco and the user begins editing.
* ONLYOFFICE sends a POST request to the callback URL to inform Alfresco that a user is editing the document.
* Alfresco locks the document, but still allows other users with write access the ability to collaborate in real time with ONLYOFFICE by leaving the Action present.
* When all users and client browsers are finished, they close the editing window.
* After 10 seconds of inactivity, ONLYOFFICE sends a POST to the callback URL letting Alfresco know that the clients have finished.
* Alfresco downloads the new version of the document, replacing the old one.
6 changes: 2 additions & 4 deletions repo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ext {



project.description = "Onlyoffice Integration for Alfresco"
project.description = "ONLYOFFICE Integration for Alfresco"
version = "git describe --tags".execute().text.trim()

repositories {
Expand Down Expand Up @@ -72,9 +72,7 @@ jar {
amp {
id = "com.parashift." + project.name
version = project.version
title = "Onlyoffice Alfresco Integration Repo"
title = "ONLYOFFICE Alfresco Integration Repo"
description = project.description
}



10 changes: 8 additions & 2 deletions repo/src/main/java/com/parashift/onlyoffice/CallBack.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
/**
* Created by cetra on 20/10/15.
*/
/*
Copyright (c) Ascensio System SIA 2016. All rights reserved.
http://www.onlyoffice.com
*/
@Component(value = "webscript.onlyoffice.callback.post")
public class CallBack extends AbstractWebScript {

Expand Down Expand Up @@ -57,7 +61,7 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws

switch(callBackJSon.getInt("status")) {
case 0:
logger.error("Onlyoffice has reported that no doc with the specified key can be found");
logger.error("ONLYOFFICE has reported that no doc with the specified key can be found");
lockService.unlock(nodeRef);
break;
case 1:
Expand All @@ -75,14 +79,16 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
updateNode(nodeRef, callBackJSon.getString("url"));
break;
case 3:
logger.error("Onlyoffice has reported that saving the document has failed");
logger.error("ONLYOFFICE has reported that saving the document has failed");
lockService.unlock(nodeRef);
break;
case 4:
logger.debug("No document updates, unlocking node");
lockService.unlock(nodeRef);
break;
}

response.getWriter().write("{\"error\":0}");
}

private void updateNode(NodeRef nodeRef, String url) {
Expand Down
4 changes: 4 additions & 0 deletions repo/src/main/java/com/parashift/onlyoffice/Prepare.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
* Created by cetra on 20/10/15.
* Sends Alfresco Share the necessaries to build up what information is needed for the OnlyOffice server
*/
/*
Copyright (c) Ascensio System SIA 2016. All rights reserved.
http://www.onlyoffice.com
*/
@Component(value = "webscript.onlyoffice.prepare.get")
public class Prepare extends AbstractWebScript {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<webscript>
<shortname>Onlyoffice CallBack URL</shortname>
<description>Callback URL for Onlyoffice to inform Alfresco</description>
<shortname>ONLYOFFICE CallBack URL</shortname>
<description>Callback URL for ONLYOFFICE to inform Alfresco</description>
<url>/parashift/onlyoffice/callback</url>
<authentication>user</authentication>
</webscript>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<webscript>
<shortname>Onlyoffice Prepare URL</shortname>
<description>Sends information to Share to prepare the Onlyoffice Edit Page</description>
<shortname>ONLYOFFICE Prepare URL</shortname>
<description>Sends information to Share to prepare the ONLYOFFICE Edit Page</description>
<url>/parashift/onlyoffice/prepare</url>
<authentication>user</authentication>
</webscript>
4 changes: 2 additions & 2 deletions share/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ allprojects {
targetCompatibility = 1.7
}

project.description = "Onlyoffice Integration for Alfresco Share"
project.description = "ONLYOFFICE Integration for Alfresco Share"
version = "git describe --tags".execute().text.trim()


Expand All @@ -39,7 +39,7 @@ amp {
// id is mandatory when you want to pack a AMP
id = "com.parashift" + project.name
version = project.version
title = "Onlyoffice Alfresco Integration Share"
title = "ONLYOFFICE Alfresco Integration Share"
description = project.description
}

11 changes: 0 additions & 11 deletions share/install.sh

This file was deleted.

4 changes: 2 additions & 2 deletions share/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<groupId>com.parashift.onlyoffice-alfresco</groupId>
<artifactId>onlyoffice-integration-share</artifactId>
<version>1.0.0</version>
<name>Onlyoffice Alfresco Integration</name>
<name>ONLYOFFICE Alfresco Integration</name>
<packaging>amp</packaging>
<description>This Module integrates Alfresco Share with Onlyoffice</description>
<description>This Module integrates Alfresco Share with ONLYOFFICE</description>

<parent>
<groupId>org.alfresco.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
Copyright (c) Ascensio System SIA 2016. All rights reserved.
http://www.onlyoffice.com
*/
html {
Expand All @@ -25,69 +25,3 @@ div {
padding: 0;
}


.top-panel {
background: url("logo.png") no-repeat 30px center #3D4A6B;
height: 80px;
width: 100%;
}
.main-panel {
margin: 105px auto 0;
width: 350px;
}
.portal-name {
color: #3D4A6B;
font-size: 20px;
}
.portal-descr {
display: inline-block;
line-height: 20px;
margin-bottom: 24px;
width: 480px;
}
.document-url {
height: 65px;
resize: vertical;
width: 350px;
}
.embedded {
margin: 105px auto 0;
width: 640px;
}

.button, .button:visited, .button:hover, .button:active {
display: inline-block;
font-weight: normal;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor:pointer;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
touch-callout: none;
-o-touch-callout: none;
-moz-touch-callout: none;
-webkit-touch-callout: none;
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
font-size: 12px;
line-height: 16px;
padding: 2px 12px;

color: #fff;

background: #3D96C6;
background: linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -o-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -moz-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -webkit-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#59B1E2', EndColorStr='#1A76a6')";

border-width: 1px;
border-style: solid;
border-color: #4da9dc #4098c9 #2d7399 #4098c9;
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
Copyright (c) Ascensio System SIA 2016. All rights reserved.
http://www.onlyoffice.com
*/
function key(k) {
Expand Down
Loading

0 comments on commit 9544dc4

Please sign in to comment.