I have a content model defined and inside it i have a constraint values with LIST type.
I have a page contains r:propertySheet associated with a node of type "Position" and that type have a property refer to the constraint LIST.
The render of the page is correct, but once i execute a code to setProperties from NodeService, i have the following errors.
A system error happened during the operation: 07230003 Found 1 integrity violations: Invalid property value: Node: workspace://SpacesStore/4c7464b2-2c1b-4346-b3f4-215a3818ac9c Type: {www.ds.alfresco.security.extension.com}position Property: {www.ds.alfresco.security.extension.com}permissions Constraint: 07230002 The value is not an allowed value: [READ SADER, WRITE SADER, READ WARED]
Where My Code is:
if(currentPosition != null && currentPosition.getNodeRef() != null){
Map<String,Object> properties = currentPosition.getProperties();
ArrayList<String> permissions = (ArrayList<String>)properties.get(Constants.SecurityModelQNames.PROP_SEC_POSITION_POSITION_PERMISSIONS);
Map<QName,Serializable> qnameSerializableProperties = NodeUtil.prepareQnameSerializableList(properties);
for(Map.Entry<QName, Serializable> entry : qnameSerializableProperties.entrySet()){
System.out.println(entry.getKey()+","+entry.getValue());
}
getNodeService().setProperties(currentPosition.getNodeRef(), qnameSerializableProperties);
}
What i do to make this code executable?
Simply, i read the values from the page and fill them in a list and again set this list in the node as property.
Related
I receive an error, value must be a string, when trying to set an ssm parameter with type=stringlist to a variable of type list using terraform.
resource "aws_ssm_parameter" "customer_list_stg" {
name = "/corp/stg/customer_list"
type = "StringList"
value = var.customer_list
tags = {
environment = var.environment
}
}
customer_list = ["sar", "smi", "heath","first","human","stars","ther","ugg","stars","well"]
terraform apply: expecting an ssm parameter with a list of 10 strings
received an error: Inappropriate value for attribute "value": string required.
I have tried tostring, jsonencode and flatten without success.
Just use list as the type, StringList isn't a valid HCL type. Please see the documentation here:
[https://developer.hashicorp.com/terraform/language/expressions/types][1]
Regardless of the attribute type = "StringList", the value attribute of aws_ssm_parameter always expects a string literal.
Please refer to the AWS API docs
Hence the correct code would be as follow
resource "aws_ssm_parameter" "customer_list_stg" {
name = "/corp/stg/customer_list"
type = "StringList"
value = join(",", var.customer_list) ## if you want to use list(string) input
# value = "sar,smi,heath,first,human,stars,ther,ugg,stars,well" ## as a string literal (you can put this value in a variable too)
tags = {
environment = var.environment # define this variable in your config too.
}
}
variable "customer_list" {
type = list(string)
description = "(optional) Customer List"
default = ["sar", "smi", "heath", "first", "human", "stars", "ther", "ugg", "stars", "well"]
}
is there any solution? e.g. I have data in Map with key favorites_ prefix and values _suffix (for example: favorites_jeans, favorites_suit,...,). I want to by dint of loop get that values and set in List, because of it I must give keys of map, right?
I want to know how can I get values of myMap["favorites_*"] (* - after the favorites_ any symbols).
List<String> favoritesStrings = ['favorite_name','favorite_jeans',];
Map<String,dynamic> myMap = {
favoritesStrings[0]:'0',
favoritesStrings[1]:'1',
'someKey':'2',
'anotherKey':'3',
};
favoritesStrings.forEach((favorite)=>print(myMap[favorite]));//prints 0 1
As per what I understood, you want to fetch value from map using "favorites_" + a dynamic value from list as key.
You just have to use String templates and use $ to insert suffix variable to build key dynamically:
List<String> suffixList = ["jeans", "suit", "shirt"];
for(String suffix in suffixList) {
var item = myMap["favorites_$suffix"];
// Do something with item
}
Hope it helps
I have a simple case class MyContext(queries: Query) that I provide to the schema with : sangria.schema.Schema(deriveContextObjectType[MyContext, Query, Unit](_.queries)
MyQuery is a trait of Query
trait MyQuery {
#GraphQLField
def item(ctx: Context[MyContext, Unit])(id: String) ...
}
This works great. But what if I want to nest resolvers?
query {
item {
status # status is resolved from source B
price # price is resolved from source C
}
}
Is that possible to achieve? Would I return an ObjectType[Item] that has properties status and price annotated with #GraphQLField?
I think you can use deriveObjectType for an Item. It is also able to handle the #GraphQLField annotation (as an alternative you can also use IncludeMethods macro setting). Here is an example:
implicit val ItemType = deriveObjectType[MyContext, Item]()
Really appreciate #tenshi's answer! I tried using the deriveObjectType but was getting a type error:
type mismatch;
found : sangria.schema.Context[MyContext,Item]
required: sangria.schema.Context[MyContext,Unit]
But using deriveContextObjectType in conjunction with AddFields is working:
def schema = sangria.schema.Schema(
deriveContextObjectType[MyContext, Query, Unit](_.queries,
AddFields(
Field(
name = "item",
fieldType = deriveContextObjectType[MyContext, Item, Unit](_ => new Item),
resolve = _ => ()
)
))
)
And the Schema looks good, yielding:
type Query {
item: Item!
}
How do I modify the query below to properly handle the case where the "Summary" element is missing from one of the articles? Now when that happens I get an "Object reference not set to an instance of an object."
var articles = from article in xmlDoc.Descendants("Article")
select new {
articleId = article.Attribute("ID").Value,
heading = article.Element("Heading").Value,
summary = article.Element("Summary").Value,
contents = article.Element("Contents").Value,
cats = from cat in article.Elements("Categories")
select new {
category = cat.Element("Category").Value
}
};
The problem is that article.Element("Summary") returns null if the element is not found, so you get a NullReferenceException when you try to get the Value property.
To solve this, note that XElement also has an explicit conversion to string. This won't throw if the XElement is null - you will just get a null string reference.
So to solve your problem you can change this:
summary = article.Element("Summary").Value,
to this:
summary = (string)article.Element("Summary")
var debtProtectionId = 0
// get the selected id of debt protection dropdown
if (mainPanel.generalPanel.calculationsFieldSet.debtProtection.getValue() != '') {
debtProtectionId = mainPanel.generalPanel.calculationsFieldSet.debtProtection.getValue();
}
// get the store record with this id
var storeRecord = planCombinationsStore.getAt(debtProtectionId)
When I run the code it says 'storeRecord is undefined'.
What could be the cause of this?
Store.getAt expects an index to its internal collection. Do you mean Store.getById instead?