wirispluginengine 3.62.0.1322 → 7.14.0.1422

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +34 -34
  3. data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
  4. data/app/controllers/wirispluginengine/application_controller.rb +84 -75
  5. data/app/helpers/wirispluginengine/application_helper.rb +4 -4
  6. data/config/routes.rb +4 -4
  7. data/lib/com/wiris/common/WInteger.rb +52 -51
  8. data/lib/com/wiris/plugin/api/Cas.rb +5 -5
  9. data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
  10. data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
  11. data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
  12. data/lib/com/wiris/plugin/api/Editor.rb +5 -5
  13. data/lib/com/wiris/plugin/api/Filter.rb +5 -5
  14. data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
  15. data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
  16. data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
  17. data/lib/com/wiris/plugin/api/Render.rb +5 -5
  18. data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
  19. data/lib/com/wiris/plugin/api/Test.rb +5 -5
  20. data/lib/com/wiris/plugin/api/TextService.rb +5 -5
  21. data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
  22. data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
  23. data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
  24. data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
  25. data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
  26. data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
  27. data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
  28. data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
  29. data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
  30. data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
  31. data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
  32. data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
  33. data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
  34. data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
  35. data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
  36. data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
  37. data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
  38. data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
  39. data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
  40. data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
  41. data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
  42. data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
  43. data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
  44. data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
  45. data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
  46. data/lib/com/wiris/util/json/JSon.rb +505 -493
  47. data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
  48. data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
  49. data/lib/com/wiris/util/json/StringParser.rb +57 -56
  50. data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
  51. data/lib/com/wiris/util/sys/Cache.rb +8 -0
  52. data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
  53. data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
  54. data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
  55. data/lib/com/wiris/util/sys/IniFile.rb +132 -131
  56. data/lib/com/wiris/util/sys/Lock.rb +8 -0
  57. data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
  58. data/lib/com/wiris/util/sys/Store.rb +126 -101
  59. data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
  60. data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
  61. data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
  62. data/lib/com/wiris/util/type/Arrays.rb +275 -0
  63. data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
  64. data/lib/com/wiris/util/type/Comparator.rb +8 -0
  65. data/lib/com/wiris/util/type/DataUtils.rb +24 -0
  66. data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
  67. data/lib/com/wiris/util/type/HashCache.rb +43 -0
  68. data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
  69. data/lib/com/wiris/util/type/Queue.rb +31 -0
  70. data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
  71. data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
  72. data/lib/com/wiris/util/type/SortedHash.rb +45 -0
  73. data/lib/com/wiris/util/type/Stack.rb +31 -0
  74. data/lib/com/wiris/util/type/StringUtils.rb +56 -0
  75. data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
  76. data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
  77. data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
  78. data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
  79. data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
  80. data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
  81. data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
  82. data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
  83. data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
  84. data/lib/com/wiris/util/xml/WEntities.rb +11 -9
  85. data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
  86. data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
  87. data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
  88. data/lib/loader.rb +15 -12
  89. data/lib/src-generic/Array.rb +22 -22
  90. data/lib/src-generic/ArrayInt.rb +31 -31
  91. data/lib/src-generic/Base64.rb +14 -14
  92. data/lib/src-generic/BaseCode.rb +93 -93
  93. data/lib/src-generic/Boolean.rb +27 -0
  94. data/lib/src-generic/Bytes.rb +50 -50
  95. data/lib/src-generic/BytesInput.rb +37 -37
  96. data/lib/src-generic/EReg.rb +55 -55
  97. data/lib/src-generic/File.rb +35 -35
  98. data/lib/src-generic/FileLock.rb +26 -26
  99. data/lib/src-generic/FileSystem.rb +37 -37
  100. data/lib/src-generic/Hash.rb +42 -42
  101. data/lib/src-generic/Http.rb +111 -107
  102. data/lib/src-generic/HttpRequest.rb +25 -25
  103. data/lib/src-generic/HttpResponse.rb +70 -70
  104. data/lib/src-generic/Iterator.rb +20 -19
  105. data/lib/src-generic/Math.rb +14 -14
  106. data/lib/src-generic/Md5.rb +8 -8
  107. data/lib/src-generic/Md5Tools.rb +11 -11
  108. data/lib/src-generic/PropertiesTools.rb +32 -32
  109. data/lib/src-generic/Reflect.rb +16 -16
  110. data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
  111. data/lib/src-generic/Serializer.rb +84 -84
  112. data/lib/src-generic/Std.rb +74 -74
  113. data/lib/src-generic/Storage.rb +152 -152
  114. data/lib/src-generic/StringBuf.rb +40 -40
  115. data/lib/src-generic/StringTools.rb +44 -46
  116. data/lib/src-generic/Timer.rb +6 -6
  117. data/lib/src-generic/Type.rb +18 -18
  118. data/lib/src-generic/TypeTools.rb +31 -31
  119. data/lib/src-generic/Unserializer.rb +72 -72
  120. data/lib/src-generic/Utf8.rb +26 -26
  121. data/lib/src-generic/Xml.rb +199 -198
  122. data/lib/src-generic/extended/Integer.rb +5 -5
  123. data/lib/src-generic/extended/Math.rb +6 -6
  124. data/lib/src-generic/extended/Properties.rb +11 -11
  125. data/lib/src-generic/extended/String.rb +38 -38
  126. data/lib/src-generic/settings/PlatformSettings.rb +18 -18
  127. data/lib/src-generic/system/HttpProxy.rb +23 -0
  128. data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
  129. data/lib/wirispluginengine.rb +5 -5
  130. data/lib/wirispluginengine/engine.rb +5 -5
  131. data/lib/wirispluginengine/integration/cleancache.rb +8 -8
  132. data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
  133. data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
  134. data/lib/wirispluginengine/integration/createimage.rb +7 -7
  135. data/lib/wirispluginengine/integration/getmathml.rb +18 -18
  136. data/lib/wirispluginengine/integration/resource.rb +8 -8
  137. data/lib/wirispluginengine/integration/service.rb +5 -5
  138. data/lib/wirispluginengine/integration/showimage.rb +28 -21
  139. data/lib/wirispluginengine/integration/test.rb +5 -5
  140. data/lib/wirispluginengine/integration/testfilter.rb +10 -0
  141. data/lib/wirispluginengine/version.rb +2 -2
  142. data/resources/VERSION +1 -1
  143. data/resources/WEB-INF/web.xml +25 -0
  144. data/resources/WIRISplugins.js +3809 -0
  145. data/resources/default-configuration.ini +47 -45
  146. data/resources/tech.txt +1 -1
  147. data/resources/wirisplugin.css +43 -42
  148. metadata +40 -4
  149. data/configuration.ini.dist +0 -104
@@ -1,34 +1,43 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/util/xml/WXmlUtils.rb')
4
- require('com/wiris/plugin/api/ImageFormatController.rb')
5
- class ImageFormatControllerSvg
6
- extend ImageFormatControllerInterface
3
+ require('com/wiris/plugin/api/ImageFormatController.rb')
4
+ require('com/wiris/plugin/api/ImageFormatController.rb')
5
+ class ImageFormatControllerSvg
6
+ extend ImageFormatControllerInterface
7
7
 
8
- include Wiris
8
+ include Wiris
9
+
10
+ def initialize()
11
+ super()
12
+ end
13
+ def getContentType()
14
+ return "image/svg+xml"
15
+ end
16
+ def getMetrics(bytes, ref_output)
17
+ svg = bytes::toString()
18
+ svgRoot = Std::substr(svg,0,svg::indexOf(">"))
19
+ firstIndex = svgRoot::indexOf("height=") + 8
20
+ endIndex = svgRoot::indexOf("\"",firstIndex)
21
+ height = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
22
+ firstIndex = svgRoot::indexOf("width=") + 7
23
+ endIndex = svgRoot::indexOf("\"",firstIndex)
24
+ width = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
25
+ firstIndex = svgRoot::indexOf("wrs:baseline=") + 14
26
+ endIndex = svgRoot::indexOf("\"",firstIndex)
27
+ baseline = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
28
+ output = ref_output
29
+ if output != nil
30
+ PropertiesTools::setProperty(output,"width","" + width)
31
+ PropertiesTools::setProperty(output,"height","" + height)
32
+ PropertiesTools::setProperty(output,"baseline","" + baseline)
33
+ r = ""
34
+ else
35
+ r = (((("&cw=" + width) + "&ch=") + height) + "&cb=") + baseline
36
+ end
37
+ return r
38
+ end
39
+ def scalateMetrics(dpi, metrics)
40
+ end
9
41
 
10
- def initialize()
11
- super()
12
- end
13
- def getContentType()
14
- return "image/svg+xml"
15
- end
16
- def getMetrics(bytes,ref_output)
17
- svg = bytes::toString()
18
- output = ref_output
19
- svgXml = WXmlUtils::parseXML(svg)
20
- width = svgXml::firstElement()::get("width")
21
- height = svgXml::firstElement()::get("height")
22
- baseline = svgXml::firstElement()::get("wrs:baseline")
23
- if output!=nil
24
- PropertiesTools::setProperty(output,"width",""+width)
25
- PropertiesTools::setProperty(output,"height",""+height)
26
- PropertiesTools::setProperty(output,"baseline",""+baseline)
27
- r = ""
28
- else
29
- r = (((("&cw="+width)+"&ch=")+height)+"&cb=")+baseline
30
- end
31
- return r
32
42
  end
33
- end
34
43
  end
@@ -1,253 +1,285 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
- require('com/wiris/plugin/api/PluginBuilder.rb')
5
- require('com/wiris/plugin/impl/FolderTreeStorageAndCache.rb')
6
- require('com/wiris/plugin/impl/TestImpl.rb')
7
- require('com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb')
8
- require('com/wiris/plugin/impl/ImageFormatControllerPng.rb')
9
- require('com/wiris/plugin/impl/CleanCacheImpl.rb')
10
- require('com/wiris/plugin/impl/EditorImpl.rb')
11
- require('com/wiris/plugin/impl/RenderImpl.rb')
12
- require('com/wiris/plugin/impl/DefaultConfigurationUpdater.rb')
13
- require('com/wiris/plugin/impl/FileStorageAndCache.rb')
14
- require('com/wiris/plugin/impl/ImageFormatControllerSvg.rb')
15
- require('com/wiris/plugin/impl/CasImpl.rb')
16
- require('com/wiris/plugin/impl/ConfigurationImpl.rb')
17
- require('com/wiris/plugin/impl/TextServiceImpl.rb')
18
- require('com/wiris/plugin/impl/GenericParamsProviderImpl.rb')
19
- require('com/wiris/plugin/api/PluginBuilder.rb')
20
- class PluginBuilderImpl < PluginBuilder
21
- include Wiris
3
+ require('com/wiris/plugin/api/PluginBuilder.rb')
4
+ require('com/wiris/plugin/api/ConfigurationKeys.rb')
5
+ require('com/wiris/plugin/impl/FolderTreeStorageAndCache.rb')
6
+ require('com/wiris/plugin/impl/TestImpl.rb')
7
+ require('com/wiris/plugin/impl/EditorImpl.rb')
8
+ require('com/wiris/plugin/impl/CleanCacheImpl.rb')
9
+ require('com/wiris/plugin/impl/FileStorageAndCache.rb')
10
+ require('com/wiris/plugin/impl/ImageFormatControllerSvg.rb')
11
+ require('com/wiris/plugin/impl/ConfigurationImpl.rb')
12
+ require('com/wiris/plugin/impl/GenericParamsProviderImpl.rb')
13
+ require('com/wiris/plugin/impl/CacheFormulaImpl.rb')
14
+ require('com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb')
15
+ require('com/wiris/plugin/impl/ImageFormatControllerPng.rb')
16
+ require('com/wiris/plugin/impl/RenderImpl.rb')
17
+ require('com/wiris/plugin/impl/DefaultConfigurationUpdater.rb')
18
+ require('com/wiris/plugin/impl/CasImpl.rb')
19
+ require('com/wiris/plugin/impl/CacheImpl.rb')
20
+ require('com/wiris/plugin/impl/TextServiceImpl.rb')
21
+ require('com/wiris/plugin/api/PluginBuilder.rb')
22
+ class PluginBuilderImpl < PluginBuilder
23
+ include Wiris
22
24
 
23
- attr_accessor :configuration
24
- attr_accessor :store
25
- attr_accessor :updaterChain
26
- attr_accessor :storageAndCacheInitObject
27
- attr_accessor :customParamsProvider
28
- def initialize()
29
- super()
30
- @updaterChain = Array.new()
31
- @updaterChain::push(DefaultConfigurationUpdater.new())
32
- ci = ConfigurationImpl.new()
33
- @configuration = ci
34
- ci::setPluginBuilderImpl(self)
35
- end
36
- def addConfigurationUpdater(conf)
37
- @updaterChain::push(conf)
38
- end
39
- def setCustomParamsProvider(provider)
40
- @customParamsProvider = provider
41
- end
42
- def getCustomParamsProvider()
43
- return @customParamsProvider
44
- end
45
- def setStorageAndCache(store)
46
- @store = store
47
- end
48
- def newRender()
49
- if (Type::resolveClass("com.wiris.editor.services.PublicServices")!=nil)&&isEditorLicensed()
50
- return RenderImplIntegratedServices.new(self)
51
- end
52
- return RenderImpl.new(self)
53
- end
54
- def newAsyncRender()
55
- return AsyncRenderImpl.new(self)
56
- end
57
- def newTest()
58
- return TestImpl.new(self)
59
- end
60
- def newEditor()
61
- return EditorImpl.new(self)
62
- end
63
- def newCas()
64
- return CasImpl.new(self)
65
- end
66
- def newTextService()
67
- if (Type::resolveClass("com.wiris.editor.services.PublicServices")!=nil)&&isEditorLicensed()
68
- return TextServiceImplIntegratedServices.new(self)
69
- end
70
- return TextServiceImpl.new(self)
71
- end
72
- def newAsyncTextService()
73
- return AsyncTextServiceImpl.new(self)
74
- end
75
- def getConfiguration()
76
- return @configuration
77
- end
78
- def getStorageAndCache()
79
- if @store==nil
80
- className = @configuration::getProperty(ConfigurationKeys::STORAGE_CLASS,nil)
81
- if (className==nil)||(className=="FolderTreeStorageAndCache")
82
- @store = FolderTreeStorageAndCache.new()
83
- else
84
- if (className=="FileStorageAndCache")
85
- @store = FileStorageAndCache.new()
86
- else
87
- cls = Type::resolveClass(className)
88
- if cls==nil
89
- raise Exception,("Class "+className)+" not found."
90
- end
91
- @store = (Type::createInstance(cls,Array.new()))
92
- if @store==nil
93
- raise Exception,("Instance from "+cls.to_s)+" cannot be created."
94
- end
95
- end
96
- end
97
- initialize_(@store,@configuration::getFullConfiguration())
98
- end
99
- return @store
100
- end
101
- def initialize_(sac,conf)
102
- sac::init(@storageAndCacheInitObject,conf)
103
- end
104
- def getConfigurationUpdaterChain()
105
- return @updaterChain
106
- end
107
- def setStorageAndCacheInitObject(obj)
108
- @storageAndCacheInitObject = obj
109
- end
110
- def newCleanCache()
111
- return CleanCacheImpl.new(self)
112
- end
113
- def newResourceLoader()
114
- return ServiceResourceLoaderImpl.new()
115
- end
116
- def getImageServiceURL(service,stats)
117
- config = getConfiguration()
118
- if Type::resolveClass("com.wiris.editor.services.PublicServices")!=nil
119
- if (config::getProperty(ConfigurationKeys::SERVICE_HOST,nil)=="www.wiris.net")
120
- return getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/")+"/editor/editor"
121
- end
122
- end
123
- protocol = config::getProperty(ConfigurationKeys::SERVICE_PROTOCOL,nil)
124
- port = config::getProperty(ConfigurationKeys::SERVICE_PORT,nil)
125
- url = config::getProperty(ConfigurationKeys::INTEGRATION_PATH,nil)
126
- if (protocol==nil)&&(url!=nil)
127
- if StringTools::startsWith(url,"https")
128
- protocol = "https"
129
- end
130
- end
131
- if protocol==nil
132
- protocol = "http"
133
- end
134
- if port!=nil
135
- if (protocol=="http")
136
- if !(port=="80")
137
- port = ":"+port
138
- else
139
- port = ""
140
- end
141
- end
142
- if (protocol=="https")
143
- if !(port=="443")
144
- port = ":"+port
145
- else
146
- port = ""
147
- end
148
- end
149
- else
150
- port = ""
151
- end
152
- domain = config::getProperty(ConfigurationKeys::SERVICE_HOST,nil)
153
- path = config::getProperty(ConfigurationKeys::SERVICE_PATH,nil)
154
- if service!=nil
155
- _end = path::lastIndexOf("/")
156
- if _end==-1
157
- path = service
158
- else
159
- path = (Std::substr(path,0,_end).to_s+"/")+service
160
- end
161
- end
162
- if stats
163
- path = addStats(path)
164
- end
165
- return (((protocol+"://")+domain)+port)+path
166
- end
167
- def addProxy(h)
168
- conf = getConfiguration()
169
- proxyEnabled = conf::getProperty(ConfigurationKeys::HTTPPROXY,"false")
170
- if (proxyEnabled=="true")
171
- host = conf::getProperty(ConfigurationKeys::HTTPPROXY_HOST,nil)
172
- port = Std::parseInt(conf::getProperty(ConfigurationKeys::HTTPPROXY_PORT,"80"))
173
- if (host!=nil)&&(host::length()>0)
174
- user = conf::getProperty(ConfigurationKeys::HTTPPROXY_USER,nil)
175
- pass = conf::getProperty(ConfigurationKeys::HTTPPROXY_PASS,nil)
176
- h::setProxy(HttpProxy::newHttpProxy(host,port,user,pass))
177
- end
178
- end
179
- end
180
- def addReferer(h)
181
- conf = getConfiguration()
182
- if (conf::getProperty("wirisexternalplugin","false")=="true")
183
- h::setHeader("Referer",conf::getProperty(ConfigurationKeys::EXTERNAL_REFERER,"external referer not found"))
184
- else
185
- h::setHeader("Referer",conf::getProperty(ConfigurationKeys::REFERER,""))
186
- end
187
- end
188
- def addCorsHeaders(response,origin)
189
- conf = getConfiguration()
190
- if (conf::getProperty("wiriscorsenabled","false")=="true")
191
- confDir = conf::getProperty(ConfigurationKeys::CONFIGURATION_PATH,nil)
192
- corsConfFile = confDir+"/corsservers.ini"
193
- s = Storage::newStorage(corsConfFile)
194
- if s::exists()
195
- dir = s::read()
196
- allowedHosts = Std::split(dir,"\n")
197
- if allowedHosts::contains_(origin)
198
- response::setHeader("Access-Control-Allow-Origin",origin)
199
- end
200
- else
201
- response::setHeader("Access-Control-Allow-Origin","*")
202
- end
203
- end
204
- end
205
- def addStats(url)
206
- saveMode = getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
207
- externalPlugin = getConfiguration()::getProperty(ConfigurationKeys::EXTERNAL_PLUGIN,"false")
208
- begin
209
- version = Storage::newResourceStorage("VERSION")::read()
210
- end
211
- begin
212
- tech = StringTools::replace(Storage::newResourceStorage("tech.txt")::read(),"\n","")
213
- tech = StringTools::replace(tech,"\r","")
214
- end
215
- if url::indexOf("?")!=-1
216
- return (((((((url+"&stats-mode=")+saveMode)+"&stats-version=")+version)+"&stats-scriptlang=")+tech)+"&external=")+externalPlugin
217
- else
218
- return (((((((url+"?stats-mode=")+saveMode)+"&stats-version=")+version)+"&stats-scriptlang=")+tech)+"&external=")+externalPlugin
219
- end
220
- end
221
- def isEditorLicensed()
222
- licenseClass = Type::resolveClass("com.wiris.util.sys.License")
223
- if licenseClass!=nil
224
- init = Reflect::field(licenseClass,"init")
225
- initMethodParams = Array.new()
226
- initMethodParams::push(getConfiguration()::getProperty(ConfigurationKeys::EDITOR_KEY,""))
227
- initMethodParams::push("")
228
- initMethodParams::push([4, 5, 9, 10])
229
- Reflect::callMethod(licenseClass,init,initMethodParams)
230
- isLicensedMethod = Reflect::field(licenseClass,"isLicensed")
231
- isLicensedObject = Reflect::callMethod(licenseClass,isLicensedMethod,nil)
232
- if Type::getClassName(Type::getClass(isLicensedObject))::indexOf("Boolean")!=-1
233
- isLicensed = Boolean::valueOf(isLicensedObject::toString())
234
- else
235
- isLicensed = (isLicensedObject)
236
- end
237
- return (isLicensed)
238
- end
239
- return false
240
- end
241
- def getImageFormatController()
242
- if (@configuration::getProperty(ConfigurationKeys::IMAGE_FORMAT,"png")=="svg")
243
- imageFormatController = ImageFormatControllerSvg.new()
244
- else
245
- imageFormatController = ImageFormatControllerPng.new()
246
- end
247
- return imageFormatController
248
- end
249
- def newGenericParamsProvider(properties)
250
- return GenericParamsProviderImpl.new(properties)
25
+ attr_accessor :configuration
26
+ attr_accessor :store
27
+ attr_accessor :updaterChain
28
+ attr_accessor :storageAndCacheInitObject
29
+ @storageAndCacheCacheObject;
30
+ attr_accessor :storageAndCacheCacheObject
31
+ @storageAndCacheCacheFormulaObject;
32
+ attr_accessor :storageAndCacheCacheFormulaObject
33
+ @customParamsProvider;
34
+ attr_accessor :customParamsProvider
35
+ @accessProvider;
36
+ attr_accessor :accessProvider
37
+ def initialize()
38
+ super()
39
+ @updaterChain = Array.new()
40
+ @updaterChain::push(DefaultConfigurationUpdater.new())
41
+ ci = ConfigurationImpl.new()
42
+ @configuration = ci
43
+ ci::setPluginBuilderImpl(self)
44
+ end
45
+ def addConfigurationUpdater(conf)
46
+ @updaterChain::push(conf)
47
+ end
48
+ def setCustomParamsProvider(provider)
49
+ self.customParamsProvider = provider
50
+ end
51
+ def getCustomParamsProvider()
52
+ return self.customParamsProvider
53
+ end
54
+ def setAccessProvider(provider)
55
+ self.accessProvider = provider
56
+ end
57
+ def getAccessProvider()
58
+ return self.accessProvider
59
+ end
60
+ def setStorageAndCache(store)
61
+ self.store = store
62
+ end
63
+ def newRender()
64
+ if (Type::resolveClass("com.wiris.editor.services.PublicServices") != nil) && isEditorLicensed()
65
+ return RenderImplIntegratedServices.new(self)
66
+ end
67
+ return RenderImpl.new(self)
68
+ end
69
+ def newAsyncRender()
70
+ return AsyncRenderImpl.new(self)
71
+ end
72
+ def newTest()
73
+ return TestImpl.new(self)
74
+ end
75
+ def newEditor()
76
+ return EditorImpl.new(self)
77
+ end
78
+ def newCas()
79
+ return CasImpl.new(self)
80
+ end
81
+ def newTextService()
82
+ if (Type::resolveClass("com.wiris.editor.services.PublicServices") != nil) && isEditorLicensed()
83
+ return TextServiceImplIntegratedServices.new(self)
84
+ end
85
+ return TextServiceImpl.new(self)
86
+ end
87
+ def newAsyncTextService()
88
+ return AsyncTextServiceImpl.new(self)
89
+ end
90
+ def getConfiguration()
91
+ return @configuration
92
+ end
93
+ def getStorageAndCache()
94
+ if @store == nil
95
+ className = @configuration::getProperty(ConfigurationKeys::STORAGE_CLASS,nil)
96
+ if (className == nil) || (className == "FolderTreeStorageAndCache")
97
+ @store = FolderTreeStorageAndCache.new()
98
+ else
99
+ if (className == "FileStorageAndCache")
100
+ @store = FileStorageAndCache.new()
101
+ else
102
+ cls = Type::resolveClass(className)
103
+ if cls == nil
104
+ raise Exception,("Class " + className) + " not found."
105
+ end
106
+ @store = (Type::createInstance(cls,Array.new()))
107
+ if @store == nil
108
+ raise Exception,("Instance from " + cls.to_s) + " cannot be created."
109
+ end
110
+ end
111
+ end
112
+ initialize_(@store,@configuration::getFullConfiguration())
113
+ end
114
+ return @store
115
+ end
116
+ def initialize_(sac, conf)
117
+ if @storageAndCacheCacheObject == nil
118
+ @storageAndCacheCacheObject = CacheImpl.new(conf)
119
+ end
120
+ if @storageAndCacheCacheFormulaObject == nil
121
+ @storageAndCacheCacheFormulaObject = CacheFormulaImpl.new(conf)
122
+ end
123
+ sac::init(@storageAndCacheInitObject,conf,@storageAndCacheCacheObject,@storageAndCacheCacheFormulaObject)
124
+ end
125
+ def getConfigurationUpdaterChain()
126
+ return @updaterChain
127
+ end
128
+ def setStorageAndCacheInitObject(obj)
129
+ @storageAndCacheInitObject = obj
130
+ end
131
+ def setStorageAndCacheCacheObject(cache)
132
+ @storageAndCacheCacheObject = cache
133
+ end
134
+ def setStorageAndCacheCacheFormulaObject(cacheFormula)
135
+ @storageAndCacheCacheFormulaObject = cacheFormula
136
+ end
137
+ def newCleanCache()
138
+ return CleanCacheImpl.new(self)
139
+ end
140
+ def newResourceLoader()
141
+ return ServiceResourceLoaderImpl.new()
142
+ end
143
+ def getImageServiceURL(service, stats)
144
+ config = getConfiguration()
145
+ if Type::resolveClass("com.wiris.editor.services.PublicServices") != nil
146
+ if (config::getProperty(ConfigurationKeys::SERVICE_HOST,nil) == "www.wiris.net")
147
+ return self.getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/") + "/editor/editor"
148
+ end
149
+ end
150
+ protocol = config::getProperty(ConfigurationKeys::SERVICE_PROTOCOL,nil)
151
+ port = config::getProperty(ConfigurationKeys::SERVICE_PORT,nil)
152
+ url = config::getProperty(ConfigurationKeys::INTEGRATION_PATH,nil)
153
+ if (protocol == nil) && (url != nil)
154
+ if StringTools::startsWith(url,"https")
155
+ protocol = "https"
156
+ end
157
+ end
158
+ if protocol == nil
159
+ protocol = "http"
160
+ end
161
+ if port != nil
162
+ if (protocol == "http")
163
+ if !(port == "80")
164
+ port = ":" + port
165
+ else
166
+ port = ""
167
+ end
168
+ end
169
+ if (protocol == "https")
170
+ if !(port == "443")
171
+ port = ":" + port
172
+ else
173
+ port = ""
174
+ end
175
+ end
176
+ else
177
+ port = ""
178
+ end
179
+ domain = config::getProperty(ConfigurationKeys::SERVICE_HOST,nil)
180
+ path = config::getProperty(ConfigurationKeys::SERVICE_PATH,nil)
181
+ if service != nil
182
+ _end = path::lastIndexOf("/")
183
+ if _end == -1
184
+ path = service
185
+ else
186
+ path = (Std::substr(path,0,_end).to_s + "/") + service
187
+ end
188
+ end
189
+ if stats
190
+ path = addStats(path)
191
+ end
192
+ return (((protocol + "://") + domain) + port) + path
193
+ end
194
+ def addProxy(h)
195
+ conf = self.getConfiguration()
196
+ proxyEnabled = conf::getProperty(ConfigurationKeys::HTTPPROXY,"false")
197
+ if (proxyEnabled == "true")
198
+ host = conf::getProperty(ConfigurationKeys::HTTPPROXY_HOST,nil)
199
+ port = Std::parseInt(conf::getProperty(ConfigurationKeys::HTTPPROXY_PORT,"80"))
200
+ if (host != nil) && (host::length() > 0)
201
+ user = conf::getProperty(ConfigurationKeys::HTTPPROXY_USER,nil)
202
+ pass = conf::getProperty(ConfigurationKeys::HTTPPROXY_PASS,nil)
203
+ h::setProxy(HttpProxy::newHttpProxy(host,port,user,pass))
204
+ end
205
+ end
206
+ end
207
+ def addReferer(h)
208
+ conf = self.getConfiguration()
209
+ if (conf::getProperty("wirisexternalplugin","false") == "true")
210
+ h::setHeader("Referer",conf::getProperty(ConfigurationKeys::EXTERNAL_REFERER,"external referer not found"))
211
+ else
212
+ h::setHeader("Referer",conf::getProperty(ConfigurationKeys::REFERER,""))
213
+ end
214
+ end
215
+ def addCorsHeaders(response, origin)
216
+ conf = self.getConfiguration()
217
+ if (conf::getProperty("wiriscorsenabled","false") == "true")
218
+ confDir = conf::getProperty(ConfigurationKeys::CONFIGURATION_PATH,nil)
219
+ corsConfFile = confDir + "/corsservers.ini"
220
+ s = Storage::newStorage(corsConfFile)
221
+ if s::exists()
222
+ dir = s::read()
223
+ allowedHosts = Std::split(dir,"\n")
224
+ if allowedHosts::contains_(origin)
225
+ response::setHeader("Access-Control-Allow-Origin",origin)
226
+ end
227
+ else
228
+ response::setHeader("Access-Control-Allow-Origin","*")
229
+ end
230
+ end
231
+ end
232
+ def addStats(url)
233
+ saveMode = self.getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml")
234
+ externalPlugin = self.getConfiguration()::getProperty(ConfigurationKeys::EXTERNAL_PLUGIN,"false")
235
+ begin
236
+ version = Storage::newResourceStorage("VERSION")::read()
237
+ end
238
+ begin
239
+ tech = StringTools::replace(Storage::newResourceStorage("tech.txt")::read(),"\n","")
240
+ tech = StringTools::replace(tech,"\r","")
241
+ end
242
+ if url::indexOf("?") != -1
243
+ return (((((((url + "&stats-mode=") + saveMode) + "&stats-version=") + version) + "&stats-scriptlang=") + tech) + "&external=") + externalPlugin
244
+ else
245
+ return (((((((url + "?stats-mode=") + saveMode) + "&stats-version=") + version) + "&stats-scriptlang=") + tech) + "&external=") + externalPlugin
246
+ end
247
+ end
248
+ def isEditorLicensed()
249
+ licenseClass = Type::resolveClass("com.wiris.util.sys.License")
250
+ if licenseClass != nil
251
+ init = Reflect::field(licenseClass,"init")
252
+ initMethodParams = Array.new()
253
+ initMethodParams::push(self.getConfiguration()::getProperty(ConfigurationKeys::EDITOR_KEY,""))
254
+ initMethodParams::push("")
255
+ initMethodParams::push([4, 5, 9, 10])
256
+ Reflect::callMethod(licenseClass,init,initMethodParams)
257
+ isLicensedMethod = Reflect::field(licenseClass,"isLicensed")
258
+ isLicensedObject = Reflect::callMethod(licenseClass,isLicensedMethod,nil)
259
+ if Type::getClassName(Type::getClass(isLicensedObject))::indexOf("Boolean") != -1
260
+ isLicensed = Boolean::valueOf(isLicensedObject::toString())
261
+ else
262
+ isLicensed = (isLicensedObject)
263
+ end
264
+ return (isLicensed)
265
+ end
266
+ return false
267
+ end
268
+ def getImageFormatController()
269
+ if (@configuration::getProperty(ConfigurationKeys::IMAGE_FORMAT,"png") == "svg")
270
+ imageFormatController = ImageFormatControllerSvg.new()
271
+ else
272
+ imageFormatController = ImageFormatControllerPng.new()
273
+ end
274
+ return imageFormatController
275
+ end
276
+ def newGenericParamsProvider(properties)
277
+ return GenericParamsProviderImpl.new(properties)
278
+ end
279
+
280
+ @storageAndCacheCacheObject = nil
281
+ @storageAndCacheCacheFormulaObject = nil
282
+ @customParamsProvider = nil
283
+ @accessProvider = nil
251
284
  end
252
- end
253
285
  end