I'm using Alfresco Share 4.2c and association.ftl to display associations and to allow objects in the repository to be picked. I run into problem to display metadata for user who doesn't have permission to see associated object.
I got an error:
Template processing error:
"get(properties) failed on instance of org.alfresco.repo.template.TemplateNode" get(properties) failed on instance of org.alfresco.repo.template.TemplateNode.
The problematic instruction:----------
==> ${row.item.properties.name!""} escaped ${jsonUtils.encodeJSONString(row.item.properties.name!"")} [on line 36, column 42 in org/alfresco/repository/forms/pickerresults.lib.ftl]
in user-directive pickerResultsLib.pickerResultsJSON [on line 2, column 1 in org/alfresco/repository/forms/pickeritems.post.json.ftl]
and AccessDeniedException.
Any help or advice for this problem is appreciated.
I would also like to have a label on the document details page with text "Access denied".
Maybe I have to create my custom association.ftl?
Thanks in advance!
copy /alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl to the extension folder and change the following loop
<#list results as row>
{
"type": "${row.item.typeShort}",
"parentType": "${row.item.parentTypeShort!""}",
"isContainer": ${row.item.isContainer?string},
"name": "${row.item.properties.name!""}",
"title": "${row.item.properties.title!""}",
"description": "${row.item.properties.description!""}",
<#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
<#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
<#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
"displayPath": "${row.item.displayPath!""}",
"nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
"selectable" : ${row.selectable?string}</#if>
}<#if row_has_next>,</#if>
</#list>
Encapsulate the inside with an extra if row.item.hasPermission("Read")
Something like this:
<#list results as row>
<#if row.item.hasPermission("Read")>
{
"type": "${row.item.typeShort}",
"parentType": "${row.item.parentTypeShort!""}",
"isContainer": ${row.item.isContainer?string},
"name": "${row.item.properties.name!""}",
"title": "${row.item.properties.title!""}",
"description": "${row.item.properties.description!""}",
<#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
<#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
<#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
"displayPath": "${row.item.displayPath!""}",
"nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
"selectable" : ${row.selectable?string}</#if>
}<#if row_has_next>,</#if>
</#if>
</#list>
Related
I am new to jq and can't seem to quite get the syntax right for what I want to do. I am executing a command and piping its JSON output into jq. The structure looks like this:
{
"timestamp": 1658186185,
"nodes": {
"x3006c0s13b1n0": {
"Mom": "x3006c0s13b1n0.hsn.cm",
"Port": 15002,
"state": "free",
"pcpus": 64,
"resources_available": {
"arch": "linux",
"gputype": "A100",
"host": "x3006c0s13b1n0",
"mem": "527672488kb",
"ncpus": 64,
"ngpus": 4,
"system": "polaris",
"tier0": "x3006-g1",
"tier1": "g1",
"vnode": "x3006c0s13b1n0"
},
"resources_assigned": {},
"comment": "CHC- Offlined due to node health check failure",
"resv_enable": "True",
"sharing": "default_shared",
"license": "l",
"last_state_change_time": 1658175652,
"last_used_time": 1658175652
},
And so on with a record for each node. In psuedocode, what I want to do is this:
if state is not free then display nodename : {comment = "Why is the node down"}
The nodename is the key, but could be extracted from a field inside the record. However, for future reference, I would like to understand how to get the key. I figured out (I think) that you can't use == on strings, but instead have to use the regex functions.
This gives me the if state is not free part:
<stdin> | jq '.nodes[] | .state | test("free") | not'
This gives me an object with the Mom (which includes the key) and the comment:
jq '.nodes[] | {Mom: .Mom, comment: .comment}'
The question is how do I put all that together? And as for the keys, this gives me a list of the keys: jq '.nodes | keys' but that uses the non-array version of nodes.
One way without touching the keys would be to only select those array items that match the condition, and map the remaining items' value to the comment itself using map_values:
jq '.nodes | map_values(select(.state != "free").comment)'
{
"x3006c0s13b1n0": "CHC- Offlined due to node health check failure"
}
Keeping the whole comments object, which is closer to your desired output, would be similar:
jq '.nodes | map_values(select(.state != "free") | {comment})'
{
"x3006c0s13b1n0": {
"comment": "CHC- Offlined due to node health check failure"
}
}
Accessing the keys directly is still possible though. You may want to have a look at keys, keys_unsorted or to_entries.
Is there an easy way to convert Openstack show command outputs into openstack commands ?
The goal is to rebuild an openstack environment after a complete wipe.
(for example: openstack network show myNet > out.txt,
then somehow generate the Openstack CLI command with appropriate fields to re-create this same exact network, based on out.txt ?)
Thanks!
You can write the output of the show commands as json formated string into a file, so you can easily read the information of the output with python-script to create and execute your desired commands.
To print the output of an openstack-command as json, add a -f json at the end of your command.
Example:
openstack server show cirros -f json
{
"OS-DCF:diskConfig": "MANUAL",
"OS-EXT-AZ:availability_zone": "nova",
"OS-EXT-SRV-ATTR:host": "test-system",
"OS-EXT-SRV-ATTR:hypervisor_hostname": "test-system",
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",
"OS-EXT-STS:power_state": "Shutdown",
"OS-EXT-STS:task_state": null,
"OS-EXT-STS:vm_state": "stopped",
"OS-SRV-USG:launched_at": "2020-07-22T08:41:06.000000",
"OS-SRV-USG:terminated_at": null,
"accessIPv4": "",
"accessIPv6": "",
"addresses": "test-network=192.168.62.207",
"config_drive": "",
"created": "2020-07-22T08:40:46Z",
"flavor": "f1 (273a2179-ac85-4c54-a40a-2c0121b338ff)",
"id": "6d302fcf-4de3-45a5-93c0-eb95650e5952",
"image": "cirros (86dded1f-8e0f-4342-906e-8ff9fbd854e2)",
"name": "cirros",
"project_id": "cbba4b1f3cb4460ca63e8ddb87c9b5fb",
"properties": "",
"security_groups": "name='default'",
"status": "SHUTOFF",
"updated": "2020-08-17T13:26:55Z",
"user_id": "b6505d6801e84fb98d77d2461f9719c2",
"volumes_attached": ""
}
in my HIVE table MYTABLE I have one column "MYCOL" that contains this:
{"id": "a651b57f",
"items": {
"ITEM1": {
"code": "CODE1",
"name": "NAME1"},
"ITEM2": {
"code": "CODE2",
"name": "NAME2"}},
"myinfo": {
"c7daf1a9": {
"id": "c7daf1a9",
"name": "newname",
"type": "newtype",
"appliedto": ["ITEM1", "ITEM2"]}},
"info2": 12}
I would like to access the elements into "myinfo" and I tried something like this:
select GET_JSON_OBJECT(t.MYCOL,'$.myinfo') FROM MYTABLE
but it doesn't work....
may someone help me?
thanks
Make sure the data in HDFS file have one line for each json row (not multiple new lines for one row).
If json row is having multiple new lines then we need to replace all newlines for each row before storing into HDFS.
Example:
HDFS file data:
{"id": "a651b57f","items": {"ITEM1": {"code": "CODE1","name": "NAME1"},"ITEM2": {"code": "CODE2","name": "NAME2"}},"myinfo": {"c7daf1a9": {"id": "c7daf1a9","name": "newname","type": "newtype","appliedto": ["ITEM1", "ITEM2"]}},"info2": 12}
Hive:
with cte as (select string('{"id": "a651b57f","items": {"ITEM1": {"code": "CODE1","name": "NAME1"},"ITEM2": {"code": "CODE2","name": "NAME2"}},"myinfo": {"c7daf1a9": {"id": "c7daf1a9","name": "newname","type": "newtype","appliedto": ["ITEM1", "ITEM2"]}},"info2": 12}')my_col) --sample data
select get_json_object(my_col,'$.myinfo')jsn from cte;
Output:
{"c7daf1a9":{"id":"c7daf1a9","name":"newname","type":"newtype","appliedto":["ITEM1","ITEM2"]}}
Update
--to access name subfield we need to specify the path of json object
hive> select get_json_object(my_col,'$.myinfo.c7daf1a9.name')jsn from <table_name>;
--result
newname
hive> select get_json_object(my_col,'$.myinfo.c7daf1a9.appliedto')jsn from <table_name>;
--result
["ITEM1","ITEM2"]
hive> select get_json_object(my_col,'$.myinfo.c7daf1a9.appliedto[0]')jsn from <table_name>;
--result
ITEM1
I am trying to use lognorm/lognormalizer to test my .rb file to use with rsyslog mmnormalize module. My log file looks like this:
2017-08-19T17:00:12.52Z,john,26,engineer
2017-08-19T17:00:12.59Z,susan,28,doctor
My rb file is as follows:
version=2
rule=:%date:date-rfc3164%,%name:word%,%age:number%,%job:word%
When running lognormalizer:
head -2 /home/debian/olas/test.log | /usr/lib/x86_64-linux-gnu/lognorm/lognormalizer -r /home/debian/olas/rule.rb -e json
I get:
{ "originalmsg": "2017-08-19T17:00:12.52Z,john,26,engineer", "unparsed-data": "2017-08-19T17:00:12.52Z,john,26,engineer" }
{ "originalmsg": "2017-08-19T17:00:13.56Z,susan,28,doctor", "unparsed-data": "2017-08-19T17:00:13.56Z,susan,28,doctor" }
This means the rb script is not correct. Does anyone know what am i doing wrong? The date field I guess is not correctly configured, should I insert any other module? I cant find anything on the web. Thank you
You can use this rule:
version=2
rule=:%date:char-to{"extradata":","}%,%name:char-to{"extradata":","}%,%age:number{"format":"number"}%,%job:rest%
which produces the following output using Lognormalizer (pretty printed):
{
"job": "engineer",
"age": 26,
"name": "john",
"date": "2017-08-19T17:00:12.52Z"
},
{
"job": "doctor",
"age": 28,
"name": "susan",
"date": "2017-08-19T17:00:12.59Z"
}
Test command:
lognormalizer -P -H -r my.rule < mylog.log
Okay, this is driving my crazy. I had set this up before, deleted Sublime Text, and now I can't remember what the right configuration was.
Very simple: I'm running R through SublimeREPL and need to point the REPL to where R is installed.
I followed the directions at http://sublimerepl.readthedocs.org/en/latest/, which say to go into the user-defined REPL settings and add this:
{
...
"default_extend_env": {"PATH": "{PATH}:/home/myusername/bin"}
...
}
where the path points to the right directory. I tried replacing it with
{
...
"default_extend_env": {"PATH": "C:/Program Files/R/R-3.0.2/bin"}
...
}
and it's still unable to find R, plus now it's giving me the error:
Error trying to parse settings: Expected value in Packages\User\SublimeREPL.sublime- settings:2:2
I know this is an easy fix. Can anybody point out what I'm doing wrong here?
*I'm using Sublime Text 3. I previously had this working, but on Sublime Text 2.
I've been to http://tomschenkjr.net/using-sublime-text-2-for-r/ and the piece where he mentions "pointing SublimeREPL at R" ... he doesn't include the actual code, as far as I can see
I've also seen this thread Error 2 The system cannot find the file specified in Sublime Text 2, Windows 8, but I had it working before and didn't have to do anything along those lines
Go to Preferences -> Browse Packages... and create a directory tree User/SublimeREPL/config/R. In that directory, create a new file named Main.sublime-menu with the following contents:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"command": "repl_open",
"caption": "Rterm",
"id": "repl_r",
"mnemonic": "r",
"args": {
"type": "subprocess",
"external_id": "r",
"additional_scopes": ["tex.latex.knitr"],
"encoding": {"windows": "$win_cmd_encoding"},
"soft_quit": "\nquit(save=\"no\")\n",
"cmd": {"windows": ["C:/Program Files/R/R-3.0.2/bin/x64/Rterm.exe", "--ess", "--encoding=$win_cmd_encoding"]},
"cwd": "$file_path",
"extend_env": {"windows": {"PATH": "{PATH}:/C/Program Files/R/R-3.0.2/bin"}},
"cmd_postfix": "\n",
"suppress_echo": {"windows": false},
"syntax": "Packages/R/R.tmLanguage"
}
}
]
}]
}
]
Save the file, and you should now have a Tools -> SublimeREPL -> Rterm menu option. Double-check that the path is the correct one to the Rterm.exe file. On my computer (32-bit XP) it's in the i386 subfolder of bin, so yours may be in bin/x64 or something like that.
I hope this helps, let me know if you still have issues.
I resolved this by adding the location of Rterm.exe to PATH