Skip to content

Commit

Permalink
added dynamic tern creation using AlfrescoScriptAPITernGet Webscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Robert authored and AFaust committed Sep 12, 2024
1 parent d710cc1 commit aabfd34
Show file tree
Hide file tree
Showing 8 changed files with 1,593 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
global.requestbody.typeClassName=org.alfresco.util.Content
global.webscript.typeClassName=org.springframework.extensions.webscripts.Description
global.config.typeClassName=org.springframework.extensions.webscripts.ScriptConfigModel
global.url.typeClassName=org.springframework.extensions.webscripts.URLModel

# Scriptable JMX API is just too nasty
global.jmx.skip=true

type.java.lang.String.ternName=JavaString
type.java.lang.Character.ternName=JavaCharacter
type.java.lang.Number.ternName=JavaNumber
type.java.lang.Boolean.ternName=JavaBoolean
type.java.util.Date.ternName=JavaDate
type.java.util.Map.ternName=JavaMap
type.java.util.List.ternName=JavaList
type.java.util.Set.ternName=JavaSet
type.java.util.Collection.ternName=JavaCollection

# anything that isn't specified to a type better than Object or Scriptable is considered unknown
type.java.lang.Object.paramTypeTernName=?
type.org.mozilla.javascript.Scriptable.paramTypeTernName=?
type.org.mozilla.javascript.ScriptableObject.paramTypeTernName=?
type.java.lang.Object.returnTypeTernName=?
type.org.mozilla.javascript.Scriptable.returnTypeTernName=?
type.org.mozilla.javascript.ScriptableObject.returnTypeTernName=?

# all the custom native-like maps should be considered native objects by default
type.org.alfresco.repo.jscript.NativeMap.typeTernName=object
type.org.springframework.extensions.webscripts.NativeMap.typeTernName=object
type.org.alfresco.repo.jscript.ScriptableHashMap.returnTypeTernName=object
type.org.alfresco.repo.jscript.ScriptableQNameMap.returnTypeTernName=object
type.org.alfresco.repo.jscript.ScriptAction$ScriptableParameterMap.returnTypeTernName=object
type.org.springframework.extensions.webscripts.ScriptableLinkedHashMap.returnTypeTernName=object
type.org.springframework.extensions.webscripts.ScriptableWrappedMap.returnTypeTernName=object

type.java.lang.Object.class.skip=true
type.java.lang.Object.notify.skip=true
type.java.lang.Object.notifyAll.skip=true
type.java.lang.Object.wait.skip=true
type.java.lang.Object.toString.skip=true
type.java.lang.Enum.declaringClass.skip=true
type.java.util.Date.toInstant.skip=true

type.org.springframework.extensions.webscripts.WebScript.execute.skip=true
type.org.springframework.extensions.webscripts.ScriptableUtils.parseXMLNodeModel.skip=true
type.org.springframework.extensions.webscripts.AbstractBaseDescription.parse.skip=true
type.org.springframework.extensions.webscripts.AbstractBaseDescription.validateRootElement.skip=true

# in case by any chance a property / method leaks class-related types, we don't want it to pull other core Java stuff in
type.java.lang.Class.nameOnly=true
type.java.lang.ClassLoader.nameOnly=true
type.java.lang.reflect.Constructor.nameOnly=true
type.java.lang.reflect.Method.nameOnly=true
type.java.lang.reflect.Field.nameOnly=true
type.java.lang.reflect.TypeVariable.nameOnly=true
type.java.lang.annotation.Annotation.nameOnly=true

# avoid leaking all Java services and classes only transitively associated due to bad API design
type.org.alfresco.service.ServiceRegistry.nameOnly=true
type.org.activiti.engine.delegate.VariableScope.nameOnly=true

type.org.alfresco.repo.jscript.ScriptNode.properties.typeTernName=NodeProperties
type.org.alfresco.repo.jscript.Person.getImmutableProperties.in.String.out.ScriptableHashMap.typeTernName=NodeProperties
type.org.alfresco.repo.workflow.jscript.JscriptWorkflowTask.properties.typeTernName=TaskProperties
type.org.alfresco.repo.jscript.Search.queryResultSet.in.Object.out.Scriptable.typeTernName=SearchResultSetMeta

type.java.lang.String.getChars.skip=true
type.java.lang.String.getBytes.skip=true
type.java.lang.String.contentEquals.skip=true
type.java.lang.String.bytes.skip=true
type.java.lang.String.subSequence.skip=true

type.java.io.Reader.read.out.int.in.CharBuffer.skip=true

type.org.alfresco.repo.jscript.ScriptNode.newInstance.skip=true

type.org.alfresco.enterprise.repo.management.script.ScriptMBean.setMBeanServer.skip=true
type.org.alfresco.enterprise.repo.management.script.ScriptMBean.setJmxValueConversionChain.skip=true

# some methods / properties use a generic Scriptable type for representing native arrays
type.org.alfresco.repo.jscript.ScriptNode.children.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.int.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.int.int.int.String.Boolean.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.childrenByXPath.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.getChildAssocsByType.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.ScriptNode.getPropertyNames.in.boolean.out.Scriptable.typeClassName=[Ljava.lang.String;
type.org.alfresco.repo.jscript.ScriptNode.typePropertyNames.typeClassName=[Ljava.lang.String;
type.org.alfresco.repo.jscript.ScriptNode.getTypePropertyNames.in.boolean.out.Scriptable.typeClassName=[Ljava.lang.String;
type.org.alfresco.repo.jscript.Classification.getAllCategoryNodes.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.CategoryNode;
type.org.alfresco.repo.jscript.Classification.getCategoryUsage.in.String.int.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.Classification$Tag;
type.org.alfresco.repo.jscript.Classification.getRootCategories.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.CategoryNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.String.boolean.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.String.boolean.int.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.String.String.boolean.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.luceneSearch.in.String.String.String.boolean.int.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.query.in.Object.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.savedSearch.in.ScriptNode.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.savedSearch.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.selectNodes.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.selectNodes.in.String.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.xpathSearch.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.Search.xpathSearch.in.String.String.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.People.getContainerGroups.in.ScriptNode.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.People.getMembers.in.ScriptNode.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
type.org.alfresco.repo.jscript.People.getMembers.in.ScriptNode.boolean.out.Scriptable.typeClassName=[Lorg.alfresco.repo.jscript.ScriptNode;
# don't know why, but getPeople returns array of NodeRef instead of ScriptNode
type.org.alfresco.repo.jscript.People.getPeople.in.String.out.Scriptable.typeClassName=[Lorg.alfresco.service.cmr.repository.NodeRef;
type.org.alfresco.repo.jscript.People.getPeople.in.String.int.out.Scriptable.typeClassName=[Lorg.alfresco.service.cmr.repository.NodeRef;
type.org.alfresco.repo.jscript.People.getPeople.in.String.int.String.boolean.out.Scriptable.typeClassName=[Lorg.alfresco.service.cmr.repository.NodeRef;
type.org.alfresco.repo.jscript.People.getPeoplePaging.in.String.ScriptPagingDetails.String.Boolean.out.Scriptable.typeClassName=[Lorg.alfresco.service.cmr.repository.NodeRef;
type.org.alfresco.repo.workflow.jscript.WorkflowManager.assignedTasks.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowTask;
type.org.alfresco.repo.workflow.jscript.WorkflowManager.completedTasks.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowTask;
type.org.alfresco.repo.workflow.jscript.WorkflowManager.latestDefinitions.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowDefinition;
type.org.alfresco.repo.workflow.jscript.WorkflowManager.allDefinitions.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowDefinition;
type.org.alfresco.repo.workflow.jscript.WorkflowManager.getPooledTasks.out.Scriptable.in.String.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowTask;
type.org.alfresco.repo.workflow.jscript.JscriptWorkflowDefinition.activeInstances.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowInstance;
type.org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance.paths.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowPath;
type.org.alfresco.repo.workflow.jscript.JscriptWorkflowPath.tasks.typeClassName=[Lorg.alfresco.repo.workflow.jscript.JscriptWorkflowTask;

# some methods expect native-like objects
# childFileFolders supports JavaString, native String and native array of native String - we opt for the latter for documentation
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.out.Scriptable.arg2.typeTernName=[string]
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.int.out.Scriptable.arg2.typeTernName=[string]
type.org.alfresco.repo.jscript.ScriptNode.childFileFolders.in.boolean.boolean.Object.int.int.int.String.Boolean.String.out.Scriptable.arg2.typeTernName=[string]

type.org.springframework.extensions.webscripts.ConfigModel.script.typeClassName=java.lang.String

type.org.springframework.extensions.webscripts.ScriptMessage.get.in.String.Scriptable.out.String.arg1.typeClassName=[Ljava.lang.String;
type.org.springframework.extensions.webscripts.ScriptMessage.get.in.String.Scriptable.out.String.arg1.typeTernName=[string]

# default doc without I18n
type.java.lang.String.ternDoc=Java representation of a string value not wrapped into a native Rhino / JS string
type.java.lang.Character.ternDoc=Java representation of a single-character value not wrapped into a native Rhino / JS string
type.java.lang.Number.ternDoc=Java representation of a numeric value not wrapped into a native Rhino / JS number
type.java.lang.Boolean.ternDoc=Java representation of a boolean value not wrapped into a native Rhino / JS boolean
type.java.util.Date.ternDoc=Java representation of a Date value not wrapped into a native Rhino / JS Date
type.java.util.Map.ternDoc=A generic Java map structure without any scripting support
type.java.util.List.ternDoc=A generic Java list structure without any scripting support
type.java.util.Set.ternDoc=A generic Java set structure without any scripting support
type.java.util.Collection.ternDoc=A generic Java collection structure without any scripting support
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,27 @@
<property name="printOutputCache" ref="jsConsoleOutput" />
<property name="resultCache" ref="jsConsoleResult" />
</bean>

<bean id="webscript.org.orderofthebee.support-tools.jsconsole.tern.alfresco-script-api.get" class="org.orderofthebee.addons.support.tools.repo.jsconsole.AlfrescoScriptAPITernGet" parent="webscript">
<property name="namespaceService" ref="NamespaceService" />
<property name="dictionaryService" ref="DictionaryService" />
<property name="scriptService" ref="ScriptService" />
<property name="personService" ref="PersonService" />
<property name="serviceRegistry" ref="ServiceRegistry" />
<property name="scriptProcessor" ref="javaScriptProcessor" />
<property name="properties">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath*:alfresco/module/*/jsconsole-tern.properties</value>
<value>classpath*:alfresco/extension/jsconsole-tern.properties</value>
</list>
</property>
<property name="propertiesPersister">
<bean class="org.alfresco.config.AlfrescoPropertiesPersister"/>
</property>
</bean>
</property>
</bean>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<webscript>
<shortname>JavaScript Console - Tern Type Definitions for Alfresco Script API</shortname>
<url>/ootbee/jsconsole/tern-definitions/alfresco-script-api</url>
<format default="json" />
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
<family>OOTBee Support Tools</family>
</webscript>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (C) 2016 - 2022 Order of the Bee
*
* This file is part of OOTBee Support Tools
*
* OOTBee Support Tools is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OOTBee Support Tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OOTBee Support Tools. If not, see
* <http://www.gnu.org/licenses/>.
*
*/

// NO-OP - only here so Java web script is able to resolve a ScriptDetails
Loading

0 comments on commit aabfd34

Please sign in to comment.