Permalink
Browse files

Initial commit and fork from etherpad integration

  • Loading branch information...
cetra3
cetra3 committed Aug 16, 2015
0 parents commit 3d2420822f0d76113899bac3bfa5fadf4acb8d3a
Showing with 1,357 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +656 −0 LICENSE.md
  3. +114 −0 README.md
  4. +113 −0 repo/build.gradle
  5. +19 −0 repo/settings.gradle
  6. +41 −0 repo/src/main/java/com/parashift/onlyoffice/prepare.java
  7. +42 −0 share/build.gradle
  8. +11 −0 share/install.sh
  9. +64 −0 share/pom.xml
  10. +1 −0 share/settings.gradle
  11. +4 −0 share/src/main/amp/module.properties
  12. BIN share/src/main/resources/META-INF/components/documentlibrary/actions/document-onlyoffice-edit-16.png
  13. +93 −0 share/src/main/resources/META-INF/components/onlyoffice/onlyoffice.css
  14. +15 −0 share/src/main/resources/META-INF/components/onlyoffice/onlyoffice.js
  15. +15 −0 share/src/main/resources/META-INF/components/onlyoffice/sha256.js
  16. +1 −0 share/src/main/resources/alfresco/messages/onlyoffice.properties
  17. +24 −0 share/src/main/resources/alfresco/onlyoffice-config.xml
  18. +9 −0 share/src/main/resources/alfresco/site-data/pages/onlyoffice-edit.xml
  19. +16 −0 share/src/main/resources/alfresco/site-data/template-instances/onlyoffice-edit.xml
  20. +5 −0 share/src/main/resources/alfresco/site-webscripts/com/parashift/onlyoffice-edit.get.desc.xml
  21. +3 −0 share/src/main/resources/alfresco/site-webscripts/com/parashift/onlyoffice-edit.get.head.ftl
  22. +59 −0 share/src/main/resources/alfresco/site-webscripts/com/parashift/onlyoffice-edit.get.html.ftl
  23. +7 −0 share/src/main/resources/alfresco/site-webscripts/com/parashift/onlyoffice-edit.get.js
  24. +1 −0 share/src/main/resources/alfresco/templates/com/parashift/onlyoffice-edit.ftl
  25. +38 −0 share/src/main/resources/alfresco/web-extension/onlyoffice-module-context.xml
@@ -0,0 +1,6 @@
.gradle/
.idea/
*.iml
build/
gradle/
gradlew*

Large diffs are not rendered by default.

Oops, something went wrong.
114 README.md
@@ -0,0 +1,114 @@
# Alfresco Onlyoffice integration
This Share plugin enables users to edit HTML documents within Onlyoffice lite from Alfresco Share. This will create a new **Edit in Onlyoffice** action within the document library for HTML documents. This allows multiple users to collaborate in real time and to save back those changes to Alfresco.
Tested with Enterprise 4.2.\*, 5.0.\* and Community 4.2.\*, 5.0.\*
![image](onlyoffice-alfresco.gif)
## Compiling
You will need:
* Java 7 SDK or above
* Maven or Gradle
### Maven
* Run `mvn package` from the `share` directory
### Gradle
* You will need Parashift's alfresco amp plugin from here: https://bitbucket.org/parashift/alfresco-amp-plugin
* Run `gradle amp` from the `share` directory
## Installation
* Deploy the amp using Alfresco MMT or copy the onlyoffice jar to the WEB-INF/lib/ directory of share
* Update your `share-config-custom.xml` to include two new endpoints, `onlyoffice` and `onlyoffice-api`. `onlyoffice` is for end users and `onlyoffice-api` is only for Share to update content from Alfresco and setup pads.
* Update your `share-config-custom.xml` to disable CSRF actions for the onlyoffice endpoint, see **CSRF Instructions** below
* Restart Alfresco Share
### Example share-config-custom.xml
This example uses the following:
* 127.0.0.1 as the host
* 9001 as the port
* an API Key of `CHANGEME`.
To find the API key, check for the file `APIKEY.txt` on your onlyoffice instance.
#### Example Endpoints
```
<config evaluator="string-compare" condition="Remote">
<remote>
<endpoint>
<id>onlyoffice</id>
<name>Onlyoffice - unauthenticated access</name>
<description>Onlyoffice access</description>
<connector-id>http</connector-id>
<endpoint-url>http://127.0.0.1:9001</endpoint-url>
<identity>none</identity>
</endpoint>
<endpoint>
<id>onlyoffice-api</id>
<name>Onlyoffice - API access</name>
<description>Onlyoffice access</description>
<connector-id>onlyoffice</connector-id>
<endpoint-url>http://127.0.0.1:9001/api/1/</endpoint-url>
<identity>declared</identity>
<username>apikey</username>
<password>CHANGEME</password>
<unsecure>true</unsecure>
</endpoint>
</remote>
</config>
```
## CSRF Instructions
Because CSRF is enabled for all POST requests, we need to override the default CSRF policy to switch it off for POST requests to the onlyoffice proxy.
As discussed in this [blog](http://blogs.alfresco.com/wp/ewinlof/2013/03/11/introducing-the-new-csrf-filter-in-alfresco-share/), there are two options. Both involve overriding configuration in your `share-config-custom.xml` file.
You can switch off the CSRF Policy completely by using this statement (not recommended in production):
```
<config evaluator="string-compare" condition="CSRFPolicy" replace="true">
<filter/>
</config>
```
Or you can copy the CSRFPolicy configuration from [this file](https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V5.0.d/root/projects/slingshot/config/alfresco/share-security-config.xml) and then add the example in the onlyoffice-alfresco readme. So you would end up with a config section like this in your share-config-custom.xml:
```
<config evaluator="string-compare" condition="CSRFPolicy" replace="true">
<filter>
<rule>
<request>
<method>POST</method>
<path>/proxy/onlyoffice/.*</path>
</request>
</rule>
<-- OTHER RULE STATEMENTS FROM share-security-config.xml -->
</filter>
</config>
```
What this accomplishes is that you have the default CSRFPolicy, so you are secure, but you enable POST requests to pass through unfiltered to onlyoffice. You must include the onlyoffice filter rule first, as `share-security-config.xml` is loaded before `share-config-custom.xml`
## Todo
* Increase security of Onlyoffice. Right now you will still need the Node's UUID to discover the pad, but we can do better.
* Handle error cases alot better (wrong API Key, etc..)
* Provide some documentation on setting up onlyoffice correctly
* Support text documents
@@ -0,0 +1,113 @@
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.3.6'
classpath group: 'com.github.dynamicextensionsalfresco', name: 'gradle-plugin', version: '1.3.0'
classpath group: 'com.parashift.amp', name: 'amp-plugin', version: '1.0-SNAPSHOT'
}
}
apply plugin: 'alfresco-dynamic-extension'
apply plugin: 'alfresco-amp'
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
ext {
alfresco = [:]
alfresco.version = "5.0.1"
baseName = "onlyoffice-alfresco-repo"
}
project.description = "Onlyoffice Integration"
version = "git describe --tags".execute().text.trim()
repositories {
mavenCentral()
maven {
url "https://maven.alfresco.com/nexus/content/groups/public/"
}
maven {
url "http://repository.springsource.com/maven/bundles/external"
}
maven {
credentials {
username project['alfresco.repo.private.username']
password project['alfresco.repo.private.password']
}
url "https://maven.alfresco.com/nexus/content/groups/private/"
}
}
dependencies {
compile (group: "org.alfresco", name: "alfresco", version: "${alfresco.version}", classifier: "classes") {
exclude module: "alfresco-web-framework-commons"
exclude module: "commons-beanutils"
exclude group: "org.springframework"
exclude group: "org.mybatis"
}
compile "org.alfresco:alfresco-web-framework-commons:${alfresco.version}"
compile "org.json:json:20141113"
compile 'org.springframework:spring-context:3.0.0.RELEASE'
compile 'org.springframework:spring-beans:3.0.0.RELEASE'
compile 'org.springframework:spring-context-support:3.0.5.RELEASE'
}
jar {
baseName = project.baseName
version = project.version
manifest {
instructionReplace 'Bundle-Name', 'Onlyoffice Alfresco'
instruction 'Bundle-Description', project.description
instruction 'Alfresco-Spring-Configuration', 'com.parashift'
instruction 'Bundle-DocURL', 'http://www.parashift.com.au'
}
}
amp {
id = "com.parashift." + project.baseName
baseName = project.baseName
alias = "onlyoffice"
version = project.version
title = "Onlyoffice"
description = project.description
dependsOn("com.github.dynamicextensionsalfresco:1.0:2.0")
}
alfrescoDynamicExtensions {
repository {
endpoint {
host = project.hasProperty('hostname') ? project.hostname : 'localhost'
port = '8080'
serviceUrl = '/alfresco/service'
}
authentication {
username = project.hasProperty('username') ? project.username : 'admin'
password = project.hasProperty('password') ? project.password : 'admin'
}
}
}
@@ -0,0 +1,19 @@
/*
* This settings file was auto generated by the Gradle buildInit task
* by 'cetra' at '16/03/15 10:27 AM' with Gradle 2.2.1
*
* The settings file is used to specify which projects to include in your build.
* In a single project build this file can be empty or even removed.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at http://gradle.org/docs/2.2.1/userguide/multi_project_builds.html
*/
/*
// To declare projects as part of a multi-project build use the 'include' method
include 'shared'
include 'api'
include 'services:webservice'
*/
rootProject.name = 'onlyoffice-repo'
@@ -0,0 +1,41 @@
package com.parashift.onlyoffice;
import com.github.dynamicextensionsalfresco.webscripts.annotations.HttpMethod;
import com.github.dynamicextensionsalfresco.webscripts.annotations.Uri;
import com.github.dynamicextensionsalfresco.webscripts.annotations.WebScript;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.util.UrlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.extensions.webscripts.WebScriptResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* Created by cetra on 16/08/15.
*/
@WebScript
public class prepare {
@Autowired
SysAdminParams sysAdminParams;
@Autowired
AuthenticationService authenticationService;
@Uri(method = HttpMethod.GET, value = "/parashift/onlyoffice/prepare", defaultFormat = "html")
public void handlePrepare(final HttpServletRequest request, final WebScriptResponse response) throws IOException {
if (request.getParameter("nodeRef") != null) {
NodeRef nodeRef = new NodeRef(request.getParameter("nodeRef"));
String contentUrl = UrlUtil.getAlfrescoUrl(sysAdminParams) + "api/node/content" + nodeRef.getStoreRef() + "/" + nodeRef.getId() + "?alf_ticket=" + authenticationService.getCurrentTicket();
response.getWriter().write(contentUrl);
}
}
}
@@ -0,0 +1,42 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath group: 'com.parashift.amp', name: 'amp-plugin', version: '1.0-SNAPSHOT'
}
}
apply plugin: 'java'
apply plugin: 'alfresco-amp'
allprojects {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
repositories {
mavenCentral()
maven {
url "http://maven.alfresco.com/nexus/content/groups/public"
}
}
dependencies {
compile 'org.springframework.extensions.surf:spring-webscripts:1.2.0'
}
amp {
// id is mandatory when you want to pack a AMP
id = "com.parashift.onlyoffice-alfresco"
// the following is options but highly recommended you fill yourself
// as the plugin just infer the values from project.version
// and project.name
alias = "onlyoffice-alfresco"
version = "1.0.0"
title = "Onlyoffice Alfresco Integration"
description = "This Module integrates Alfresco Share with Onlyoffice"
}
@@ -0,0 +1,11 @@
#!/bin/bash
DEV_SERVER=192.168.0.106
INSTALL_DIR=/var/lib/tomcat7/webapps/share/WEB-INF/lib
USERNAME=admin
PASSWORD=setup
gradle clean build
find . -iname '*jar' -type f -exec scp '{}' root@$DEV_SERVER:$INSTALL_DIR \;
curl -u $USERNAME:$PASSWORD http://$DEV_SERVER:8080/manager/text/reload?path=/share
Oops, something went wrong.

0 comments on commit 3d24208

Please sign in to comment.