mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-03-16 10:42:20 +08:00
Compare commits
97 Commits
v4.5.dev.1
...
v5.2.0.164
| Author | SHA1 | Date | |
|---|---|---|---|
| 0245c992a3 | |||
| 04cad3f10f | |||
| cb60398051 | |||
| f46b6a7c8c | |||
| 4872a74d13 | |||
| b00ed15051 | |||
| 0cbc290fbe | |||
| cb065bc4db | |||
| 4712057faa | |||
| 2e9842d559 | |||
| 0078c05a74 | |||
| aa8a143338 | |||
| a999b20588 | |||
| cab5f62201 | |||
| 95d33f3ee7 | |||
| 83c03c97db | |||
| 7b1c56ea2c | |||
| 178133a292 | |||
| f9232788b2 | |||
| c0f8caaf0b | |||
| fbb23a5872 | |||
| ec764e0f0e | |||
| d08d887392 | |||
| b039b16fd9 | |||
| 1df7cc54c1 | |||
| cf6d11bf4e | |||
| 8793235481 | |||
| 232fc0d156 | |||
| b1352bd897 | |||
| d8e1d4d6b7 | |||
| fc2db9b47f | |||
| c0b8e2e578 | |||
| fa4c3e3258 | |||
| 6d1bda75b9 | |||
| db9287263c | |||
| 6e1cef27cc | |||
| ceb4db9de6 | |||
| 68c2ae0444 | |||
| 30bdc7497a | |||
| 67a53ea5c8 | |||
| 043ab4251c | |||
| 20412f0c80 | |||
| 3792599e41 | |||
| 48a5f7ce72 | |||
| f3ee251088 | |||
| 2497acb9f5 | |||
| 6038381f72 | |||
| 7cd8333186 | |||
| 39301f65b6 | |||
| 5209ea55c0 | |||
| fb1715eebc | |||
| 59e78960ea | |||
| 102f34c49e | |||
| d0bbc736af | |||
| 5115995fb9 | |||
| 682ed58528 | |||
| 2114b23900 | |||
| 207f896e25 | |||
| 983c8829fa | |||
| 02afb13601 | |||
| 494bc6b6a4 | |||
| 72db6178ac | |||
| 5c1d925d42 | |||
| fd4dfea7d7 | |||
| ebd309dabc | |||
| f376c50fd9 | |||
| 6088e7d685 | |||
| d143e3c80d | |||
| 56d6388603 | |||
| 54993942bf | |||
| f2301ecbbf | |||
| f09f62103c | |||
| 75c1cc0c83 | |||
| e1e3357748 | |||
| 449020a9a4 | |||
| 22f2f0f922 | |||
| 1aa7e73d79 | |||
| 6eaa290557 | |||
| ed8df66513 | |||
| 16d942a487 | |||
| 5c6d9ec008 | |||
| 8e7f7c20e4 | |||
| b3f7e9861f | |||
| 797696ceea | |||
| af30096d71 | |||
| 8a7193a645 | |||
| 84f5be3556 | |||
| cff90de454 | |||
| 18b7bdb401 | |||
| 75155b4c54 | |||
| 4c3bc0e7ef | |||
| 908affc61c | |||
| c5b227d278 | |||
| 364d24dda2 | |||
| 74537582d7 | |||
| 8057ef7cbc | |||
| 8bab3ecbc6 |
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
10
Readme.md
10
Readme.md
@ -3,7 +3,15 @@
|
||||
|
||||
## Document Server integration example
|
||||
|
||||
These examples show the way to integrate [ONLYOFFICE Document Server][2] into your own website or application using one of the programming languages. The package contains examples written in .Net (C# MVC), .Net (C#), Java, Node.js, PHP and Ruby.
|
||||
These examples show the way to integrate [ONLYOFFICE Document Server][2] into your own website or application using one of the programming languages. The package contains examples written in .Net (C# MVC), .Net (C#), Java, Node.js, PHP and Ruby.
|
||||
|
||||
You should change `http://documentserver` to your server address in these files:
|
||||
* .Net (C# MVC) - `web/documentserver-example/csharp-mvc/web.appsettings.config`
|
||||
* .Net (C#) - `web/documentserver-example/csharp/settings.config`
|
||||
* Java - `web/documentserver-example/java/src/main/resources/settings.properties`
|
||||
* Node.js - `web/documentserver-example/nodejs/config/default.json`
|
||||
* PHP - `web/documentserver-example/php/config.php`
|
||||
* Ruby - `web/documentserver-example/ruby/config/application.rb`
|
||||
|
||||
More information on how to use these examples can be found here: [http://api.onlyoffice.com/editors/demopreview](http://api.onlyoffice.com/editors/demopreview "http://api.onlyoffice.com/editors/demopreview")
|
||||
|
||||
|
||||
@ -4,44 +4,58 @@
|
||||
<PropertyGroup>
|
||||
<To Condition=" '$(To)' == '' ">..\deploy\</To>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<NameCSharp>$(To).Net (C#) Example</NameCSharp>
|
||||
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
|
||||
<NameMvc>$(To).Net (C# MVC) Example</NameMvc>
|
||||
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
|
||||
<NameJava>$(To)Java Example</NameJava>
|
||||
<DirJava>$(RootDir)web\documentserver-example\java\</DirJava>
|
||||
<NameNodeJS>$(To)Node.js Example</NameNodeJS>
|
||||
<DirNodeJS>$(RootDir)web\documentserver-example\nodejs\</DirNodeJS>
|
||||
<NamePHP>$(To)PHP Example</NamePHP>
|
||||
<DirPHP>$(RootDir)web\documentserver-example\php\</DirPHP>
|
||||
<NameRuby>$(To)Ruby Example</NameRuby>
|
||||
<DirRuby>$(RootDir)web\documentserver-example\ruby\</DirRuby>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
<RemoveDir Directories="$(To)" ContinueOnError="true" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)obj\**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesCSharp)" WorkingDirectory="$(DirCSharp)" ZipFileName="$(To).Net (C#) Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesCSharp)" DestinationFiles="@(ZipFilesCSharp->'$(NameCSharp)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameCSharp)" WorkingDirectory="$(To)" ZipFileName="$(NameCSharp).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc)obj\**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesMVC)" WorkingDirectory="$(DirMvc)" ZipFileName="$(To).Net (C# MVC) Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesMVC)" DestinationFiles="@(ZipFilesMVC->'$(NameMvc)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameMvc)" WorkingDirectory="$(To)" ZipFileName="$(NameMvc).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesJava Include="$(DirJava)**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesJava)" WorkingDirectory="$(DirJava)" ZipFileName="$(To)Java Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesJava)" DestinationFiles="@(ZipFilesJava->'$(NameJava)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameJava)" WorkingDirectory="$(To)" ZipFileName="$(NameJava).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesNodeJS Include="$(DirNodeJS)**" Exclude="$(DirNodeJS)node_modules\**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesNodeJS)" WorkingDirectory="$(DirNodeJS)" ZipFileName="$(To)Node.js Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesNodeJS)" DestinationFiles="@(ZipFilesNodeJS->'$(NameNodeJS)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameNodeJS)" WorkingDirectory="$(To)" ZipFileName="$(NameNodeJS).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesPHP Include="$(DirPHP)**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesPHP)" WorkingDirectory="$(DirPHP)" ZipFileName="$(To)PHP Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesPHP)" DestinationFiles="@(ZipFilesPHP->'$(NamePHP)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NamePHP)" WorkingDirectory="$(To)" ZipFileName="$(NamePHP).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesRuby Include="$(DirRuby)**" />
|
||||
</ItemGroup>
|
||||
<Zip Files="@(ZipFilesRuby)" WorkingDirectory="$(DirRuby)" ZipFileName="$(To)Ruby Example.zip" />
|
||||
<Copy SourceFiles="@(ZipFilesRuby)" DestinationFiles="@(ZipFilesRuby->'$(NameRuby)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameRuby)" WorkingDirectory="$(To)" ZipFileName="$(NameRuby).zip" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -29,10 +29,8 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Web.Helpers;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
@ -47,7 +45,6 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
static ServiceConverter()
|
||||
{
|
||||
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
|
||||
DocumentStorageUrl = WebConfigurationManager.AppSettings["files.docservice.url.storage"] ?? "";
|
||||
|
||||
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
|
||||
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
|
||||
@ -65,21 +62,6 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
/// </summary>
|
||||
private static readonly string DocumentConverterUrl;
|
||||
|
||||
/// <summary>
|
||||
/// Url to the service of storage
|
||||
/// </summary>
|
||||
private static readonly string DocumentStorageUrl;
|
||||
|
||||
/// <summary>
|
||||
/// The parameters for the query conversion
|
||||
/// </summary>
|
||||
private const string ConvertParams = "?url={0}&outputtype={1}&filetype={2}&title={3}&key={4}";
|
||||
|
||||
/// <summary>
|
||||
/// Number of tries request conversion
|
||||
/// </summary>
|
||||
private const int MaxTry = 3;
|
||||
|
||||
#endregion
|
||||
|
||||
#region public method
|
||||
@ -108,74 +90,51 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
out string convertedDocumentUri)
|
||||
{
|
||||
convertedDocumentUri = string.Empty;
|
||||
var responceFromConvertService =
|
||||
SendRequestToConvertService(documentUri, fromExtension, toExtension, documentRevisionId, isAsync)
|
||||
.Root;
|
||||
|
||||
var errorElement = responceFromConvertService.Element("Error");
|
||||
if (errorElement != null)
|
||||
ProcessConvertServiceResponceError(Convert.ToInt32(errorElement.Value));
|
||||
fromExtension = string.IsNullOrEmpty(fromExtension) ? Path.GetExtension(documentUri) : fromExtension;
|
||||
|
||||
var isEndConvert = Convert.ToBoolean(responceFromConvertService.Element("EndConvert").Value);
|
||||
var percent = Convert.ToInt32(responceFromConvertService.Element("Percent").Value);
|
||||
var title = Path.GetFileName(documentUri);
|
||||
title = string.IsNullOrEmpty(title) ? Guid.NewGuid().ToString() : title;
|
||||
|
||||
if (isEndConvert)
|
||||
{
|
||||
convertedDocumentUri = responceFromConvertService.Element("FileUrl").Value;
|
||||
percent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = percent >= 100 ? 99 : percent;
|
||||
}
|
||||
documentRevisionId = string.IsNullOrEmpty(documentRevisionId)
|
||||
? documentUri
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
|
||||
return percent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Placing the document in the storage service
|
||||
/// </summary>
|
||||
/// <param name="fileStream">Stream of document</param>
|
||||
/// <param name="contentLength">Length of stream</param>
|
||||
/// <param name="contentType">Mime type</param>
|
||||
/// <param name="documentRevisionId">Key for caching on service, whose used in editor</param>
|
||||
/// <returns>Uri to document in the storage</returns>
|
||||
public static string GetExternalUri(
|
||||
Stream fileStream,
|
||||
long contentLength,
|
||||
string contentType,
|
||||
string documentRevisionId)
|
||||
{
|
||||
var urlDocumentService = DocumentStorageUrl + ConvertParams;
|
||||
var urlTostorage = String.Format(urlDocumentService,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
documentRevisionId);
|
||||
|
||||
var request = (HttpWebRequest)WebRequest.Create(urlTostorage);
|
||||
var request = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
request.Method = "POST";
|
||||
request.ContentType = contentType;
|
||||
request.ContentLength = contentLength;
|
||||
request.ContentType = "application/json";
|
||||
request.Accept = "application/json";
|
||||
request.Timeout = ConvertTimeout;
|
||||
|
||||
const int bufferSize = 2048;
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = fileStream.Read(buffer, 0, bufferSize)) > 0)
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
request.ContentLength = bytes.Length;
|
||||
using (var requestStream = request.GetRequestStream())
|
||||
{
|
||||
request.GetRequestStream().Write(buffer, 0, readed);
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
string dataResponse;
|
||||
using (var response = request.GetResponse())
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
if (stream == null) throw new WebException("Could not get an answer");
|
||||
var xDocumentResponse = XDocument.Load(new XmlTextReader(stream));
|
||||
string externalUri;
|
||||
GetResponseUri(xDocumentResponse, out externalUri);
|
||||
return externalUri;
|
||||
if (stream == null) throw new Exception("Response is null");
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
dataResponse = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
return GetResponseUri(dataResponse, out convertedDocumentUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -195,77 +154,44 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
#region private method
|
||||
|
||||
/// <summary>
|
||||
/// Request for conversion to a service
|
||||
/// Processing document received from the editing service
|
||||
/// </summary>
|
||||
/// <param name="documentUri">Uri for the document to convert</param>
|
||||
/// <param name="fromExtension">Document extension</param>
|
||||
/// <param name="toExtension">Extension to which to convert</param>
|
||||
/// <param name="documentRevisionId">Key for caching on service</param>
|
||||
/// <param name="isAsync">Perform conversions asynchronously</param>
|
||||
/// <returns>Xml document request result of conversion</returns>
|
||||
private static XDocument SendRequestToConvertService(string documentUri, string fromExtension, string toExtension, string documentRevisionId, bool isAsync)
|
||||
/// <param name="jsonDocumentResponse">The resulting json from editing service</param>
|
||||
/// <param name="responseUri">Uri to the converted document</param>
|
||||
/// <returns>The percentage of completion of conversion</returns>
|
||||
private static int GetResponseUri(string jsonDocumentResponse, out string responseUri)
|
||||
{
|
||||
fromExtension = string.IsNullOrEmpty(fromExtension) ? Path.GetExtension(documentUri) : fromExtension;
|
||||
if (string.IsNullOrEmpty(jsonDocumentResponse)) throw new ArgumentException("Invalid param", "jsonDocumentResponse");
|
||||
|
||||
var title = Path.GetFileName(documentUri);
|
||||
title = string.IsNullOrEmpty(title) ? Guid.NewGuid().ToString() : title;
|
||||
var responseFromService = Json.Decode(jsonDocumentResponse);
|
||||
if (jsonDocumentResponse == null) throw new WebException("Invalid answer format");
|
||||
|
||||
documentRevisionId = string.IsNullOrEmpty(documentRevisionId)
|
||||
? documentUri
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
var errorElement = responseFromService.error;
|
||||
if (errorElement != null) ProcessResponseError(Convert.ToInt32(errorElement));
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "text/json";
|
||||
req.Timeout = ConvertTimeout;
|
||||
var isEndConvert = responseFromService.endConvert;
|
||||
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
req.ContentLength = bytes.Length;
|
||||
using (var requestStream = req.GetRequestStream())
|
||||
int resultPercent;
|
||||
responseUri = string.Empty;
|
||||
if (isEndConvert)
|
||||
{
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
responseUri = responseFromService.fileUrl;
|
||||
resultPercent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPercent = responseFromService.percent;
|
||||
if (resultPercent >= 100) resultPercent = 99;
|
||||
}
|
||||
|
||||
Stream stream = null;
|
||||
var countTry = 0;
|
||||
while (countTry < MaxTry)
|
||||
{
|
||||
try
|
||||
{
|
||||
countTry++;
|
||||
stream = req.GetResponse().GetResponseStream();
|
||||
break;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status != WebExceptionStatus.Timeout)
|
||||
{
|
||||
throw new HttpException((int) HttpStatusCode.BadRequest, "Bad Request", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (countTry == MaxTry)
|
||||
{
|
||||
throw new WebException("Timeout", WebExceptionStatus.Timeout);
|
||||
}
|
||||
|
||||
return XDocument.Load(new XmlTextReader(stream));
|
||||
return resultPercent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate an error code table
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code</param>
|
||||
private static void ProcessConvertServiceResponceError(int errorCode)
|
||||
private static void ProcessResponseError(int errorCode)
|
||||
{
|
||||
var errorMessage = string.Empty;
|
||||
const string errorMessageTemplate = "Error occurred in the ConvertService.ashx: {0}";
|
||||
@ -315,45 +241,6 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processing document received from the editing service
|
||||
/// </summary>
|
||||
/// <param name="xDocumentResponse">The resulting xml from editing service</param>
|
||||
/// <param name="responseUri">Uri to the converted document</param>
|
||||
/// <returns>The percentage of completion of conversion</returns>
|
||||
private static int GetResponseUri(XDocument xDocumentResponse, out string responseUri)
|
||||
{
|
||||
var responceFromConvertService = xDocumentResponse.Root;
|
||||
if (responceFromConvertService == null) throw new WebException("Invalid answer format");
|
||||
|
||||
var errorElement = responceFromConvertService.Element("Error");
|
||||
if (errorElement != null) ProcessConvertServiceResponceError(Convert.ToInt32(errorElement.Value));
|
||||
|
||||
var endConvert = responceFromConvertService.Element("EndConvert");
|
||||
if (endConvert == null) throw new WebException("Invalid answer format");
|
||||
var isEndConvert = Convert.ToBoolean(endConvert.Value);
|
||||
|
||||
var resultPercent = 0;
|
||||
responseUri = string.Empty;
|
||||
if (isEndConvert)
|
||||
{
|
||||
var fileUrl = responceFromConvertService.Element("FileUrl");
|
||||
if (fileUrl == null) throw new WebException("Invalid answer format");
|
||||
|
||||
responseUri = fileUrl.Value;
|
||||
resultPercent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
var percent = responceFromConvertService.Element("Percent");
|
||||
if (percent != null)
|
||||
resultPercent = Convert.ToInt32(percent.Value);
|
||||
resultPercent = resultPercent >= 100 ? 99 : resultPercent;
|
||||
}
|
||||
|
||||
return resultPercent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -51,22 +51,26 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
|
||||
public static readonly List<string> ExtsDocument = new List<string>
|
||||
{
|
||||
".docx", ".doc", ".odt", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".pdf", ".djvu",
|
||||
".fb2", ".epub", ".xps"
|
||||
".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps"
|
||||
};
|
||||
|
||||
public static readonly List<string> ExtsSpreadsheet = new List<string>
|
||||
{
|
||||
".xls", ".xlsx",
|
||||
".ods", ".csv"
|
||||
".xls", ".xlsx", ".xlsm",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"
|
||||
};
|
||||
|
||||
public static readonly List<string> ExtsPresentation = new List<string>
|
||||
{
|
||||
".pps", ".ppsx",
|
||||
".ppt", ".pptx",
|
||||
".odp"
|
||||
".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -49,12 +49,10 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
|
||||
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExampleMVC")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2017")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
@ -2,15 +2,13 @@ For the ONLYOFFICE Applications example to work properly you need to do the foll
|
||||
|
||||
1. Download and extract the Example.zip into a directory selected for it, for instance, C:\OnlyofficeExample
|
||||
|
||||
2. Use the settings.config file to change the received authorization key for the document service. The file can be found in the unpacked root folder (C:\OnlyofficeExample\web.appsettings.config, in our example). The authorization key is specified in the files.docservice.key field.
|
||||
2. Run the IIS Manager (C:\Windows\system32\inetsrv\InetMgr.exe or Start -> All Programs -> Administrative Tools -> Internet Information Services (IIS) Manager for Windows Server 2003)
|
||||
|
||||
3. Run the IIS Manager (C:\Windows\system32\inetsrv\InetMgr.exe or Start -> All Programs -> Administrative Tools -> Internet Information Services (IIS) Manager for Windows Server 2003)
|
||||
3. Add the unpacked Example to the list of sites with the physical path to the C:\OnlyofficeExample (or the one you selected) folder.
|
||||
|
||||
4. Add the unpacked Example to the list of sites with the physical path to the C:\OnlyofficeExample (or the one you selected) folder.
|
||||
4. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
5. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
6. Make the created ONLYOFFIC<49> Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
5. Make the created ONLYOFFIC<49> Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -145,28 +145,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", сonnectEditor);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent("load", сonnectEditor);
|
||||
}
|
||||
|
||||
function getXmlHttp() {
|
||||
var xmlhttp;
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (ex) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
return xmlhttp;
|
||||
}
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", сonnectEditor);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent("load", сonnectEditor);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -47,10 +47,10 @@
|
||||
<body>
|
||||
<div class="top-panel"></div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -9,13 +9,12 @@
|
||||
|
||||
<add key="filesize-max" value="5242880"/>
|
||||
|
||||
<add key="files.docservice.viewed-docs" value=".ppt|.pps|.odp|.pdf|.djvu|.epub|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.doc|.odt|.xlsx|.xls|.ods|.csv|.pptx|.ppsx|.rtf|.txt|.mht|.html|.htm"/>
|
||||
<add key="files.docservice.convert-docs" value=".doc|.odt|.xls|.ods|.ppt|.pps|.odp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.ppsx|.txt"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.timeout" value="120000" />
|
||||
|
||||
<add key="files.docservice.url.storage" value="https://doc.onlyoffice.com/FileUploader.ashx"/>
|
||||
<add key="files.docservice.url.converter" value="https://doc.onlyoffice.com/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
</appSettings>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -43,10 +43,10 @@
|
||||
|
||||
<div class="top-panel"></div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
@ -99,7 +99,7 @@
|
||||
if (examples.Any())
|
||||
{ %>
|
||||
<br />
|
||||
Download the code for the sample of ONLYOFFICE Online Editors to find out the details.
|
||||
Download the code for the sample of ONLYOFFICE Document Editors to find out the details.
|
||||
<br />
|
||||
<br />
|
||||
<% foreach (var example in examples)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -42,22 +42,26 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
public static readonly List<string> ExtsSpreadsheet = new List<string>
|
||||
{
|
||||
".xls", ".xlsx",
|
||||
".ods", ".csv"
|
||||
".xls", ".xlsx", ".xlsm",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"
|
||||
};
|
||||
|
||||
public static readonly List<string> ExtsPresentation = new List<string>
|
||||
{
|
||||
".pps", ".ppsx",
|
||||
".ppt", ".pptx",
|
||||
".odp"
|
||||
".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"
|
||||
};
|
||||
|
||||
public static readonly List<string> ExtsDocument = new List<string>
|
||||
{
|
||||
".docx", ".doc", ".odt", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".pdf", ".djvu",
|
||||
".fb2", ".epub", ".xps"
|
||||
".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps"
|
||||
};
|
||||
|
||||
public static string GetInternalExtension(string extension)
|
||||
|
||||
@ -143,35 +143,6 @@
|
||||
window.attachEvent("load", сonnectEditor);
|
||||
}
|
||||
|
||||
function getXmlHttp() {
|
||||
var xmlhttp;
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (ex) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
return xmlhttp;
|
||||
}
|
||||
|
||||
function SaveFileRequest(fileName, fileType, fileUri) {
|
||||
var req = getXmlHttp();
|
||||
var requestAddress = "webeditor.ashx"
|
||||
+ "?type=save"
|
||||
+ "&filename=" + encodeURIComponent(fileName)
|
||||
+ "&filetype=" + encodeURIComponent(fileType)
|
||||
+ "&fileuri=" + encodeURIComponent(fileUri);
|
||||
req.open('get', requestAddress, true);
|
||||
|
||||
req.send(fileUri);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -24,16 +24,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System.Text;
|
||||
using OnlineEditorsExample;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Web.Helpers;
|
||||
using OnlineEditorsExample;
|
||||
|
||||
namespace ASC.Api.DocumentConverter
|
||||
{
|
||||
@ -48,7 +46,6 @@ namespace ASC.Api.DocumentConverter
|
||||
static ServiceConverter()
|
||||
{
|
||||
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
|
||||
DocumentStorageUrl = WebConfigurationManager.AppSettings["files.docservice.url.storage"] ?? "";
|
||||
|
||||
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
|
||||
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
|
||||
@ -66,21 +63,6 @@ namespace ASC.Api.DocumentConverter
|
||||
/// </summary>
|
||||
private static readonly string DocumentConverterUrl;
|
||||
|
||||
/// <summary>
|
||||
/// Url to the service of storage
|
||||
/// </summary>
|
||||
private static readonly string DocumentStorageUrl;
|
||||
|
||||
/// <summary>
|
||||
/// The parameters for the query conversion
|
||||
/// </summary>
|
||||
private const string ConvertParams = "?url={0}&outputtype={1}&filetype={2}&title={3}&key={4}";
|
||||
|
||||
/// <summary>
|
||||
/// Number of tries request conversion
|
||||
/// </summary>
|
||||
private const int MaxTry = 3;
|
||||
|
||||
#endregion
|
||||
|
||||
#region public method
|
||||
@ -109,63 +91,36 @@ namespace ASC.Api.DocumentConverter
|
||||
out string convertedDocumentUri)
|
||||
{
|
||||
convertedDocumentUri = string.Empty;
|
||||
var responceFromConvertService =
|
||||
SendRequestToConvertService(documentUri, fromExtension, toExtension, documentRevisionId, isAsync)
|
||||
.Root;
|
||||
|
||||
var errorElement = responceFromConvertService.Element("Error");
|
||||
if (errorElement != null)
|
||||
ProcessConvertServiceResponceError(Convert.ToInt32(errorElement.Value));
|
||||
fromExtension = string.IsNullOrEmpty(fromExtension) ? Path.GetExtension(documentUri) : fromExtension;
|
||||
|
||||
var isEndConvert = Convert.ToBoolean(responceFromConvertService.Element("EndConvert").Value);
|
||||
var percent = Convert.ToInt32(responceFromConvertService.Element("Percent").Value);
|
||||
var title = Path.GetFileName(documentUri);
|
||||
title = string.IsNullOrEmpty(title) ? Guid.NewGuid().ToString() : title;
|
||||
|
||||
if (isEndConvert)
|
||||
{
|
||||
convertedDocumentUri = responceFromConvertService.Element("FileUrl").Value;
|
||||
percent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = percent >= 100 ? 99 : percent;
|
||||
}
|
||||
documentRevisionId = string.IsNullOrEmpty(documentRevisionId)
|
||||
? documentUri
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
|
||||
return percent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Placing the document in the storage service
|
||||
/// </summary>
|
||||
/// <param name="fileStream">Stream of document</param>
|
||||
/// <param name="contentLength">Length of stream</param>
|
||||
/// <param name="contentType">Mime type</param>
|
||||
/// <param name="documentRevisionId">Key for caching on service, whose used in editor</param>
|
||||
/// <returns>Uri to document in the storage</returns>
|
||||
public static string GetExternalUri(
|
||||
Stream fileStream,
|
||||
long contentLength,
|
||||
string contentType,
|
||||
string documentRevisionId)
|
||||
{
|
||||
var urlDocumentService = DocumentStorageUrl + ConvertParams;
|
||||
var urlTostorage = String.Format(urlDocumentService,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
documentRevisionId);
|
||||
|
||||
var request = (HttpWebRequest)WebRequest.Create(urlTostorage);
|
||||
var request = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
request.Method = "POST";
|
||||
request.ContentType = contentType;
|
||||
request.ContentLength = contentLength;
|
||||
request.ContentType = "application/json";
|
||||
request.Accept = "application/json";
|
||||
request.Timeout = ConvertTimeout;
|
||||
|
||||
const int bufferSize = 2048;
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = fileStream.Read(buffer, 0, bufferSize)) > 0)
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
request.ContentLength = bytes.Length;
|
||||
using (var requestStream = request.GetRequestStream())
|
||||
{
|
||||
request.GetRequestStream().Write(buffer, 0, readed);
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
// hack. http://ubuntuforums.org/showthread.php?t=1841740
|
||||
@ -174,15 +129,19 @@ namespace ASC.Api.DocumentConverter
|
||||
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
|
||||
}
|
||||
|
||||
string dataResponse;
|
||||
using (var response = request.GetResponse())
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
if (stream == null) throw new WebException("Could not get an answer");
|
||||
var xDocumentResponse = XDocument.Load(new XmlTextReader(stream));
|
||||
string externalUri;
|
||||
GetResponseUri(xDocumentResponse, out externalUri);
|
||||
return externalUri;
|
||||
if (stream == null) throw new Exception("Response is null");
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
dataResponse = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
return GetResponseUri(dataResponse, out convertedDocumentUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -200,85 +159,46 @@ namespace ASC.Api.DocumentConverter
|
||||
#endregion
|
||||
|
||||
#region private method
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Request for conversion to a service
|
||||
/// Processing document received from the editing service
|
||||
/// </summary>
|
||||
/// <param name="documentUri">Uri for the document to convert</param>
|
||||
/// <param name="fromExtension">Document extension</param>
|
||||
/// <param name="toExtension">Extension to which to convert</param>
|
||||
/// <param name="documentRevisionId">Key for caching on service</param>
|
||||
/// <param name="isAsync">Perform conversions asynchronously</param>
|
||||
/// <returns>Xml document request result of conversion</returns>
|
||||
private static XDocument SendRequestToConvertService(string documentUri, string fromExtension, string toExtension, string documentRevisionId, bool isAsync)
|
||||
/// <param name="jsonDocumentResponse">The resulting json from editing service</param>
|
||||
/// <param name="responseUri">Uri to the converted document</param>
|
||||
/// <returns>The percentage of completion of conversion</returns>
|
||||
private static int GetResponseUri(string jsonDocumentResponse, out string responseUri)
|
||||
{
|
||||
fromExtension = string.IsNullOrEmpty(fromExtension) ? Path.GetExtension(documentUri) : fromExtension;
|
||||
if (string.IsNullOrEmpty(jsonDocumentResponse)) throw new ArgumentException("Invalid param", "jsonDocumentResponse");
|
||||
|
||||
var title = Path.GetFileName(documentUri);
|
||||
title = string.IsNullOrEmpty(title) ? Guid.NewGuid().ToString() : title;
|
||||
var responseFromService = Json.Decode(jsonDocumentResponse);
|
||||
if (jsonDocumentResponse == null) throw new WebException("Invalid answer format");
|
||||
|
||||
documentRevisionId = string.IsNullOrEmpty(documentRevisionId)
|
||||
? documentUri
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
var errorElement = responseFromService.error;
|
||||
if (errorElement != null) ProcessResponseError(Convert.ToInt32(errorElement));
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "text/json";
|
||||
req.Timeout = ConvertTimeout;
|
||||
var isEndConvert = responseFromService.endConvert;
|
||||
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
req.ContentLength = bytes.Length;
|
||||
using (var requestStream = req.GetRequestStream())
|
||||
int resultPercent;
|
||||
responseUri = string.Empty;
|
||||
if (isEndConvert)
|
||||
{
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
responseUri = responseFromService.fileUrl;
|
||||
resultPercent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPercent = responseFromService.percent;
|
||||
if (resultPercent >= 100) resultPercent = 99;
|
||||
}
|
||||
|
||||
var countTry = 0;
|
||||
Stream stream = null;
|
||||
|
||||
// hack. http://ubuntuforums.org/showthread.php?t=1841740
|
||||
if (_Default.IsMono)
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
|
||||
}
|
||||
while (countTry < MaxTry)
|
||||
{
|
||||
try
|
||||
{
|
||||
countTry++;
|
||||
stream = req.GetResponse().GetResponseStream();
|
||||
break;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status != WebExceptionStatus.Timeout)
|
||||
{
|
||||
throw new HttpException((int) HttpStatusCode.BadRequest, "Bad Request", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (countTry == MaxTry)
|
||||
{
|
||||
throw new WebException("Timeout", WebExceptionStatus.Timeout);
|
||||
}
|
||||
|
||||
return XDocument.Load(new XmlTextReader(stream));
|
||||
return resultPercent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate an error code table
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code</param>
|
||||
private static void ProcessConvertServiceResponceError(int errorCode)
|
||||
private static void ProcessResponseError(int errorCode)
|
||||
{
|
||||
var errorMessage = string.Empty;
|
||||
const string errorMessageTemplate = "Error occurred in the ConvertService.ashx: {0}";
|
||||
@ -328,45 +248,6 @@ namespace ASC.Api.DocumentConverter
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processing document received from the editing service
|
||||
/// </summary>
|
||||
/// <param name="xDocumentResponse">The resulting xml from editing service</param>
|
||||
/// <param name="responseUri">Uri to the converted document</param>
|
||||
/// <returns>The percentage of completion of conversion</returns>
|
||||
private static int GetResponseUri(XDocument xDocumentResponse, out string responseUri)
|
||||
{
|
||||
var responceFromConvertService = xDocumentResponse.Root;
|
||||
if (responceFromConvertService == null) throw new WebException("Invalid answer format");
|
||||
|
||||
var errorElement = responceFromConvertService.Element("Error");
|
||||
if (errorElement != null) ProcessConvertServiceResponceError(Convert.ToInt32(errorElement.Value));
|
||||
|
||||
var endConvert = responceFromConvertService.Element("EndConvert");
|
||||
if (endConvert == null) throw new WebException("Invalid answer format");
|
||||
var isEndConvert = Convert.ToBoolean(endConvert.Value);
|
||||
|
||||
var resultPercent = 0;
|
||||
responseUri = string.Empty;
|
||||
if (isEndConvert)
|
||||
{
|
||||
var fileUrl = responceFromConvertService.Element("FileUrl");
|
||||
if (fileUrl == null) throw new WebException("Invalid answer format");
|
||||
|
||||
responseUri = fileUrl.Value;
|
||||
resultPercent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
var percent = responceFromConvertService.Element("Percent");
|
||||
if (percent != null)
|
||||
resultPercent = Convert.ToInt32(percent.Value);
|
||||
resultPercent = resultPercent >= 100 ? 99 : resultPercent;
|
||||
}
|
||||
|
||||
return resultPercent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -44,12 +44,12 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Web.Helpers" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_Themes\images\file_docx.png" />
|
||||
|
||||
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExample")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2017")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
@ -2,15 +2,13 @@ For the ONLYOFFICE Applications example to work properly you need to do the foll
|
||||
|
||||
1. Download and extract the Example.zip into a directory selected for it, for instance, C:\OnlyofficeExample
|
||||
|
||||
2. Use the settings.config file to change the received authorization key for the document service. The file can be found in the unpacked root folder (C:\OnlyofficeExample\settings.config, in our example). The authorization key is specified in the files.docservice.key field.
|
||||
2. Run the IIS Manager (C:\Windows\system32\inetsrv\InetMgr.exe or Start -> All Programs -> Administrative Tools -> Internet Information Services (IIS) Manager for Windows Server 2003)
|
||||
|
||||
3. Run the IIS Manager (C:\Windows\system32\inetsrv\InetMgr.exe or Start -> All Programs -> Administrative Tools -> Internet Information Services (IIS) Manager for Windows Server 2003)
|
||||
3. Add the unpacked Example to the list of sites with the physical path to the C:\OnlyofficeExample (or the one you selected) folder.
|
||||
|
||||
4. Add the unpacked Example to the list of sites with the physical path to the C:\OnlyofficeExample (or the one you selected) folder.
|
||||
4. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
5. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
6. Make the created ONLYOFFICE Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
5. Make the created ONLYOFFICE Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -5,13 +5,12 @@
|
||||
<add key="filesize-max" value="5242880"/>
|
||||
<add key="storage-path" value=""/>
|
||||
|
||||
<add key="files.docservice.viewed-docs" value=".ppt|.pps|.odp|.pdf|.djvu|.epub|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.doc|.odt|.xlsx|.xls|.ods|.csv|.pptx|.ppsx|.rtf|.txt|.mht|.html|.htm"/>
|
||||
<add key="files.docservice.convert-docs" value=".doc|.odt|.xls|.ods|.ppt|.pps|.odp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.ppsx|.txt"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.timeout" value="120000" />
|
||||
|
||||
<add key="files.docservice.url.storage" value="https://doc.onlyoffice.com/FileUploader.ashx"/>
|
||||
<add key="files.docservice.url.converter" value="https://doc.onlyoffice.com/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
</appSettings>
|
||||
9
web/documentserver-example/java/Dockerfile
Normal file
9
web/documentserver-example/java/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM ubuntu:16.04
|
||||
RUN apt-get update && apt-get install -y software-properties-common \
|
||||
python-software-properties
|
||||
RUN add-apt-repository -y ppa:webupd8team/java
|
||||
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
|
||||
RUN apt-get update && apt-get install -y oracle-java8-installer \
|
||||
maven
|
||||
COPY . /java
|
||||
CMD mvn -f /java package
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
61
web/documentserver-example/java/README.md
Normal file
61
web/documentserver-example/java/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
## Build instruction
|
||||
|
||||
At first, You need to install `oracle-java8-installer`
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:webupd8team/java
|
||||
sudo apt-get update
|
||||
sudo apt-get install oracle-java8-installer
|
||||
```
|
||||
|
||||
Edit the **settings.properties** configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed
|
||||
|
||||
```
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
```
|
||||
|
||||
Install Maven:
|
||||
|
||||
```
|
||||
apt-get install maven
|
||||
```
|
||||
|
||||
And build:
|
||||
|
||||
```
|
||||
mvn package
|
||||
```
|
||||
|
||||
After it, all bin files will be passed to `./target` folder
|
||||
|
||||
## Build from docker
|
||||
Edit the **settings.properties** configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed
|
||||
|
||||
```
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
Edit the following lines. You need to change `documentserver` to your documentserver:
|
||||
|
||||
```
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
|
||||
```
|
||||
Run next command in java example directory:
|
||||
```
|
||||
docker build . -t java-example
|
||||
docker run -it -v $PWD/target:/java/target java-example
|
||||
```
|
||||
After it, all bin files will be passed to `./target` folder
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>onlyoffice.com</groupId>
|
||||
<artifactId>OnlineEditorsExampleJava</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>OnlineEditorsExampleJava</name>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -39,8 +39,8 @@ import entities.FileModel;
|
||||
|
||||
|
||||
@WebServlet(name = "EditorServlet", urlPatterns = {"/EditorServlet"})
|
||||
public class EditorServlet extends HttpServlet {
|
||||
|
||||
public class EditorServlet extends HttpServlet
|
||||
{
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
String fileName = "";
|
||||
@ -87,17 +87,20 @@ public class EditorServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
public String getServletInfo()
|
||||
{
|
||||
return "Editor page";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -38,61 +38,62 @@ import javax.net.ssl.X509TrustManager;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class GlobalServletContextListener implements ServletContextListener{
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
System.out.println("ServletContextListener destroyed");
|
||||
}
|
||||
public class GlobalServletContextListener implements ServletContextListener
|
||||
{
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0)
|
||||
{
|
||||
System.out.println("ServletContextListener destroyed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent arg0) {
|
||||
|
||||
TrustManager[] trustAllCerts = new TrustManager[] {
|
||||
new X509TrustManager() {
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
SSLContext sc;
|
||||
|
||||
try
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent arg0)
|
||||
{
|
||||
TrustManager[] trustAllCerts = new TrustManager[]
|
||||
{
|
||||
new X509TrustManager()
|
||||
{
|
||||
sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
}
|
||||
catch (NoSuchAlgorithmException | KeyManagementException ex)
|
||||
{
|
||||
}
|
||||
|
||||
HostnameVerifier allHostsValid = new HostnameVerifier() {
|
||||
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
System.out.println("ServletContextListener started");
|
||||
}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SSLContext sc;
|
||||
|
||||
try
|
||||
{
|
||||
sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
}
|
||||
catch (NoSuchAlgorithmException | KeyManagementException ex)
|
||||
{
|
||||
}
|
||||
|
||||
HostnameVerifier allHostsValid = new HostnameVerifier()
|
||||
{
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
|
||||
System.out.println("ServletContextListener started");
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -50,13 +50,13 @@ import org.json.simple.parser.JSONParser;
|
||||
|
||||
@WebServlet(name = "IndexServlet", urlPatterns = {"/IndexServlet"})
|
||||
@MultipartConfig
|
||||
public class IndexServlet extends HttpServlet {
|
||||
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
public class IndexServlet extends HttpServlet
|
||||
{
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
String action = request.getParameter("type");
|
||||
|
||||
if(action == null)
|
||||
if (action == null)
|
||||
{
|
||||
request.getRequestDispatcher("index.jsp").forward(request, response);
|
||||
return;
|
||||
@ -65,7 +65,8 @@ public class IndexServlet extends HttpServlet {
|
||||
DocumentManager.Init(request, response);
|
||||
PrintWriter writer = response.getWriter();
|
||||
|
||||
switch (action.toLowerCase()) {
|
||||
switch (action.toLowerCase())
|
||||
{
|
||||
case "upload":
|
||||
Upload(request, response, writer);
|
||||
break;
|
||||
@ -76,11 +77,11 @@ public class IndexServlet extends HttpServlet {
|
||||
Track(request, response, writer);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void Upload(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) {
|
||||
private static void Upload(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
response.setContentType("text/plain");
|
||||
|
||||
try
|
||||
@ -88,20 +89,24 @@ public class IndexServlet extends HttpServlet {
|
||||
Part httpPostedFile = request.getPart("file");
|
||||
|
||||
String fileName = "";
|
||||
for (String content : httpPostedFile.getHeader("content-disposition").split(";")) {
|
||||
if (content.trim().startsWith("filename")) {
|
||||
for (String content : httpPostedFile.getHeader("content-disposition").split(";"))
|
||||
{
|
||||
if (content.trim().startsWith("filename"))
|
||||
{
|
||||
fileName = content.substring(content.indexOf('=') + 1).trim().replace("\"", "");
|
||||
}
|
||||
}
|
||||
|
||||
long curSize = httpPostedFile.getSize();
|
||||
if (DocumentManager.GetMaxFileSize() < curSize || curSize <= 0) {
|
||||
if (DocumentManager.GetMaxFileSize() < curSize || curSize <= 0)
|
||||
{
|
||||
writer.write("{ \"error\": \"File size is incorrect\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
String curExt = FileUtility.GetFileExtension(fileName);
|
||||
if (!DocumentManager.GetFileExts().contains(curExt)) {
|
||||
if (!DocumentManager.GetFileExts().contains(curExt))
|
||||
{
|
||||
writer.write("{ \"error\": \"File type is not supported\"}");
|
||||
return;
|
||||
}
|
||||
@ -113,10 +118,12 @@ public class IndexServlet extends HttpServlet {
|
||||
|
||||
File file = new File(fileStoragePath);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
try (FileOutputStream out = new FileOutputStream(file))
|
||||
{
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = fileStream.read(bytes)) != -1) {
|
||||
while ((read = fileStream.read(bytes)) != -1)
|
||||
{
|
||||
out.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
@ -162,15 +169,18 @@ public class IndexServlet extends HttpServlet {
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
if (stream == null) {
|
||||
if (stream == null)
|
||||
{
|
||||
throw new Exception("Stream is null");
|
||||
}
|
||||
|
||||
File convertedFile = new File(DocumentManager.StoragePath(correctName, null));
|
||||
try (FileOutputStream out = new FileOutputStream(convertedFile)) {
|
||||
try (FileOutputStream out = new FileOutputStream(convertedFile))
|
||||
{
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = stream.read(bytes)) != -1) {
|
||||
while ((read = stream.read(bytes)) != -1)
|
||||
{
|
||||
out.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
@ -195,7 +205,8 @@ public class IndexServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
private static void Track(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) {
|
||||
private static void Track(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
String userAddress = request.getParameter("userAddress");
|
||||
String fileName = request.getParameter("fileName");
|
||||
|
||||
@ -238,7 +249,7 @@ public class IndexServlet extends HttpServlet {
|
||||
long status = (long) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if(status == 2 || status == 3)//MustSave, Corrupted
|
||||
if (status == 2 || status == 3)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
@ -248,15 +259,18 @@ public class IndexServlet extends HttpServlet {
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
if (stream == null) {
|
||||
if (stream == null)
|
||||
{
|
||||
throw new Exception("Stream is null");
|
||||
}
|
||||
|
||||
File savedFile = new File(storagePath);
|
||||
try (FileOutputStream out = new FileOutputStream(savedFile)) {
|
||||
try (FileOutputStream out = new FileOutputStream(savedFile))
|
||||
{
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = stream.read(bytes)) != -1) {
|
||||
while ((read = stream.read(bytes)) != -1)
|
||||
{
|
||||
out.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
@ -276,20 +290,21 @@ public class IndexServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
public String getServletInfo()
|
||||
{
|
||||
return "Handler";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -27,7 +27,8 @@
|
||||
|
||||
package entities;
|
||||
|
||||
public enum FileType {
|
||||
public enum FileType
|
||||
{
|
||||
Text,
|
||||
Spreadsheet,
|
||||
Presentation
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -30,8 +30,8 @@ package helpers;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
public class ConfigManager
|
||||
{
|
||||
private static Properties properties;
|
||||
|
||||
static
|
||||
@ -53,7 +53,8 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static String GetProperty(String name){
|
||||
public static String GetProperty(String name)
|
||||
{
|
||||
if(properties == null)
|
||||
return "";
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -44,7 +44,8 @@ public class DocumentManager
|
||||
{
|
||||
private static HttpServletRequest request;
|
||||
|
||||
public static void Init(HttpServletRequest req, HttpServletResponse resp){
|
||||
public static void Init(HttpServletRequest req, HttpServletResponse resp)
|
||||
{
|
||||
request = req;
|
||||
}
|
||||
|
||||
@ -116,7 +117,7 @@ public class DocumentManager
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
String hostAddress = CurUserHostAddress(userAddress);
|
||||
|
||||
String directory = serverPath + "\\" + storagePath + "\\";
|
||||
String directory = serverPath + File.separator + storagePath + File.separator;
|
||||
|
||||
File file = new File(directory);
|
||||
|
||||
@ -125,7 +126,7 @@ public class DocumentManager
|
||||
file.mkdir();
|
||||
}
|
||||
|
||||
directory = directory + hostAddress + "\\";
|
||||
directory = directory + hostAddress + File.separator;
|
||||
file = new File(directory);
|
||||
|
||||
if (!file.exists())
|
||||
@ -157,25 +158,20 @@ public class DocumentManager
|
||||
{
|
||||
String demoName = "sample." + fileExt;
|
||||
String fileName = GetCorrectName(demoName);
|
||||
|
||||
try
|
||||
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoName);
|
||||
|
||||
File file = new File(StoragePath(fileName, null));
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(file))
|
||||
{
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoName);
|
||||
|
||||
File file = new File(StoragePath(fileName, null));
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = stream.read(bytes)) != -1) {
|
||||
out.write(bytes, 0, read);
|
||||
}
|
||||
out.flush();
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = stream.read(bytes)) != -1)
|
||||
{
|
||||
out.write(bytes, 0, read);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
out.flush();
|
||||
}
|
||||
|
||||
return fileName;
|
||||
@ -185,36 +181,37 @@ public class DocumentManager
|
||||
{
|
||||
try
|
||||
{
|
||||
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
String serverPath = GetServerUrl();
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
|
||||
String filePath = serverPath + "/" + storagePath + "/" + hostAddress + "/" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
String filePath = serverPath + "/" + storagePath + "/" + hostAddress + "/" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()).replace("+", "%20");
|
||||
|
||||
return filePath;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError("UTF-8 is unknown");
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw ex;
|
||||
throw new AssertionError("UTF-8 is unknown");
|
||||
}
|
||||
}
|
||||
|
||||
public static String GetServerUrl()
|
||||
{
|
||||
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
|
||||
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
}
|
||||
|
||||
public static String GetCallback(String fileName)
|
||||
{
|
||||
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
String serverPath = GetServerUrl();
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try {
|
||||
try
|
||||
{
|
||||
String query = "?type=track&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new AssertionError("UTF-8 is unknown");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -37,14 +37,14 @@ import java.util.Map;
|
||||
public class FileUtility
|
||||
{
|
||||
static {}
|
||||
|
||||
|
||||
public static FileType GetFileType(String fileName)
|
||||
{
|
||||
String ext = GetFileExtension(fileName).toLowerCase();
|
||||
|
||||
if (ExtsDocument.contains(ext))
|
||||
return FileType.Text;
|
||||
|
||||
|
||||
if (ExtsSpreadsheet.contains(ext))
|
||||
return FileType.Spreadsheet;
|
||||
|
||||
@ -56,26 +56,33 @@ public class FileUtility
|
||||
|
||||
public static List<String> ExtsDocument = Arrays.asList
|
||||
(
|
||||
".docx", ".doc", ".odt", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".pdf", ".djvu",
|
||||
".fb2", ".epub", ".xps"
|
||||
".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps"
|
||||
);
|
||||
|
||||
public static List<String> ExtsSpreadsheet = Arrays.asList
|
||||
(
|
||||
".xls", ".xlsx", ".ods", ".csv"
|
||||
".xls", ".xlsx", ".xlsm",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"
|
||||
);
|
||||
|
||||
public static List<String> ExtsPresentation = Arrays.asList
|
||||
(
|
||||
".pps", ".ppsx", ".ppt", ".pptx",".odp"
|
||||
".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"
|
||||
);
|
||||
|
||||
|
||||
|
||||
public static String GetFileName (String url)
|
||||
{
|
||||
if(url == null) return null;
|
||||
|
||||
|
||||
//for external file url
|
||||
String tempstorage = ConfigManager.GetProperty("files.docservice.url.tempstorage");
|
||||
if(!tempstorage.isEmpty() && url.startsWith(tempstorage))
|
||||
@ -87,7 +94,7 @@ public class FileUtility
|
||||
String fileName = url.substring(url.lastIndexOf('/')+1, url.length());
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
public static String GetFileNameWithoutExtension (String url)
|
||||
{
|
||||
String fileName = GetFileName(url);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -37,23 +37,16 @@ import java.net.URLEncoder;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
|
||||
public class ServiceConverter
|
||||
{
|
||||
private static int ConvertTimeout = 120000;
|
||||
private static final String DocumentConverterUrl = ConfigManager.GetProperty("files.docservice.url.converter");
|
||||
private static final String DocumentStorageUrl = ConfigManager.GetProperty("files.docservice.url.storage");
|
||||
private static final MessageFormat ConvertParams = new MessageFormat("?url={0}&outputtype={1}&filetype={2}&title={3}&key={4}");
|
||||
private static final int MaxTry = 3;
|
||||
|
||||
static
|
||||
{
|
||||
@ -71,113 +64,14 @@ public class ServiceConverter
|
||||
}
|
||||
|
||||
public static String GetConvertedUri(String documentUri, String fromExtension, String toExtension, String documentRevisionId, Boolean isAsync) throws Exception
|
||||
{
|
||||
String convertedDocumentUri = null;
|
||||
|
||||
String xml = SendRequestToConvertService(documentUri, fromExtension, toExtension, documentRevisionId, isAsync);
|
||||
|
||||
Document document = ConvertStringToXmlDocument(xml);
|
||||
|
||||
Element responceFromConvertService = document.getDocumentElement();
|
||||
if (responceFromConvertService == null)
|
||||
throw new Exception("Invalid answer format");
|
||||
|
||||
NodeList errorElement = responceFromConvertService.getElementsByTagName("Error");
|
||||
if (errorElement != null && errorElement.getLength() > 0)
|
||||
ProcessConvertServiceResponceError(Integer.parseInt(errorElement.item(0).getTextContent()));
|
||||
|
||||
NodeList endConvertNode = responceFromConvertService.getElementsByTagName("EndConvert");
|
||||
if (endConvertNode == null || endConvertNode.getLength() == 0)
|
||||
throw new Exception("EndConvert node is null");
|
||||
|
||||
Boolean isEndConvert = Boolean.parseBoolean(endConvertNode.item(0).getTextContent());
|
||||
|
||||
NodeList percentNode = responceFromConvertService.getElementsByTagName("Percent");
|
||||
if (percentNode == null || percentNode.getLength() == 0)
|
||||
throw new Exception("Percent node is null");
|
||||
|
||||
Integer percent = Integer.parseInt(percentNode.item(0).getTextContent());
|
||||
|
||||
if (isEndConvert)
|
||||
{
|
||||
NodeList fileUrlNode = responceFromConvertService.getElementsByTagName("FileUrl");
|
||||
if (fileUrlNode == null || fileUrlNode.getLength() == 0)
|
||||
throw new Exception("FileUrl node is null");
|
||||
|
||||
convertedDocumentUri = fileUrlNode.item(0).getTextContent();
|
||||
percent = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = percent >= 100 ? 99 : percent;
|
||||
}
|
||||
|
||||
return percent >= 100 ? convertedDocumentUri : "";
|
||||
}
|
||||
|
||||
public static String GetExternalUri(InputStream fileStream, long contentLength, String contentType, String documentRevisionId) throws IOException, Exception
|
||||
{
|
||||
Object[] args = {"", "", "", "", documentRevisionId};
|
||||
|
||||
String urlTostorage = DocumentStorageUrl + ConvertParams.format(args);
|
||||
|
||||
URL url = new URL(urlTostorage);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setInstanceFollowRedirects(false);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", contentType == null ? "application/octet-stream" : contentType);
|
||||
connection.setRequestProperty("charset", "utf-8");
|
||||
connection.setRequestProperty("Content-Length", Long.toString(contentLength));
|
||||
connection.setUseCaches (false);
|
||||
|
||||
try (DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
int read;
|
||||
final byte[] bytes = new byte[1024];
|
||||
while ((read = fileStream.read(bytes)) != -1) {
|
||||
dataOutputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
dataOutputStream.flush();
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
if (stream == null)
|
||||
{
|
||||
throw new Exception("Could not get an answer");
|
||||
}
|
||||
|
||||
String xml = ConvertStreamToString(stream);
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
String res = GetResponseUri(xml);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String GenerateRevisionId(String expectedKey)
|
||||
{
|
||||
if (expectedKey.length() > 20)
|
||||
expectedKey = Integer.toString(expectedKey.hashCode());
|
||||
|
||||
String key = expectedKey.replace("[^0-9-.a-zA-Z_=]", "_");
|
||||
|
||||
return key.substring(0, Math.min(key.length(), 20));
|
||||
}
|
||||
|
||||
private static String SendRequestToConvertService(String documentUri, String fromExtension, String toExtension, String documentRevisionId, Boolean isAsync) throws Exception
|
||||
{
|
||||
fromExtension = fromExtension == null || fromExtension.isEmpty() ? FileUtility.GetFileExtension(documentUri) : fromExtension;
|
||||
|
||||
String title = FileUtility.GetFileName(documentUri);
|
||||
title = title == null || title.isEmpty() ? UUID.randomUUID().toString() : title;
|
||||
|
||||
|
||||
documentRevisionId = documentRevisionId == null || documentRevisionId.isEmpty() ? documentUri : documentRevisionId;
|
||||
|
||||
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
|
||||
Object[] args = {
|
||||
@ -187,7 +81,7 @@ public class ServiceConverter
|
||||
title,
|
||||
documentRevisionId
|
||||
};
|
||||
|
||||
|
||||
String urlToConverter = DocumentConverterUrl + ConvertParams.format(args);
|
||||
|
||||
if (isAsync)
|
||||
@ -195,38 +89,29 @@ public class ServiceConverter
|
||||
|
||||
URL url = new URL(urlToConverter);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setConnectTimeout(ConvertTimeout);
|
||||
|
||||
InputStream stream = null;
|
||||
int countTry = 0;
|
||||
|
||||
while (countTry < MaxTry)
|
||||
{
|
||||
try
|
||||
{
|
||||
countTry++;
|
||||
stream = connection.getInputStream();
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(!(ex instanceof TimeoutException))
|
||||
throw new Exception("Bad Request");
|
||||
}
|
||||
}
|
||||
if (countTry == MaxTry)
|
||||
{
|
||||
throw new Exception("Timeout");
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
if (stream == null)
|
||||
throw new Exception("Could not get an answer");
|
||||
|
||||
String xml = ConvertStreamToString(stream);
|
||||
|
||||
String jsonString = ConvertStreamToString(stream);
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
return xml;
|
||||
|
||||
return GetResponseUri(jsonString);
|
||||
}
|
||||
|
||||
public static String GenerateRevisionId(String expectedKey)
|
||||
{
|
||||
if (expectedKey.length() > 20)
|
||||
expectedKey = Integer.toString(expectedKey.hashCode());
|
||||
|
||||
String key = expectedKey.replace("[^0-9-.a-zA-Z_=]", "_");
|
||||
|
||||
return key.substring(0, Math.min(key.length(), 20));
|
||||
}
|
||||
|
||||
private static void ProcessConvertServiceResponceError(int errorCode) throws Exception
|
||||
@ -270,46 +155,31 @@ public class ServiceConverter
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
private static String GetResponseUri(String xml) throws Exception
|
||||
private static String GetResponseUri(String jsonString) throws Exception
|
||||
{
|
||||
Document document = ConvertStringToXmlDocument(xml);
|
||||
|
||||
Element responceFromConvertService = document.getDocumentElement();
|
||||
if (responceFromConvertService == null)
|
||||
throw new Exception("Invalid answer format");
|
||||
JSONObject jsonObj = ConvertStringToJSON(jsonString);
|
||||
|
||||
NodeList errorElement = responceFromConvertService.getElementsByTagName("Error");
|
||||
if (errorElement != null && errorElement.getLength() > 0)
|
||||
ProcessConvertServiceResponceError(Integer.parseInt(errorElement.item(0).getTextContent()));
|
||||
String error = (String) jsonObj.get("error");
|
||||
if (error != null && error != "")
|
||||
ProcessConvertServiceResponceError(Integer.parseInt(error));
|
||||
|
||||
NodeList endConvert = responceFromConvertService.getElementsByTagName("EndConvert");
|
||||
if (endConvert == null || endConvert.getLength() == 0)
|
||||
throw new Exception("Invalid answer format");
|
||||
|
||||
Boolean isEndConvert = Boolean.parseBoolean(endConvert.item(0).getTextContent());
|
||||
Boolean isEndConvert = (Boolean) jsonObj.get("endConvert");
|
||||
|
||||
int resultPercent = 0;
|
||||
Long resultPercent = 0l;
|
||||
String responseUri = null;
|
||||
|
||||
|
||||
if (isEndConvert)
|
||||
{
|
||||
NodeList fileUrl = responceFromConvertService.getElementsByTagName("FileUrl");
|
||||
if (fileUrl == null || endConvert.getLength() == 0)
|
||||
throw new Exception("Invalid answer format");
|
||||
|
||||
resultPercent = 100;
|
||||
responseUri = fileUrl.item(0).getTextContent();
|
||||
resultPercent = 100l;
|
||||
responseUri = (String) jsonObj.get("fileUrl");
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeList percent = responceFromConvertService.getElementsByTagName("Percent");
|
||||
if (percent != null && percent.getLength() > 0)
|
||||
resultPercent = Integer.parseInt(percent.item(0).getTextContent());
|
||||
|
||||
resultPercent = resultPercent >= 100 ? 99 : resultPercent;
|
||||
resultPercent = (Long) jsonObj.get("percent");
|
||||
resultPercent = resultPercent >= 100l ? 99l : resultPercent;
|
||||
}
|
||||
|
||||
return resultPercent >= 100 ? responseUri : "";
|
||||
return resultPercent >= 100l ? responseUri : "";
|
||||
}
|
||||
|
||||
private static String ConvertStreamToString(InputStream stream) throws IOException
|
||||
@ -319,24 +189,23 @@ public class ServiceConverter
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
String line = bufferedReader.readLine();
|
||||
|
||||
while(line != null) {
|
||||
while(line != null)
|
||||
{
|
||||
stringBuilder.append(line);
|
||||
line =bufferedReader.readLine();
|
||||
line = bufferedReader.readLine();
|
||||
}
|
||||
|
||||
String result = stringBuilder.toString();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Document ConvertStringToXmlDocument(String xml) throws IOException, ParserConfigurationException, SAXException
|
||||
private static JSONObject ConvertStringToJSON(String jsonString) throws ParseException
|
||||
{
|
||||
DocumentBuilderFactory documentBuildFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder doccumentBuilder = documentBuildFactory.newDocumentBuilder();
|
||||
InputStream inputStream = new ByteArrayInputStream(xml.getBytes("utf-8"));
|
||||
InputSource inputSource = new InputSource(inputStream);
|
||||
Document document = doccumentBuilder.parse(inputSource);
|
||||
|
||||
return document;
|
||||
JSONParser parser = new JSONParser();
|
||||
Object obj = parser.parse(jsonString);
|
||||
JSONObject jsonObj = (JSONObject) obj;
|
||||
|
||||
return jsonObj;
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,12 @@
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
|
||||
files.docservice.viewed-docs=.ppt|.pps|.odp|.pdf|.djvu|.epub|.xps
|
||||
files.docservice.edited-docs=.docx|.doc|.odt|.xlsx|.xls|.ods|.csv|.pptx|.ppsx|.rtf|.txt|.mht|.html|.htm
|
||||
files.docservice.convert-docs=.doc|.odt|.xls|.ods|.ppt|.pps|.odp|.rtf|.mht|.html|.htm|.epub
|
||||
files.docservice.viewed-docs=.pdf|.djvu|.xps
|
||||
files.docservice.edited-docs=.docx|.xlsx|.csv|.pptx|.ppsx|.txt
|
||||
files.docservice.convert-docs=.docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub
|
||||
files.docservice.timeout=120000
|
||||
|
||||
files.docservice.url.storage=https://doc.onlyoffice.com/FileUploader.ashx
|
||||
files.docservice.url.converter=https://doc.onlyoffice.com/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://doc.onlyoffice.com/ResourceService.ashx
|
||||
files.docservice.url.api=https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -40,6 +40,7 @@
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="css/editor.css" />
|
||||
|
||||
<% DocumentManager.Init(request, response); %>
|
||||
<% FileModel Model = (FileModel)request.getAttribute("file"); %>
|
||||
|
||||
<script type="text/javascript" src="${docserviceApiUrl}"></script>
|
||||
@ -145,23 +146,6 @@
|
||||
window.attachEvent("load", сonnectEditor);
|
||||
}
|
||||
|
||||
function getXmlHttp() {
|
||||
var xmlhttp;
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (ex) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
if (!xmlhttp && typeof XMLHttpRequest !== "undefined") {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
return xmlhttp;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -44,10 +44,10 @@
|
||||
<div class="top-panel"></div>
|
||||
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
0
web/documentserver-example/java/target/.keep
Normal file
0
web/documentserver-example/java/target/.keep
Normal file
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
<link href="stylesheet.css" type="text/css" rel="stylesheet">
|
||||
|
||||
<!--Change the address on installed ONLYOFFICE Online Editors-->
|
||||
<script id="scriptApi" type="text/javascript" src="https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js"></script>
|
||||
<!--Change the address on installed ONLYOFFICE Document Editors-->
|
||||
<script id="scriptApi" type="text/javascript" src="https://documentserver/web-apps/apps/api/documents/api.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="init.js"></script>
|
||||
@ -43,10 +43,10 @@
|
||||
<div id="page">
|
||||
<div class="top-panel"></div>
|
||||
<div id="mainPanel" class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may enter url your own document for testing.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may enter url your own document for testing.</span>
|
||||
<textarea id="documentUrl" class="document-url">http://onlyo.co/1x5REbq?demo.docx</textarea>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -73,8 +73,8 @@ function key(k) {
|
||||
};
|
||||
|
||||
var getDocumentType = function (ext) {
|
||||
if (".docx.doc.odt.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
|
||||
if (".xls.xlsx.ods.csv".indexOf(ext) != -1) return "spreadsheet";
|
||||
if (".pps.ppsx.ppt.pptx.odp".indexOf(ext) != -1) return "presentation";
|
||||
if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
|
||||
if (".xls.xlsx.xlsm.xlt.xltx.xltm.ods.fods.ots.csv".indexOf(ext) != -1) return "spreadsheet";
|
||||
if (".pps.ppsx.ppsm.ppt.pptx.pptm.pot.potx.potm.odp.fodp.otp".indexOf(ext) != -1) return "presentation";
|
||||
return null;
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/*
|
||||
"use strict";
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -150,6 +151,7 @@ app.post("/upload", function (req, res) {
|
||||
const form = new formidable.IncomingForm();
|
||||
form.uploadDir = uploadDirTmp;
|
||||
form.keepExtensions = true;
|
||||
form.maxFileSize = configServer.get("maxFileSize");
|
||||
|
||||
form.parse(req, function (err, fields, files) {
|
||||
if (err) {
|
||||
@ -229,6 +231,7 @@ app.get("/convert", function (req, res) {
|
||||
if (error != null)
|
||||
result["error"] = error;
|
||||
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.write(JSON.stringify(result));
|
||||
response.end();
|
||||
};
|
||||
@ -268,7 +271,7 @@ app.get("/convert", function (req, res) {
|
||||
|
||||
fileSystem.renameSync(path.join(correctHistoryPath, fileName + ".txt"), path.join(correctHistoryPath, correctName + ".txt"));
|
||||
|
||||
writeResult(correctName, null, null);
|
||||
writeResult(correctName, result, null);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
writeResult(null, null, "Server error");
|
||||
@ -277,7 +280,11 @@ app.get("/convert", function (req, res) {
|
||||
|
||||
try {
|
||||
if (configServer.get('convertedDocs').indexOf(fileExt) != -1) {
|
||||
const key = documentService.generateRevisionId(fileUri);
|
||||
let storagePath = docManager.storagePath(fileName);
|
||||
const stat = fileSystem.statSync(storagePath);
|
||||
let key = fileUri + stat.mtime.getTime();
|
||||
|
||||
key = documentService.generateRevisionId(key);
|
||||
documentService.getConvertedUri(fileUri, fileExt, internalFileExt, key, true, callback);
|
||||
} else {
|
||||
writeResult(fileName, null, null);
|
||||
@ -354,7 +361,7 @@ app.post("/track", function (req, res) {
|
||||
|
||||
var count_version = docManager.countVersion(historyPath);
|
||||
version = count_version + 1;
|
||||
versionPath = docManager.versionPath(fileName, userAddress, version);
|
||||
var versionPath = docManager.versionPath(fileName, userAddress, version);
|
||||
docManager.createDirectory(versionPath);
|
||||
|
||||
var downloadZip = body.changesurl;
|
||||
@ -467,24 +474,32 @@ app.post("/track", function (req, res) {
|
||||
|
||||
//checkjwt
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
var checkJwtHeaderRes = documentService.checkJwtHeader(req);
|
||||
if (checkJwtHeaderRes) {
|
||||
if (checkJwtHeaderRes.payload) {
|
||||
body = checkJwtHeaderRes.payload;
|
||||
}
|
||||
if (checkJwtHeaderRes.query) {
|
||||
if (checkJwtHeaderRes.query.useraddress) {
|
||||
userAddress = checkJwtHeaderRes.query.useraddress;
|
||||
}
|
||||
if (checkJwtHeaderRes.query.filename) {
|
||||
fileName = fileUtility.getFileName(checkJwtHeaderRes.query.filename);
|
||||
}
|
||||
}
|
||||
processTrack(res, body, fileName, userAddress);
|
||||
var body = null;
|
||||
if (req.body.hasOwnProperty("token")) {
|
||||
body = documentService.readToken(req.body.token);
|
||||
} else {
|
||||
var checkJwtHeaderRes = documentService.checkJwtHeader(req);
|
||||
if (checkJwtHeaderRes) {
|
||||
var body;
|
||||
if (checkJwtHeaderRes.payload) {
|
||||
body = checkJwtHeaderRes.payload;
|
||||
}
|
||||
if (checkJwtHeaderRes.query) {
|
||||
if (checkJwtHeaderRes.query.useraddress) {
|
||||
userAddress = checkJwtHeaderRes.query.useraddress;
|
||||
}
|
||||
if (checkJwtHeaderRes.query.filename) {
|
||||
fileName = fileUtility.getFileName(checkJwtHeaderRes.query.filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (body == null) {
|
||||
res.write("{\"error\":1}");
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
processTrack(res, body, fileName, userAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,7 +534,7 @@ app.get("/editor", function (req, res) {
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var key = docManager.getKey(fileName);
|
||||
var url = docManager.getFileUri(fileName);
|
||||
var mode = req.query.mode || "edit"; //mode: view/edit
|
||||
var mode = req.query.mode || "edit"; //mode: view/edit/review/comment/fillForms/embedded
|
||||
var type = req.query.type || ""; //type: embedded/mobile/desktop
|
||||
if (type == "") {
|
||||
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
|
||||
@ -550,14 +565,15 @@ app.get("/editor", function (req, res) {
|
||||
key: keyVersion,
|
||||
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileUtility.getFileExtension(fileName)),
|
||||
};
|
||||
if (i > 1) {
|
||||
|
||||
if (i > 1 && docManager.existsSync(docManager.diffPath(fileName, userAddress, i-1))) {
|
||||
historyD.previous = {
|
||||
key: historyData[i-2].key,
|
||||
url: historyData[i-2].url,
|
||||
|
||||
};
|
||||
historyD.changesUrl = docManager.getlocalFileUri(fileName, i-1) + "/diff.zip";
|
||||
}
|
||||
|
||||
historyData.push(historyD);
|
||||
|
||||
if (i < countVersion) {
|
||||
@ -595,9 +611,11 @@ app.get("/editor", function (req, res) {
|
||||
key: key,
|
||||
token: "",
|
||||
callbackUrl: docManager.getCallback(fileName),
|
||||
isEdit: canEdit && mode == "edit",
|
||||
isEdit: canEdit && (mode == "edit" || mode == "filter"),
|
||||
review: mode == "edit" || mode == "review",
|
||||
comment: mode == "edit" || mode == "comment",
|
||||
comment: mode != "view" && mode != "fillForms" && mode != "embedded",
|
||||
fillForms: mode != "view" && mode != "comment" && mode != "embedded",
|
||||
modifyFilter: mode != "filter",
|
||||
mode: canEdit && mode != "view" ? "edit" : "view",
|
||||
canBackToFolder: type != "embedded",
|
||||
backUrl: docManager.getServerUrl(),
|
||||
|
||||
@ -12,17 +12,16 @@
|
||||
},
|
||||
"server": {
|
||||
"port": 3000,
|
||||
"siteUrl": "https://doc.onlyoffice.com/",
|
||||
"siteUrl": "https://documentserver/",
|
||||
"commandUrl": "coauthoring/CommandService.ashx",
|
||||
"storageUrl": "FileUploader.ashx",
|
||||
"converterUrl": "ConvertService.ashx",
|
||||
"tempStorageUrl": "ResourceService.ashx",
|
||||
"apiUrl": "web-apps/apps/api/documents/api.js",
|
||||
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
|
||||
"exampleUrl": null,
|
||||
"viewedDocs": [".ppt", ".pps", ".odp", ".pdf", ".djvu", ".epub", ".xps"],
|
||||
"editedDocs": [".docx", ".doc", ".odt", ".xlsx", ".xls", ".ods", ".csv", ".pptx", ".ppsx", ".rtf", ".txt", ".mht", ".html", ".htm"],
|
||||
"convertedDocs": [".doc", ".odt", ".xls", ".ods", ".ppt", ".pps", ".odp", ".rtf", ".mht", ".html", ".htm", ".epub"],
|
||||
"viewedDocs": [".pdf", ".djvu", ".xps"],
|
||||
"editedDocs": [".docx", ".xlsx", ".csv", ".pptx", ".ppsx", ".txt"],
|
||||
"convertedDocs": [".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub"],
|
||||
"storageFolder": "files",
|
||||
"maxFileSize": 1073741824,
|
||||
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
{
|
||||
"server": {
|
||||
"port": 3000,
|
||||
"siteUrl": "http://127.0.0.1:8080/"
|
||||
"siteUrl": "http://127.0.0.1:8080/",
|
||||
"apiUrl": "web-apps-pro/apps/api/documents/api.js",
|
||||
"preloaderUrl": "web-apps-pro/apps/api/documents/cache-scripts.html"
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
{
|
||||
"server": {
|
||||
"port": 80,
|
||||
"siteUrl": "http://127.0.0.1:8001/"
|
||||
"siteUrl": "http://127.0.0.1:8001/",
|
||||
"apiUrl": "web-apps-pro/apps/api/documents/api.js",
|
||||
"preloaderUrl": "web-apps-pro/apps/api/documents/cache-scripts.html"
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -244,7 +245,8 @@ docManager.getStoredFiles = function () {
|
||||
const item = {
|
||||
time: time,
|
||||
name: storedFiles[i],
|
||||
documentType: fileUtility.getFileType(storedFiles[i])
|
||||
documentType: fileUtility.getFileType(storedFiles[i]),
|
||||
canEdit: configServer.get("editedDocs").indexOf(fileUtility.getFileExtension(storedFiles[i])) != -1
|
||||
};
|
||||
|
||||
if (!result.length) {
|
||||
@ -302,7 +304,7 @@ docManager.getKey = function (fileName) {
|
||||
|
||||
let storagePath = docManager.storagePath(fileName, userAddress);
|
||||
const stat = fileSystem.statSync(storagePath);
|
||||
key += stat.mtime.toString();
|
||||
key += stat.mtime.getTime();
|
||||
|
||||
return documentService.generateRevisionId(key);
|
||||
};
|
||||
@ -313,7 +315,10 @@ docManager.getDate = function (date) {
|
||||
};
|
||||
|
||||
docManager.getChanges = function (fileName) {
|
||||
return JSON.parse(fileSystem.readFileSync(fileName));
|
||||
if (this.existsSync(fileName)) {
|
||||
return JSON.parse(fileSystem.readFileSync(fileName));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
docManager.countVersion = function(directory) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -27,7 +27,6 @@
|
||||
var path = require("path");
|
||||
var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
var xml2js = require("xml2js");
|
||||
var jwt = require("jsonwebtoken");
|
||||
var jwa = require("jwa");
|
||||
var fileUtility = require("./fileUtility");
|
||||
@ -47,8 +46,6 @@ var documentService = {};
|
||||
documentService.userIp = null;
|
||||
|
||||
documentService.getConvertedUriSync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
|
||||
|
||||
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, function (err, data) {
|
||||
if (err) {
|
||||
callback();
|
||||
@ -77,11 +74,13 @@ documentService.getConvertedUri = function (documentUri, fromExtension, toExtens
|
||||
|
||||
var uri = siteUrl + configServer.get('converterUrl');
|
||||
var headers = {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
"Accept": "application/json"
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
params.token = documentService.getToken(params);
|
||||
}
|
||||
|
||||
urllib.request(uri,
|
||||
@ -93,38 +92,6 @@ documentService.getConvertedUri = function (documentUri, fromExtension, toExtens
|
||||
callback);
|
||||
};
|
||||
|
||||
documentService.getExternalUri = function (fileStream, contentLength, contentType, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId);
|
||||
|
||||
var urlTostorage = siteUrl + configServer.get('storageUrl') + "?key=" + documentRevisionId;
|
||||
var headers = {
|
||||
"Content-Type": contentType == null ? "application/octet-stream" : contentType,
|
||||
"Content-Length": contentLength.toString(),
|
||||
"charset": "utf-8"
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
const hmac = jwa(cfgSignatureSecretAlgorithmRequest);
|
||||
var payloadhash = hmac.sign(fileStream, cfgSignatureSecret);
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(urlTostorage, undefined, undefined, payloadhash);
|
||||
}
|
||||
|
||||
urllib.request(urlTostorage,
|
||||
{
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
data: fileStream
|
||||
},
|
||||
function (err, data) {
|
||||
if (err) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
var res = documentService.getResponseUri(data);
|
||||
callback(res.value);
|
||||
});
|
||||
};
|
||||
|
||||
documentService.generateRevisionId = function (expectedKey) {
|
||||
if (expectedKey.length > 20) {
|
||||
expectedKey = expectedKey.hashCode().toString();
|
||||
@ -177,33 +144,22 @@ documentService.processConvertServiceResponceError = function (errorCode) {
|
||||
throw { message: errorMessage };
|
||||
};
|
||||
|
||||
documentService.getResponseUri = function (xml) {
|
||||
var json = documentService.convertXmlStringToJson(xml);
|
||||
documentService.getResponseUri = function (json) {
|
||||
var fileResult = JSON.parse(json);
|
||||
|
||||
if (!json.FileResult)
|
||||
throw { message: "FileResult node is null" };
|
||||
if (fileResult.error)
|
||||
documentService.processConvertServiceResponceError(parseInt(fileResult.error));
|
||||
|
||||
var fileResult = json.FileResult;
|
||||
var isEndConvert = fileResult.endConvert
|
||||
|
||||
if (fileResult.Error)
|
||||
documentService.processConvertServiceResponceError(parseInt(fileResult.Error[0]));
|
||||
|
||||
if (!fileResult.EndConvert)
|
||||
throw { message: "EndConvert node is null" };
|
||||
|
||||
var isEndConvert = fileResult.EndConvert[0].toLowerCase() === "true";
|
||||
|
||||
if (!fileResult.Percent)
|
||||
throw { message: "Percent node is null" };
|
||||
|
||||
var percent = parseInt(fileResult.Percent[0]);
|
||||
var percent = parseInt(fileResult.percent);
|
||||
var uri = null;
|
||||
|
||||
if (isEndConvert) {
|
||||
if (!fileResult.FileUrl)
|
||||
throw { message: "FileUrl node is null" };
|
||||
if (!fileResult.fileUrl)
|
||||
throw { message: "FileUrl is null" };
|
||||
|
||||
uri = fileResult.FileUrl[0];
|
||||
uri = fileResult.fileUrl;
|
||||
percent = 100;
|
||||
} else {
|
||||
percent = percent >= 100 ? 99 : percent;
|
||||
@ -215,16 +171,6 @@ documentService.getResponseUri = function (xml) {
|
||||
};
|
||||
};
|
||||
|
||||
documentService.convertXmlStringToJson = function (xml) {
|
||||
var res;
|
||||
|
||||
xml2js.parseString(xml, function (err, result) {
|
||||
res = result;
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
documentService.commandRequest = function (method, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId);
|
||||
var params = {
|
||||
@ -238,6 +184,7 @@ documentService.commandRequest = function (method, documentRevisionId, callback)
|
||||
};
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
params.token = documentService.getToken(params);
|
||||
}
|
||||
|
||||
urllib.request(uri,
|
||||
@ -271,4 +218,18 @@ documentService.fillJwtByUrl = function (uri, opt_dataObject, opt_iss, opt_paylo
|
||||
return jwt.sign(payload, cfgSignatureSecret, options);
|
||||
}
|
||||
|
||||
documentService.getToken = function (data) {
|
||||
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn};
|
||||
return jwt.sign(data, cfgSignatureSecret, options);
|
||||
};
|
||||
|
||||
documentService.readToken = function (token) {
|
||||
try {
|
||||
return jwt.verify(token, cfgSignatureSecret);
|
||||
} catch (err) {
|
||||
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token)
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
module.exports = documentService;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -77,11 +77,11 @@ fileUtility.fileType = {
|
||||
presentation: "presentation"
|
||||
}
|
||||
|
||||
fileUtility.documentExts = [".docx", ".doc", ".odt", ".rtf", ".txt", ".html", ".htm", ".mht", ".pdf", ".djvu", ".fb2", ".epub", ".xps"];
|
||||
fileUtility.documentExts = [".doc", ".docx", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".pdf", ".djvu", ".fb2", ".epub", ".xps"];
|
||||
|
||||
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".ods", ".csv"];
|
||||
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".xlsm", ".xlt", ".xltx", ".xltm", ".ods", ".fods", ".ots", ".csv"];
|
||||
|
||||
fileUtility.presentationExts = [".pps", ".ppsx", ".ppt", ".pptx", ".odp"];
|
||||
fileUtility.presentationExts = [".pps", ".ppsx", ".ppsm", ".ppt", ".pptx", ".pptm", ".pot", ".potx", ".potm", ".odp", ".fodp", ".otp"];
|
||||
|
||||
function getUrlParams(url) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
"mime": "^1.3.4",
|
||||
"serve-favicon": "~2.3.0",
|
||||
"sync-request": "^4.0.1",
|
||||
"urllib": "^2.20.0",
|
||||
"xml2js": "~0.4.17"
|
||||
"urllib": "^2.20.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 152 B |
BIN
web/documentserver-example/nodejs/public/images/filter-24.png
Normal file
BIN
web/documentserver-example/nodejs/public/images/filter-24.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 118 B |
BIN
web/documentserver-example/nodejs/public/images/presentation.ico
Normal file
BIN
web/documentserver-example/nodejs/public/images/presentation.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
BIN
web/documentserver-example/nodejs/public/images/spreadsheet.ico
Normal file
BIN
web/documentserver-example/nodejs/public/images/spreadsheet.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
BIN
web/documentserver-example/nodejs/public/images/text.ico
Normal file
BIN
web/documentserver-example/nodejs/public/images/text.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -70,6 +70,9 @@ if (typeof jQuery != "undefined") {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
add: function (e, data) {
|
||||
if (jq("#mainProgress").is(":visible")) {
|
||||
return;
|
||||
}
|
||||
jq(".error").removeClass("error");
|
||||
jq(".done").removeClass("done");
|
||||
jq(".current").removeClass("current");
|
||||
@ -133,10 +136,9 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
timer = setTimeout(function () {
|
||||
var requestAddress = UrlConverter + "?filename=" + encodeURIComponent(jq("#hiddenFileName").val());
|
||||
|
||||
jq.ajaxSetup({ cache: false });
|
||||
jq.ajax({
|
||||
async: true,
|
||||
contentType: "text/xml",
|
||||
type: "get",
|
||||
url: requestAddress,
|
||||
complete: function (data) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
"comment": <%- editor.comment %>,
|
||||
"download": true,
|
||||
"edit": <%- editor.isEdit %>,
|
||||
"fillForms": <%- editor.fillForms %>,
|
||||
"modifyFilter": <%- editor.modifyFilter %>,
|
||||
"review": <%- editor.review %>
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -33,7 +33,9 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<title>ONLYOFFICE</title>
|
||||
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
|
||||
<link rel="icon"
|
||||
href="images/<%- editor.documentType %>.ico"
|
||||
type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/editor.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>ONLYOFFICE Integration Edition</title>
|
||||
<title>ONLYOFFICE Document Editors</title>
|
||||
<link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" />
|
||||
@ -44,10 +44,10 @@
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Integration Edition – Welcome!</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Integration Edition, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
<table class="user-block-table" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="middle" width="30%">
|
||||
@ -63,7 +63,7 @@
|
||||
<tr>
|
||||
<td valign="middle" width="30%">
|
||||
<select class="select-user" id="language">
|
||||
<option value="en" selected>English</option>
|
||||
<option value="en">English</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="es">Espanol</option>
|
||||
<option value="fr">Francais</option>
|
||||
@ -130,7 +130,7 @@
|
||||
<thead>
|
||||
<tr class="tableHeader">
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
|
||||
<td colspan="4" class="tableHeaderCell contentCells-shift">Editors</td>
|
||||
<td colspan="5" class="tableHeaderCell contentCells-shift">Editors</td>
|
||||
<td colspan="3" class="tableHeaderCell">Viewers</td>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -145,6 +145,7 @@
|
||||
<a class="delete-file" data="<%= encodeURIComponent(storedFiles[i].name) %>">
|
||||
<img class="icon-delete" src="images/delete-24.png" alt="Delete" title="Delete" /></a>
|
||||
</td>
|
||||
<% if (storedFiles[i].canEdit) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>
|
||||
@ -157,14 +158,24 @@
|
||||
<% if (storedFiles[i].documentType == "text") { %>
|
||||
<a href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/review-24.png" alt="Open in editor for review" title="Open in editor for review" /></a>
|
||||
<% } else if (storedFiles[i].documentType == "spreadsheet") { %>
|
||||
<a href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/filter-24.png" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>
|
||||
<% } %>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/comment-24.png" alt="Open in editor for comment" title="Open in editor for comment" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon">
|
||||
<% if (storedFiles[i].documentType == "text") { %>
|
||||
<a href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/comment-24.png" alt="Open in editor for comment" title="Open in editor for comment" /></a>
|
||||
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/fill-forms-24.png" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
|
||||
<% } %>
|
||||
</td>
|
||||
<% } else { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon" colspan="5"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>
|
||||
@ -190,7 +201,7 @@
|
||||
<div class="help-block">
|
||||
<span>Want to learn the magic?</span>
|
||||
<br />
|
||||
Explore ONLYOFFICE Integration Edition <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
Explore ONLYOFFICE Document Editors <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
@ -234,7 +245,7 @@
|
||||
|
||||
<span id="loadScripts" data-docs="<%= preloaderUrl %>"></span>
|
||||
|
||||
<footer>© Ascensio Systems Inc 2017. All rights reserved.</footer>
|
||||
<footer>© Ascensio Systems Inc 2018. All rights reserved.</footer>
|
||||
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -32,7 +32,11 @@ require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
|
||||
function sendlog($msg, $logFileName) {
|
||||
file_put_contents($logFileName, $msg . PHP_EOL, FILE_APPEND);
|
||||
$logsFolder = "logs/";
|
||||
if (!file_exists($logsFolder)) {
|
||||
mkdir($logsFolder);
|
||||
}
|
||||
file_put_contents($logsFolder . $logFileName, $msg . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
function guid() {
|
||||
@ -143,10 +147,10 @@ function getClientIp() {
|
||||
return $ipaddress;
|
||||
}
|
||||
|
||||
function serverPath($forDocumentServer) {
|
||||
return $forDocumentServer && isset($GLOBALS['EXAMPLE_URL']) && $GLOBALS['EXAMPLE_URL'] != ""
|
||||
? $GLOBALS['EXAMPLE_URL']
|
||||
: ('http://' . $_SERVER['HTTP_HOST']);
|
||||
function serverPath($forDocumentServer = NULL) {
|
||||
return $forDocumentServer && isset($GLOBALS['EXAMPLE_URL']) && $GLOBALS['EXAMPLE_URL'] != ""
|
||||
? $GLOBALS['EXAMPLE_URL']
|
||||
: (getScheme() . '://' . $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
function getCurUserHostAddress($userAddress = NULL) {
|
||||
@ -201,7 +205,7 @@ function getStoragePath($fileName, $userAddress = NULL) {
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
sendlog("getStoragePath result: " . $directory . $fileName, "logs/common.log");
|
||||
sendlog("getStoragePath result: " . $directory . $fileName, "common.log");
|
||||
return $directory . $fileName;
|
||||
}
|
||||
|
||||
@ -212,24 +216,24 @@ function getStoredFiles() {
|
||||
$result = array();
|
||||
if ($storagePath != "")
|
||||
{
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$directory = $directory . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
$directory = $directory . getCurUserHostAddress() . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$cdir = scandir($directory);
|
||||
$result = array();
|
||||
foreach($cdir as $key => $fileName) {
|
||||
if (!in_array($fileName,array(".", ".."))) {
|
||||
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName);
|
||||
$result[$dat] = (object) array(
|
||||
"name" => $fileName,
|
||||
@ -248,12 +252,12 @@ function getVirtualPath($forDocumentServer) {
|
||||
|
||||
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
sendlog("getVirtualPath virtPath: " . $virtPath, "logs/common.log");
|
||||
sendlog("getVirtualPath virtPath: " . $virtPath, "common.log");
|
||||
return $virtPath;
|
||||
}
|
||||
|
||||
function FileUri($file_name, $forDocumentServer) {
|
||||
$uri = getVirtualPath($forDocumentServer) . $file_name;
|
||||
function FileUri($file_name, $forDocumentServer = NULL) {
|
||||
$uri = getVirtualPath($forDocumentServer) . rawurlencode($file_name);
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
@ -6,36 +6,36 @@ $GLOBALS['ALONE'] = FALSE;
|
||||
|
||||
$GLOBALS['MODE'] = "";
|
||||
|
||||
$GLOBALS['DOC_SERV_VIEWD'] = array(".ppt",".pps",".odp",".pdf",".djvu",".epub",".xps");
|
||||
$GLOBALS['DOC_SERV_EDITED'] = array(".docx",".doc",".odt",".xlsx",".xls",".ods",".csv",".pptx",".ppsx",".rtf",".txt",".mht",".html",".htm");
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = array(".doc",".odt",".xls",".ods",".ppt",".pps",".odp",".rtf",".mht",".html",".htm",".epub");
|
||||
$GLOBALS['DOC_SERV_VIEWD'] = array(".pdf", ".djvu", ".xps");
|
||||
$GLOBALS['DOC_SERV_EDITED'] = array(".docx", ".xlsx", ".csv", ".pptx", ".ppsx", ".txt");
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = array(".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub");
|
||||
|
||||
$GLOBALS['DOC_SERV_TIMEOUT'] = "120000";
|
||||
|
||||
$GLOBALS['DOC_SERV_STORAGE_URL'] = "https://doc.onlyoffice.com/FileUploader.ashx";
|
||||
$GLOBALS['DOC_SERV_CONVERTER_URL'] = "https://doc.onlyoffice.com/ConvertService.ashx";
|
||||
$GLOBALS['DOC_SERV_API_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js";
|
||||
$GLOBALS['DOC_SERV_CONVERTER_URL'] = "https://documentserver/ConvertService.ashx";
|
||||
$GLOBALS['DOC_SERV_API_URL'] = "https://documentserver/web-apps/apps/api/documents/api.js";
|
||||
|
||||
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html";
|
||||
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://documentserver/web-apps/apps/api/documents/cache-scripts.html";
|
||||
|
||||
$GLOBALS['EXAMPLE_URL'] = "";
|
||||
|
||||
$GLOBALS['MOBILE_REGEX'] = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
|
||||
|
||||
|
||||
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx",
|
||||
".ods", ".csv");
|
||||
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx", ".xlsm",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv");
|
||||
|
||||
$GLOBALS['ExtsPresentation'] = array(".pps", ".ppsx",
|
||||
".ppt", ".pptx",
|
||||
".odp");
|
||||
$GLOBALS['ExtsPresentation'] = array(".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp");
|
||||
|
||||
$GLOBALS['ExtsDocument'] = array(".docx", ".doc", ".odt", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".pdf", ".djvu",
|
||||
".fb2", ".epub", ".xps");
|
||||
|
||||
if ( !defined('ServiceConverterMaxTry') )
|
||||
define( 'ServiceConverterMaxTry', 3);
|
||||
$GLOBALS['ExtsDocument'] = array(".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps");
|
||||
|
||||
|
||||
?>
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
if(!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . "app_data" . DIRECTORY_SEPARATOR . $demoName, getStoragePath($demoFilename)))
|
||||
{
|
||||
sendlog("Copy file error to ". getStoragePath($demoFilename), "logs/common.log");
|
||||
sendlog("Copy file error to ". getStoragePath($demoFilename), "common.log");
|
||||
//Copy error!!!
|
||||
}
|
||||
|
||||
@ -228,23 +228,6 @@
|
||||
window.attachEvent("load", сonnectEditor);
|
||||
}
|
||||
|
||||
function getXmlHttp() {
|
||||
var xmlhttp;
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (ex) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
return xmlhttp;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -31,56 +31,6 @@
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
|
||||
|
||||
function GetExternalFileUri($local_uri) {
|
||||
$externalUri = '';
|
||||
|
||||
try
|
||||
{
|
||||
$documentRevisionId = GenerateRevisionId($local_uri);
|
||||
|
||||
if (($fileContents = file_get_contents(str_replace(" ","%20", $local_uri))) === FALSE) {
|
||||
throw new Exception("Bad Request");
|
||||
} else {
|
||||
$contentType = mime_content_type($local_uri);
|
||||
|
||||
$urlToService = generateUrlToStorage('', '', '', '', $documentRevisionId);
|
||||
|
||||
$opts = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n" .
|
||||
"Content-Type: " . $contentType . "\r\n" .
|
||||
"Content-Length: " . strlen($fileContents) . "\r\n",
|
||||
'content' => $fileContents,
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT']
|
||||
)
|
||||
);
|
||||
|
||||
if (substr($urlToService, 0, strlen("https")) === "https") {
|
||||
$opts['ssl'] = array( 'verify_peer' => FALSE );
|
||||
}
|
||||
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
if (($response_data = file_get_contents($urlToService, FALSE, $context)) === FALSE) {
|
||||
throw new Exception ("Could not get an answer");
|
||||
} else {
|
||||
sendlog("GetExternalUri response_data:" . PHP_EOL . $response_data, "logs/common.log");
|
||||
GetResponseUri($response_data, $externalUri);
|
||||
}
|
||||
|
||||
sendlog("GetExternalFileUri. externalUri = " . $externalUri, "logs/common.log");
|
||||
return $externalUri . "";
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
sendlog("GetExternalFileUri Exception: " . $e->getMessage(), "logs/common.log");
|
||||
}
|
||||
return $local_uri;
|
||||
}
|
||||
|
||||
|
||||
function DoUpload($fileUri) {
|
||||
$_fileName = GetCorrectName($fileUri);
|
||||
|
||||
@ -101,18 +51,6 @@ function DoUpload($fileUri) {
|
||||
}
|
||||
|
||||
|
||||
function generateUrlToStorage($document_uri, $from_extension, $to_extension, $title, $document_revision_id) {
|
||||
|
||||
return $GLOBALS['DOC_SERV_STORAGE_URL'] . "?" . http_build_query(
|
||||
array(
|
||||
"url" => $document_uri,
|
||||
"outputtype" => trim($to_extension,'.'),
|
||||
"filetype" => trim($from_extension, '.'),
|
||||
"title" => $title,
|
||||
"key" => $document_revision_id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate an error code table
|
||||
*
|
||||
@ -185,7 +123,7 @@ function GenerateRevisionId($expected_key) {
|
||||
* @param string $document_revision_id Key for caching on service
|
||||
* @param bool $is_async Perform conversions asynchronously
|
||||
*
|
||||
* @return Xml document request result of conversion
|
||||
* @return Document request result of conversion
|
||||
*/
|
||||
function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async) {
|
||||
if (empty($from_extension))
|
||||
@ -218,13 +156,11 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
)
|
||||
);
|
||||
|
||||
$response_xml_data;
|
||||
$countTry = 0;
|
||||
|
||||
$opts = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
|
||||
'header'=> "Content-type: application/json\r\n",
|
||||
'header'=> "Content-type: application/json\r\n" .
|
||||
"Accept: application/json\r\n",
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
@ -234,30 +170,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
}
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
while ($countTry < ServiceConverterMaxTry)
|
||||
{
|
||||
$countTry = $countTry + 1;
|
||||
$response_xml_data = file_get_contents($urlToConverter, FALSE, $context);
|
||||
if ($response_xml_data !== false) { break; }
|
||||
}
|
||||
|
||||
if ($countTry == ServiceConverterMaxTry)
|
||||
{
|
||||
throw new Exception ("Bad Request or timeout error");
|
||||
}
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
if (!function_exists('simplexml_load_file')) {
|
||||
throw new Exception("Server can't read xml");
|
||||
}
|
||||
$response_data = simplexml_load_string($response_xml_data);
|
||||
if (!$response_data) {
|
||||
$exc = "Bad Response. Errors: ";
|
||||
foreach(libxml_get_errors() as $error) {
|
||||
$exc = $exc . "\t" . $error->message;
|
||||
}
|
||||
throw new Exception ($exc);
|
||||
}
|
||||
$response_data = file_get_contents($urlToConverter, FALSE, $context);
|
||||
|
||||
return $response_data;
|
||||
}
|
||||
@ -304,39 +217,28 @@ function GetConvertedUri($document_uri, $from_extension, $to_extension, $documen
|
||||
/**
|
||||
* Processing document received from the editing service.
|
||||
*
|
||||
* @param string $x_document_response The resulting xml from editing service
|
||||
* @param string $document_response The result from editing service
|
||||
* @param string $response_uri Uri to the converted document
|
||||
*
|
||||
* @return The percentage of completion of conversion
|
||||
*/
|
||||
function GetResponseUri($x_document_response, &$response_uri) {
|
||||
function GetResponseUri($document_response, &$response_uri) {
|
||||
$response_uri = "";
|
||||
$resultPercent = 0;
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
if (!function_exists('simplexml_load_file')) {
|
||||
throw new Exception("Server can't read xml");
|
||||
}
|
||||
$data = simplexml_load_string($x_document_response);
|
||||
|
||||
if (!$data) {
|
||||
$errs = "Invalid answer format. Errors: ";
|
||||
foreach(libxml_get_errors() as $error) {
|
||||
$errs = $errs . '\t' . $error->message;
|
||||
}
|
||||
|
||||
throw new Exception ($errs);
|
||||
if (!$document_response) {
|
||||
$errs = "Invalid answer format";
|
||||
}
|
||||
|
||||
$errorElement = $data->Error;
|
||||
if ($errorElement != NULL && $errorElement != "") ProcessConvServResponceError($data->Error);
|
||||
$errorElement = $document_response->Error;
|
||||
if ($errorElement != NULL && $errorElement != "") ProcessConvServResponceError($document_response->Error);
|
||||
|
||||
$endConvert = $data->EndConvert;
|
||||
$endConvert = $document_response->EndConvert;
|
||||
if ($endConvert != NULL && $endConvert == "") throw new Exception("Invalid answer format");
|
||||
|
||||
if ($endConvert != NULL && strtolower($endConvert) == true)
|
||||
{
|
||||
$fileUrl = $data->FileUrl;
|
||||
$fileUrl = $document_response->FileUrl;
|
||||
if ($fileUrl == NULL || $fileUrl == "") throw new Exception("Invalid answer format");
|
||||
|
||||
$response_uri = $fileUrl;
|
||||
@ -344,7 +246,7 @@ function GetResponseUri($x_document_response, &$response_uri) {
|
||||
}
|
||||
else
|
||||
{
|
||||
$percent = $data->Percent;
|
||||
$percent = $document_response->Percent;
|
||||
|
||||
if ($percent != NULL && $percent != "")
|
||||
$resultPercent = $percent;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>ONLYOFFICE Integration Edition</title>
|
||||
<title>ONLYOFFICE Document Editors</title>
|
||||
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
|
||||
@ -74,10 +74,10 @@
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Integration Edition – Welcome!</span>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Integration Edition, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<table class="user-block-table" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
@ -177,7 +177,7 @@
|
||||
echo ' <a class="stored-edit '.$storeFile->documentType.'" href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'" target="_blank">';
|
||||
echo ' <span title="'.$storeFile->name.'">'.$storeFile->name.'</span>';
|
||||
echo ' </a>';
|
||||
echo ' <a href="webeditor-ajax.php?type=download&filename='.$storeFile->name.'">';
|
||||
echo ' <a href="'.FileUri($storeFile->name).'">';
|
||||
echo ' <img class="icon-download" src="css/images/download-24.png" alt="Download" title="Download" /></a>';
|
||||
echo ' </a>';
|
||||
echo ' <a class="delete-file" data="'.$storeFile->name.'">';
|
||||
@ -231,7 +231,7 @@
|
||||
<div class="help-block">
|
||||
<span>Want to learn the magic?</span>
|
||||
<br />
|
||||
Explore ONLYOFFICE Integration Edition <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
Explore ONLYOFFICE Document Editors <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
* (c) Copyright Ascensio System Limited 2010-2018
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -52,7 +52,7 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
|
||||
|
||||
nocache_headers();
|
||||
|
||||
sendlog(serialize($_GET),"logs/webedior-ajax.log");
|
||||
sendlog(serialize($_GET), "webedior-ajax.log");
|
||||
|
||||
$type = $_GET["type"];
|
||||
|
||||
@ -61,9 +61,6 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
|
||||
$response_array = upload();
|
||||
$response_array['status'] = isset($response_array['error']) ? 'error' : 'success';
|
||||
die (json_encode($response_array));
|
||||
case "download":
|
||||
download();
|
||||
exit;
|
||||
case "convert":
|
||||
$response_array = convert();
|
||||
$response_array['status'] = 'success';
|
||||
@ -128,24 +125,9 @@ function upload() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function download() {
|
||||
$fileName = $_GET["filename"];
|
||||
|
||||
$filePath = getStoragePath($fileName);
|
||||
if (!file_exists($filePath)) {
|
||||
http_response_code(404);
|
||||
return;
|
||||
}
|
||||
header("Content-Length: " . filesize($filePath));
|
||||
header("Content-Type: " . mime_content_type($fileName));
|
||||
|
||||
header("Content-Disposition: attachment; filename=\"".basename($filePath)."\"");
|
||||
readfile($filePath);
|
||||
}
|
||||
|
||||
function track() {
|
||||
sendlog("Track START", "logs/webedior-ajax.log");
|
||||
sendlog("_GET params: " . serialize( $_GET ), "logs/webedior-ajax.log");
|
||||
sendlog("Track START", "webedior-ajax.log");
|
||||
sendlog("_GET params: " . serialize( $_GET ), "webedior-ajax.log");
|
||||
|
||||
global $_trackerStatus;
|
||||
$data;
|
||||
@ -163,7 +145,7 @@ function track() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
sendlog("InputStream data: " . serialize($data), "logs/webedior-ajax.log");
|
||||
sendlog("InputStream data: " . serialize($data), "webedior-ajax.log");
|
||||
|
||||
$status = $_trackerStatus[$data["status"]];
|
||||
|
||||
@ -183,12 +165,12 @@ function track() {
|
||||
$key = getDocEditorKey(downloadUri);
|
||||
|
||||
try {
|
||||
sendlog("Convert " . $downloadUri . " from " . $downloadExt . " to " . $curExt, "logs/webedior-ajax.log");
|
||||
sendlog("Convert " . $downloadUri . " from " . $downloadExt . " to " . $curExt, "webedior-ajax.log");
|
||||
$convertedUri;
|
||||
$percent = GetConvertedUri($downloadUri, $downloadExt, $curExt, $key, FALSE, $convertedUri);
|
||||
$downloadUri = $convertedUri;
|
||||
} catch (Exception $e) {
|
||||
sendlog("Convert after save ".$e->getMessage(), "logs/webedior-ajax.log");
|
||||
sendlog("Convert after save ".$e->getMessage(), "webedior-ajax.log");
|
||||
$result["error"] = "error: " . $e->getMessage();
|
||||
return $result;
|
||||
}
|
||||
@ -208,7 +190,7 @@ function track() {
|
||||
break;
|
||||
}
|
||||
|
||||
sendlog("track result: " . serialize($result), "logs/webedior-ajax.log");
|
||||
sendlog("track result: " . serialize($result), "webedior-ajax.log");
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -274,7 +256,7 @@ function delete() {
|
||||
unlink($filePath);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
sendlog("Deletion ".$e->getMessage(), "logs/webedior-ajax.log");
|
||||
sendlog("Deletion ".$e->getMessage(), "webedior-ajax.log");
|
||||
$result["error"] = "error: " . $e->getMessage();
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -36,51 +36,51 @@ GEM
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.0)
|
||||
arel (6.0.4)
|
||||
binding_of_caller (0.7.2)
|
||||
debug_inspector (>= 0.0.1)
|
||||
builder (3.2.2)
|
||||
byebug (3.5.1)
|
||||
columnize (~> 0.8)
|
||||
debugger-linecache (~> 1.2)
|
||||
slop (~> 3.6)
|
||||
coffee-rails (4.1.0)
|
||||
builder (3.2.3)
|
||||
byebug (9.1.0)
|
||||
coffee-rails (4.1.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
coffee-script (2.3.0)
|
||||
railties (>= 4.0.0, < 5.1.x)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.8.0)
|
||||
columnize (0.9.0)
|
||||
debug_inspector (0.0.2)
|
||||
debugger-linecache (1.2.0)
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.2)
|
||||
debug_inspector (0.0.3)
|
||||
erubis (2.7.0)
|
||||
execjs (2.2.2)
|
||||
globalid (0.3.0)
|
||||
activesupport (>= 4.1.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.2.6)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (4.0.3)
|
||||
rails-dom-testing (~> 1.0)
|
||||
execjs (2.7.0)
|
||||
ffi (1.9.18)
|
||||
globalid (0.4.0)
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (0.8.6)
|
||||
jbuilder (2.7.0)
|
||||
activesupport (>= 4.2.0)
|
||||
multi_json (>= 1.2)
|
||||
jquery-rails (4.3.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.2)
|
||||
loofah (2.0.1)
|
||||
json (1.8.6)
|
||||
loofah (2.1.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
macaddr (1.7.1)
|
||||
systemu (~> 2.6.2)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
multi_json (1.10.1)
|
||||
nokogiri (1.6.6.1-x86-mingw32)
|
||||
mini_portile (~> 0.6.0)
|
||||
rack (1.6.0)
|
||||
mail (2.6.6)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
multi_json (1.12.2)
|
||||
nokogiri (1.8.1)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
rack (1.6.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.0)
|
||||
@ -96,64 +96,65 @@ GEM
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.5)
|
||||
rails-dom-testing (1.0.8)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.0)
|
||||
actionpack (= 4.2.0)
|
||||
activesupport (= 4.2.0)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
json (~> 1.4)
|
||||
sass (3.4.10)
|
||||
sass-rails (5.0.1)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
rake (12.1.0)
|
||||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rdoc (4.3.0)
|
||||
sass (3.5.2)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.6)
|
||||
railties (>= 4.0.0, < 6)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (~> 1.1)
|
||||
sdoc (0.4.1)
|
||||
tilt (>= 1.1, < 3)
|
||||
sdoc (0.4.2)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
slop (3.6.0)
|
||||
sprockets (2.12.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.2.4)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10-x86-mingw32)
|
||||
systemu (2.6.4)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.4)
|
||||
tilt (1.4.1)
|
||||
turbolinks (2.5.3)
|
||||
coffee-rails
|
||||
tzinfo (1.2.2)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
systemu (2.6.5)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
turbolinks (5.0.1)
|
||||
turbolinks-source (~> 5)
|
||||
turbolinks-source (5.0.3)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo-data (1.2014.10)
|
||||
tzinfo (>= 1.0.0)
|
||||
uglifier (2.7.0)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
uuid (2.3.7)
|
||||
uglifier (3.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
uuid (2.3.8)
|
||||
macaddr (~> 1.0)
|
||||
web-console (2.0.0)
|
||||
activemodel (~> 4.0)
|
||||
web-console (2.3.0)
|
||||
activemodel (>= 4.0)
|
||||
binding_of_caller (>= 0.7.2)
|
||||
railties (~> 4.0)
|
||||
railties (>= 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
|
||||
PLATFORMS
|
||||
x86-mingw32
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
byebug
|
||||
@ -169,3 +170,6 @@ DEPENDENCIES
|
||||
uglifier (>= 1.3.0)
|
||||
uuid
|
||||
web-console (~> 2.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.4
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
Copyright (c) 2018 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) Ascensio System SIA 2017. All rights reserved.
|
||||
Copyright (c) Ascensio System SIA 2018. All rights reserved.
|
||||
http://www.onlyoffice.com
|
||||
*/
|
||||
if (typeof jQuery != "undefined") {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) Ascensio System SIA 2017. All rights reserved.
|
||||
Copyright (c) Ascensio System SIA 2018. All rights reserved.
|
||||
http://www.onlyoffice.com
|
||||
*/
|
||||
html {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) Ascensio System SIA 2017. All rights reserved.
|
||||
Copyright (c) Ascensio System SIA 2018. All rights reserved.
|
||||
http://www.onlyoffice.com
|
||||
*/
|
||||
html {
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
require 'net/http'
|
||||
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
end
|
||||
@ -117,7 +119,7 @@ class HomeController < ApplicationController
|
||||
|
||||
if status == 2 || status == 3 #MustSave, Corrupted
|
||||
|
||||
saved = 1
|
||||
saved = 0
|
||||
|
||||
begin
|
||||
|
||||
@ -143,12 +145,15 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
rescue
|
||||
saved = 0
|
||||
saved = 1
|
||||
end
|
||||
|
||||
render :text => '{"error":0,"c":"saved","status":' + saved.to_s + '}'
|
||||
|
||||
render :text => '{"error":' + saved.to_s + '}'
|
||||
return
|
||||
end
|
||||
|
||||
render :text => '{"error":0}'
|
||||
return
|
||||
|
||||
end
|
||||
end
|
||||
@ -1,10 +1,10 @@
|
||||
class FileUtility
|
||||
|
||||
@@exts_document = %w(.docx .doc .odt .rtf .txt .html .htm .mht .pdf .djvu .fb2 .epub .xps)
|
||||
@@exts_document = %w(.doc .docx .docm .dot .dotx .dotm .odt .fodt .ott .rtf .txt .html .htm .mht .pdf .djvu .fb2 .epub .xps)
|
||||
|
||||
@@exts_spreadsheet = %w(.xls .xlsx .ods .csv)
|
||||
@@exts_spreadsheet = %w(.xls .xlsx .xlsm .xlt .xltx .xltm .ods .fods .ots .csv)
|
||||
|
||||
@@exts_presentation = %w(.pps .ppsx .ppt .pptx .odp)
|
||||
@@exts_presentation = %w(.pps .ppsx .ppsm .ppt .pptx .pptm .pot .potx .potm .odp .fodp .otp)
|
||||
|
||||
class << self
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user