Skip to content

Commit

Permalink
Include updates for 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cetra3 committed Jul 20, 2016
1 parent 9544dc4 commit 90d7c6a
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.gradle/
build/
.idea/
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ This Share plugin enables users to edit Office documents within ONLYOFFICE from

Tested with Enterprise 5.0.\*, 5.1.\* and Community 5.1.\*

## Release Notes

### Version `1.1.0`


* Support for OnlyOffice version 4 (Tested with Alfresco Enterprise 5.1)
* Adds a few more Languages as per the ONLYOFFICE fork
* Limits the Edit in OnlyOffice button to certain mime types within Alfresco, rather than globally available as an action
* Adds a keep alive to make sure the share session does not expire when you have a window open
* Adds a new global property: `onlyoffice.lang`. This will set the language of the editor. E.g, for italian:
```
onlyoffice.lang=it
```
* Wrapped some response writers in the try blocks

## Compiling

Expand Down Expand Up @@ -32,7 +46,25 @@ The easiest way to start an instance of ONLYOFFICE is to use Docker: https://git
* 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/`
```
onlyoffice.url=http://documentserver/
```

* OnlyOffice will make the connection to Alfresco on behalf of the client, so OnlyOffice needs to be able to talk to Alfresco. In order for OnlyOffice to do this, Alfresco needs to generate what it thinks the external URL is. Make sure that the following properties are set correctly in `alfresco-global.properties`

```
alfresco.protocol=http
alfresco.host=alfresco.yourcompany.local
alfresco.port=8080
alfresco.context=alfresco
```

* (Optional) set the default language that the editor will use. By default the document editor should pick up the language of the browser, so it doesn't always need to be set.

```
onlyoffice.lang=en
```



## How it works
Expand Down
13 changes: 8 additions & 5 deletions repo/src/main/java/com/parashift/onlyoffice/CallBack.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.net.URL;
import java.text.SimpleDateFormat;

/**
* 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 @@ -88,7 +85,13 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
break;
}

response.getWriter().write("{\"error\":0}");
//Respond as per doco
try(Writer responseWriter = response.getWriter()) {
JSONObject responseJson = new JSONObject();
responseJson.put("error", 0);
responseJson.write(responseWriter);
}

}

private void updateNode(NodeRef nodeRef, String url) {
Expand Down
21 changes: 15 additions & 6 deletions repo/src/main/java/com/parashift/onlyoffice/Prepare.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.annotation.Resource;
import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Properties;
Expand All @@ -27,10 +28,6 @@
* 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 Expand Up @@ -68,14 +65,26 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
JSONObject responseJson = new JSONObject();
responseJson.put("docUrl", contentUrl);
responseJson.put("callbackUrl", callbackUrl);
responseJson.put("onlyofficeUrl", globalProp.getOrDefault("onlyoffice.url", "http://127.0.0.1/"));

if(globalProp.containsKey("onlyoffice.url")) {
responseJson.put("onlyofficeUrl", globalProp.get("onlyoffice.url"));
} else {
responseJson.put("onlyofficeUrl", "http://127.0.0.1/");
}

responseJson.put("key", key);
responseJson.put("docTitle", properties.get(ContentModel.PROP_NAME));

if(globalProp.containsKey("onlyoffice.lang")) {
responseJson.put("lang", globalProp.get("onlyoffice.lang"));
}

logger.debug("Sending JSON prepare object");
logger.debug(responseJson.toString(3));

response.getWriter().write(responseJson.toString(3));
try(Writer responseWriter = response.getWriter()) {
responseJson.write(responseWriter);
}

}
}
Expand Down
1 change: 1 addition & 0 deletions share/src/main/resources/alfresco/onlyoffice-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>evaluator.doclib.action.onlyofficeEditMimetype</evaluator>
</action>
</actions>
<actionGroups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<link href="${url.context}/res/components/onlyoffice/onlyoffice.css" type="text/css" rel="stylesheet">

<!--Change the address on installed ONLYOFFICE Online Editors-->
<!--Change the address on installed ONLYOFFICE Online Editors-->
<script id="scriptApi" type="text/javascript" src="${onlyofficeUrl}OfficeWeb/apps/api/documents/api.js"></script>

<script type="text/javascript" src="${url.context}/res/components/onlyoffice/onlyoffice.js"></script>
Expand All @@ -24,36 +24,49 @@
var docName = "${docTitle}";
var docType = docName.substring(docName.lastIndexOf(".") + 1).trim().toLowerCase();
var documentType = getDocumentType(docType);
new DocsAPI.DocEditor("placeholder",
{
type: "desktop",
width: "100%",
height: "100%",
documentType: documentType,
document: {
title: docName,
url: "${docUrl}",
fileType: docType,
key: "${key}",
permissions: {
edit: true
},
},
editorConfig: {
mode: "edit",
callbackUrl: "${callbackUrl}",
user: {
id: "${userId}",
firstname: "${firstName}",
lastname: "${lastName}",
}
},
events: {
},
});
var docConfig = {
type: "desktop",
width: "100%",
height: "100%",
documentType: getDocumentType(docType),
document: {
title: docName,
url: "${docUrl}",
fileType: docType,
key: "${key}",
permissions: {
edit: true
}
},
editorConfig: {
mode: "edit",
callbackUrl: "${callbackUrl}",
user: {
id: "${userId}",
firstname: "${firstName}",
lastname: "${lastName}",
}
}
};
<#if lang??>
docConfig.lang = "${lang}";
</#if>
new DocsAPI.DocEditor("placeholder", docConfig);
//Keep Alfresco active
setInterval(function() {
var keepAlive = new XMLHttpRequest();
keepAlive.open("GET", "${url.context}/proxy/alfresco/api/admin/restrictions", true);
keepAlive.send();
}, 60000);
</script>
</body>
</html>

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/*
Copyright (c) Ascensio System SIA 2016. All rights reserved.
http://www.onlyoffice.com
*/

pObj = eval('(' + remote.call("/parashift/onlyoffice/prepare?nodeRef=" + url.args.nodeRef) + ')');
pObj = eval('(' + remote.call("/parashift/onlyoffice/prepare?nodeRef=" + url.args.nodeRef) + ')');
model.callbackUrl = pObj.callbackUrl;
model.docTitle = pObj.docTitle;
model.docUrl = pObj.docUrl;
model.key = pObj.key;
model.onlyofficeUrl = pObj.onlyofficeUrl;

if(pObj.lang) {
model.lang = pObj.lang;
}

model.userId = user.id;
model.firstName = user.firstName;
model.lastName = user.lastName;

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
http://www.springframework.org/schema/context/spring-context-2.5.xsd">


<bean id="evaluator.doclib.action.onlyofficeEditMimetype" parent="evaluator.doclib.action.isMimetype">
<property name="mimetypes">
<list>
<value>text/html</value>
</list>
</property>
</bean>

<bean id="onlyoffice.custom.config" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
Expand All @@ -34,5 +26,33 @@
</property>
</bean>

<bean id="evaluator.doclib.action.onlyofficeEditMimetype" parent="evaluator.doclib.action.isMimetype">
<property name="mimetypes">
<list>
<value>application/vnd.ms-excel</value>
<value>application/vnd.ms-powerpoint</value>
<value>application/msword</value>
<value>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</value>
<value>application/vnd.openxmlformats-officedocument.presentationml.presentation</value>
<value>application/vnd.openxmlformats-officedocument.wordprocessingml.document</value>
<value>application/vnd.ms-word.document.macroenabled.12</value>
<value>application/vnd.ms-word.template.macroenabled.12</value>
<value>application/vnd.ms-excel.sheet.macroenabled.12</value>
<value>application/vnd.ms-excel.template.macroenabled.12</value>
<value>application/vnd.ms-powerpoint.presentation.macroenabled.12</value>
<value>application/vnd.ms-powerpoint.template.macroenabled.12</value>
<value>application/vnd.openxmlformats-officedocument.wordprocessingml.template</value>
<value>application/vnd.openxmlformats-officedocument.presentationml.slideshow</value>
<value>application/vnd.ms-powerpoint.slideshow.macroenabled.12</value>
<value>application/vnd.openxmlformats-officedocument.presentationml.template</value>
<value>application/vnd.ms-powerpoint.addin.macroenabled.12</value>
<value>application/vnd.openxmlformats-officedocument.presentationml.slide</value>
<value>application/vnd.ms-powerpoint.slide.macroenabled.12</value>
<value>application/vnd.openxmlformats-officedocument.spreadsheetml.template</value>
<value>application/vnd.ms-excel.addin.macroenabled.12</value>
<value>application/vnd.ms-excel.sheet.binary.macroenabled.12</value>
</list>
</property>
</bean>

</beans>

0 comments on commit 90d7c6a

Please sign in to comment.