class WirisPlugin::PluginBuilderImpl
Attributes
accessProvider[RW]
configuration[RW]
customParamsProvider[RW]
storageAndCacheCacheFormulaObject[RW]
storageAndCacheCacheObject[RW]
storageAndCacheInitObject[RW]
store[RW]
updaterChain[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
WirisPlugin::PluginBuilder::new
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 37 def initialize() super() @updaterChain = Array.new() @updaterChain::push(DefaultConfigurationUpdater.new()) ci = ConfigurationImpl.new() @configuration = ci ci::setPluginBuilderImpl(self) end
Public Instance Methods
addConfigurationUpdater(conf)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 45 def addConfigurationUpdater(conf) @updaterChain::push(conf) end
addCorsHeaders(response, origin)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 215 def addCorsHeaders(response, origin) conf = self.getConfiguration() if (conf::getProperty("wiriscorsenabled","false") == "true") confDir = conf::getProperty(ConfigurationKeys::CONFIGURATION_PATH,nil) corsConfFile = confDir + "/corsservers.ini" s = Storage::newStorage(corsConfFile) if s::exists() dir = s::read() allowedHosts = Std::split(dir,"\n") if allowedHosts::contains_(origin) response::setHeader("Access-Control-Allow-Origin",origin) end else response::setHeader("Access-Control-Allow-Origin","*") end end end
addProxy(h)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 194 def addProxy(h) conf = self.getConfiguration() proxyEnabled = conf::getProperty(ConfigurationKeys::HTTPPROXY,"false") if (proxyEnabled == "true") host = conf::getProperty(ConfigurationKeys::HTTPPROXY_HOST,nil) port = Std::parseInt(conf::getProperty(ConfigurationKeys::HTTPPROXY_PORT,"80")) if (host != nil) && (host::length() > 0) user = conf::getProperty(ConfigurationKeys::HTTPPROXY_USER,nil) pass = conf::getProperty(ConfigurationKeys::HTTPPROXY_PASS,nil) h::setProxy(HttpProxy::newHttpProxy(host,port,user,pass)) end end end
addReferer(h)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 207 def addReferer(h) conf = self.getConfiguration() if (conf::getProperty("wirisexternalplugin","false") == "true") h::setHeader("Referer",conf::getProperty(ConfigurationKeys::EXTERNAL_REFERER,"external referer not found")) else h::setHeader("Referer",conf::getProperty(ConfigurationKeys::REFERER,"")) end end
addStats(url)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 232 def addStats(url) saveMode = self.getConfiguration()::getProperty(ConfigurationKeys::SAVE_MODE,"xml") externalPlugin = self.getConfiguration()::getProperty(ConfigurationKeys::EXTERNAL_PLUGIN,"false") begin version = Storage::newResourceStorage("VERSION")::read() end begin tech = StringTools::replace(Storage::newResourceStorage("tech.txt")::read(),"\n","") tech = StringTools::replace(tech,"\r","") end if url::indexOf("?") != -1 return (((((((url + "&stats-mode=") + saveMode) + "&stats-version=") + version) + "&stats-scriptlang=") + tech) + "&external=") + externalPlugin else return (((((((url + "?stats-mode=") + saveMode) + "&stats-version=") + version) + "&stats-scriptlang=") + tech) + "&external=") + externalPlugin end end
getAccessProvider()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 57 def getAccessProvider() return self.accessProvider end
getConfiguration()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 90 def getConfiguration() return @configuration end
getConfigurationUpdaterChain()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 125 def getConfigurationUpdaterChain() return @updaterChain end
getCustomParamsProvider()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 51 def getCustomParamsProvider() return self.customParamsProvider end
getImageFormatController()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 268 def getImageFormatController() if (@configuration::getProperty(ConfigurationKeys::IMAGE_FORMAT,"png") == "svg") imageFormatController = ImageFormatControllerSvg.new() else imageFormatController = ImageFormatControllerPng.new() end return imageFormatController end
getImageServiceURL(service, stats)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 143 def getImageServiceURL(service, stats) config = getConfiguration() if Type::resolveClass("com.wiris.editor.services.PublicServices") != nil if (config::getProperty(ConfigurationKeys::SERVICE_HOST,nil) == "www.wiris.net") return self.getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/") + "/editor/editor" end end protocol = config::getProperty(ConfigurationKeys::SERVICE_PROTOCOL,nil) port = config::getProperty(ConfigurationKeys::SERVICE_PORT,nil) url = config::getProperty(ConfigurationKeys::INTEGRATION_PATH,nil) if (protocol == nil) && (url != nil) if StringTools::startsWith(url,"https") protocol = "https" end end if protocol == nil protocol = "http" end if port != nil if (protocol == "http") if !(port == "80") port = ":" + port else port = "" end end if (protocol == "https") if !(port == "443") port = ":" + port else port = "" end end else port = "" end domain = config::getProperty(ConfigurationKeys::SERVICE_HOST,nil) path = config::getProperty(ConfigurationKeys::SERVICE_PATH,nil) if service != nil _end = path::lastIndexOf("/") if _end == -1 path = service else path = (Std::substr(path,0,_end).to_s + "/") + service end end if stats path = addStats(path) end return (((protocol + "://") + domain) + port) + path end
getStorageAndCache()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 93 def getStorageAndCache() if @store == nil className = @configuration::getProperty(ConfigurationKeys::STORAGE_CLASS,nil) if (className == nil) || (className == "FolderTreeStorageAndCache") @store = FolderTreeStorageAndCache.new() else if (className == "FileStorageAndCache") @store = FileStorageAndCache.new() else cls = Type::resolveClass(className) if cls == nil raise Exception,("Class " + className) + " not found." end @store = (Type::createInstance(cls,Array.new())) if @store == nil raise Exception,("Instance from " + cls.to_s) + " cannot be created." end end end initialize_(@store,@configuration::getFullConfiguration()) end return @store end
initialize_(sac, conf)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 116 def initialize_(sac, conf) if @storageAndCacheCacheObject == nil @storageAndCacheCacheObject = CacheImpl.new(conf) end if @storageAndCacheCacheFormulaObject == nil @storageAndCacheCacheFormulaObject = CacheFormulaImpl.new(conf) end sac::init(@storageAndCacheInitObject,conf,@storageAndCacheCacheObject,@storageAndCacheCacheFormulaObject) end
isEditorLicensed()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 248 def isEditorLicensed() licenseClass = Type::resolveClass("com.wiris.util.sys.License") if licenseClass != nil init = Reflect::field(licenseClass,"init") initMethodParams = Array.new() initMethodParams::push(self.getConfiguration()::getProperty(ConfigurationKeys::EDITOR_KEY,"")) initMethodParams::push("") initMethodParams::push([4, 5, 9, 10]) Reflect::callMethod(licenseClass,init,initMethodParams) isLicensedMethod = Reflect::field(licenseClass,"isLicensed") isLicensedObject = Reflect::callMethod(licenseClass,isLicensedMethod,nil) if Type::getClassName(Type::getClass(isLicensedObject))::indexOf("Boolean") != -1 isLicensed = Boolean::valueOf(isLicensedObject::toString()) else isLicensed = (isLicensedObject) end return (isLicensed) end return false end
newAsyncRender()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 69 def newAsyncRender() return AsyncRenderImpl.new(self) end
newAsyncTextService()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 87 def newAsyncTextService() return AsyncTextServiceImpl.new(self) end
newCas()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 78 def newCas() return CasImpl.new(self) end
newCleanCache()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 137 def newCleanCache() return CleanCacheImpl.new(self) end
newEditor()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 75 def newEditor() return EditorImpl.new(self) end
newGenericParamsProvider(properties)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 276 def newGenericParamsProvider(properties) return GenericParamsProviderImpl.new(properties) end
newRender()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 63 def newRender() if (Type::resolveClass("com.wiris.editor.services.PublicServices") != nil) && isEditorLicensed() return RenderImplIntegratedServices.new(self) end return RenderImpl.new(self) end
newResourceLoader()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 140 def newResourceLoader() return ServiceResourceLoaderImpl.new() end
newTest()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 72 def newTest() return TestImpl.new(self) end
newTextService()
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 81 def newTextService() if (Type::resolveClass("com.wiris.editor.services.PublicServices") != nil) && isEditorLicensed() return TextServiceImplIntegratedServices.new(self) end return TextServiceImpl.new(self) end
setAccessProvider(provider)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 54 def setAccessProvider(provider) self.accessProvider = provider end
setCustomParamsProvider(provider)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 48 def setCustomParamsProvider(provider) self.customParamsProvider = provider end
setStorageAndCache(store)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 60 def setStorageAndCache(store) self.store = store end
setStorageAndCacheCacheFormulaObject(cacheFormula)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 134 def setStorageAndCacheCacheFormulaObject(cacheFormula) @storageAndCacheCacheFormulaObject = cacheFormula end
setStorageAndCacheCacheObject(cache)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 131 def setStorageAndCacheCacheObject(cache) @storageAndCacheCacheObject = cache end
setStorageAndCacheInitObject(obj)
click to toggle source
# File lib/com/wiris/plugin/impl/PluginBuilderImpl.rb, line 128 def setStorageAndCacheInitObject(obj) @storageAndCacheInitObject = obj end