Use of pattern matching generate JavaScript languagae Service has been disabled - javascript

If use pattern matching for checking type of variable then it raise The JavaScript language service has been disabled
var exception = ex as XYZException; //it has no issue
but if :
if (ex is XYZException exception) // it generate error of JaVascript Service Disabled
Please see screenshot :
UPDATE : Fixed by updating Visual Studio.

Seems you need to update the visual studio.
https://learn.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes#knownissues

Related

Error Updating a Chromebook's Organizational Unit with Google Script

I have been experiencing an issue recently with a Google Script code I wrote to update a few Chromebooks' organization units.
Here is a portion of the code that I am running:
let admin = AdminDirectory.Chromeosdevices.get("my_customer", active_deviceid[serial_index])
admin.annotatedAssetId = device_ID.toString()
admin.annotatedLocation = name
admin.orgUnitPath = _location_(device_ID).toString().toUpperCase()
AdminDirectory.Chromeosdevices.update(admin, 'my_customer', active_deviceid[serial_index])
Once the script executes I get the following error:
GoogleJsonResponseException: API call to directory.chromeosdevices.update failed with error: Invalid Input: Inconsistent Orgunit id and path in request - 11006550017573025, /1 SCHOOLS/COVID LOANERS
What is strange is that if I comment or remove "admin.orgUnitPath = location(device_ID).toString().toUpperCase()" the script will run fine. It seems the orgUnitPath is causing this error.
I tried the following:
Removing the first slash "/"
Do only 1 Chromebook
Remove and reapply the AdminDirectory
Run previous scripts that were used to change the OrgUnitPath
Added quotes on the beginning and end of the OrgUnitPath
Converted the path to String with toString()
used Stript() function to eliminate any empty spaces
All the above attempts failed to fix this issue. I will also include an image of an error I am getting from a previous script I made that used to work about a year ago that also changes the OrgUnitPath.
Does anyone know how to fix this issue?
Thanks in advance.
For some reason there has been a change that now requires the orgUnitId in addition to the orgUnitPath.
So before you run AdminDirectory.Chromeosdevices.update you need to obtain the orgUnitId and update that property
var orgUnitPathStr = "/Tech Dept/Storage"
admin.orgUnitId = AdminDirectory.Orgunits.get("my_customer",orgUnitPathStr.substring(1)).orgUnitId;
//substring(1) above removes the first slash in the orgUnitPath, which is required for this method
Credit for hints:
https://github.com/taers232c/GAMADV-XTD3/issues/225

Can't evaluate Javascript based policy with Keycloak

I'm trying to test the Javascript Based policies defined in this project https://github.com/mposolda/devconf2019-authz/blob/master/cars-realm.json#L191, but everytime I try to access a protected ressource I got the following error in keycloak logs :
Caused by: java.lang.IllegalStateException: Could not find ScriptEngine for script: Script{id='null', realmId='cars', name='Only From a Specific Client Address', type='text/javascript', code='var contextAttributes = $evaluation.getContext().getAttributes();
if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
$evaluation.grant();
}', description='Defines that only clients from a specific address can do something'}
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.createPreparedScriptEngine(DefaultScriptingProvider.java:106)
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.prepareEvaluatableScript(DefaultScriptingProvider.java:72)
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.prepareEvaluatableScript(DefaultScriptingProvider.java:33)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.lambda$getEvaluatableScript$0(JSPolicyProviderFactory.java:109)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.ScriptCache.lambda$computeIfAbsent$0(ScriptCache.java:80)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1224)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.ScriptCache.computeIfAbsent(ScriptCache.java:80)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.getEvaluatableScript(JSPolicyProviderFactory.java:106)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProvider.evaluate(JSPolicyProvider.java:46)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.aggregated.AggregatePolicyProvider.evaluate(AggregatePolicyProvider.java:66)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.aggregated.AggregatePolicyProvider.evaluate(AggregatePolicyProvider.java:66)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.permission.AbstractPermissionProvider.evaluate(AbstractPermissionProvider.java:56)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.permission.ScopePolicyProvider.evaluate(ScopePolicyProvider.java:52)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.policy.evaluation.DefaultPolicyEvaluator.lambda$createPolicyEvaluator$0(DefaultPolicyEvaluator.java:116)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.cacheQuery(StoreFactoryCacheSession.java:1098)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.cacheQuery(StoreFactoryCacheSession.java:1073)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.findByScopeIds(StoreFactoryCacheSession.java:1045)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.AuthorizationProvider$3.findByScopeIds(AuthorizationProvider.java:430)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.policy.evaluation.DefaultPolicyEvaluator.evaluate(DefaultPolicyEvaluator.java:86)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.evaluator.UnboundedPermissionEvaluator.lambda$evaluate$0(UnboundedPermissionEvaluator.java:49)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.Permissions.lambda$all$1(Permissions.java:87)
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache$1.accept(StoreFactoryCacheSession.java:678)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache$1.accept(StoreFactoryCacheSession.java:673)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.utils.ClosingStream.forEach(ClosingStream.java:128)
at org.keycloak.keycloak-model-jpa#15.0.2//org.keycloak.authorization.jpa.store.JPAResourceStore.findByOwnerFilter(JPAResourceStore.java:136)
at org.keycloak.keycloak-model-jpa#15.0.2//org.keycloak.authorization.jpa.store.JPAResourceStore.findByOwner(JPAResourceStore.java:101)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.lambda$findByOwner$7(StoreFactoryCacheSession.java:673)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.cacheQuery(StoreFactoryCacheSession.java:845)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.cacheQuery(StoreFactoryCacheSession.java:830)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.findByOwner(StoreFactoryCacheSession.java:671)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.AuthorizationProvider$4.findByOwner(AuthorizationProvider.java:501)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.Permissions.all(Permissions.java:85)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.evaluator.UnboundedPermissionEvaluator.evaluate(UnboundedPermissionEvaluator.java:48)
Is there any further step I need to do in order to make this example work ?
Keycloak version : 15.0.2
Java version : 15
Thanks !
When we look at the first line of the log message:
Could not find ScriptEngine for script: Script{ ... type='text/javascript'... }
we see that keycloak is not able to load a javascript scripting engine.
Since Java >= 15, no javascript engine is provided with the JVM (see JEP 372). This is the reason why keycloak cannot find a javascript engine.
I see two possible solutions to the problem:
Provide a javascript engine through some 3rd party libraries (for detail see this question by Paul Taylor), or
Downgrade Java to <= 14 (not recommended).

how to use web.reg_save_param when using javascript as scripting launguage in loadrunner?

I am trying to switch to javascript for scripting in loadrunner. While this process i recorded script by changing the script language and I got a script. Now when i was trying to correlate a parameter i am getting error as described below.
Loadrunner Version : 12.63
This code snippet is copied from MF documentation made made changes according to my need: HERE
// ClientID":"f3d65s4gs6dg4df65g465fd4","
web.reg_save_param (""outFlightVal",
new String []{
"NOTFOUND=ERROR",
"LB=ClientID\":\"",
"RB=\",\"" ,
"LAST"} );
ERROR :
Action.js(142): Error: 'SyntaxError: missing ) after argument list'.
Source line: ' web.reg_save_param (""outFlightVal",'.
I even tried :
web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');
ERROR:
Action.js(149): Error: 'SyntaxError: missing ) after argument list'.
Source line: ' web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');'.
After some research I got to know that the java code given in the documentation is not for javascript. it is for java Vuser which is used by some protocol like oracle DB, JMS ..etc
and web_reg_save_param is a older version of web_reg_save_param_ex and is no longer supported when we use javascript as a scripting language. so only web.regSaveParamEx is supported and it accepts an object so
instead of :
web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');
use :
web.regSaveParamEx({paramName:"outFlightVal",lb:'ClientID":"',rb:'",'});

Alfresco Script set group as assignee

I'm using alfresco script and I'm starting a workflow using a script. I'm setting group assignee as reception:
wfparams["bpm:groupasignee"] = groups.getGroup('reception');
And starting workflow:
workflowAction.startWorkflow(package, wfparams);
Problem is showing in console:
org.springframework.extensions.webscripts.WebScriptException: 04120017 Wrapped Exception (with status template): 04120067 Failed to execute script 'Javascript Console Script': 04120066 Failed to start workflow activiti$activitiParallelGroupReview:1:20.
Cause by:
org.activiti.engine.ActivitiException: Couldn't serialize
value
'[org.alfresco.repo.security.authority.script.ScriptUser#36e9c1f8]' in
variable 'bpm_groupasignee'
How to assign a group to a workflow task?
Greetings, RafaƂ
You can not assign task to group, using script.Below is the code i have taken it from bpmn file, where activiti:candidateGroups="GROUP_GroupName" used to assign task to Group.In alfresco group are prefixed in backend as "GROUP_ ",so i think you have to assign task to "GROUP_reception".
<userTask id="PE" name="PE" activiti:candidateGroups="GROUP_PE" activiti:formKey="wf:adhocTask"></userTask>
please try using this to assign a workflow to a group
wfparams["bpm:groupAssignee"] = people.getGroup("GROUP_YOUR_GROUP_NAME");

How to use display/view only Twproject Gantt?

I am trying to using Twproject Gantt. I don't form GitHub.
But, I just want to use display/view only. I don't need add or edit or others function.
I already try to configure"canWrite":false.It does not work. How to configure view only mode in Twproject Gantt?
Configure view only mode : (i am using this settings)
First, you need to remove all save and delete button to prevent client mistaken it. (search this one for this issue) :
class="template" type="GANTBUTTONS"
then when DB load , try to set the json there like this one :
{
"tasks":[],
"selectedRow":0,
"canWrite":false, //is a must
"canWriteOnParent":false, //is a must
"roles":[], //optional
"resources":[] //optional
}
May this answer your question.
Moreover, you can browse this one Documentation
or github jQueryGantt

Categories