I am trying to use sling.servlet.prefix option in Sling Servlets. As per my understanding if I put a relative path to resourceType and add a prefix to /apps or /libs it will directly point to that path. But it is not happening.
> #Component(service=Servlet.class,
> property={
> Constants.SERVICE_DESCRIPTION + "=Simple Demo Servlet",
> "sling.servlet.methods=" + HttpConstants.METHOD_GET,
> "sling.servlet.resourceTypes="+ "community-components/components/componentpage",
> "sling.servlet.extensions=" + "sample",
> "sling.servlet.prefix=" + "/apps"
> })
Please help.
The value of the sling.servlet.prefix needs to start with a / for its value to be applied as the prefix. Else, it expects a integer or a String that can be parsed as an integer which would be the index of the search path entries from the resource resolver to be used as the prefix.
Since your prefix didn't start with a /, it would try to convert it into a integer and since it is not a valid integer it would be ignored.
In your case the prefix would be /apps/.
More information on prefix can be found here.
Related
I try to use map directive.
I have 2 vars and if first var exist set it to new var, or if only second var exist, set it to new var.
My config:
map "$arg_arg1:$cookie_1" $new_var {
"~^.*:" $arg_arg1;
"~:.*$" $cookie_1;
default "new";
}
Work only in first situation.
The sequence .* also matches zero characters, so your first regex matches any string containing a :, including those that begin with a :.
Use ^.+: to guarantee at least one character before the : or just .: (as the anchor is not really necessary).
If the cookie value may contain a :, you may want to use ^[^:]+: instead.
My working config:
map "$cookie_1:$arg_arg1" $new_var {
default "new";
"~:.*$" $arg_arg1;
"~*^.*:$" $cookie_1;
}
I need to isolate the file extension from a path in SQLite. I've read the post here (SQLite: How to select part of string?), which gets 99% there.
However, the solution:
select distinct replace(column_name, rtrim(column_name, replace(column_name, '.', '' ) ), '') from table_name;
fails if a file has no extension (i.e. no '.' in the filename), for which it should return an empty string. Is there any way to trap this please?
Note the filename in this context is the bit after the final '\'- it shouldn't be searching for'.'s in the full path, as it does at moment too.
I think it should be possible to do it using further nested rtrims and replaces.
Thanks. Yes, you can do it like this:
1) create a scalar function called "extension" in QtScript in SQLiteStudio
2) The code is as follows:
if ( arguments[0].substring(arguments[0].lastIndexOf('\u005C')).lastIndexOf('.') == -1 )
{
return ("");
}
else
{
return arguments[0].substring(arguments[0].lastIndexOf('.'));
}
3) Then, in the SQL query editor you can use
select distinct extension(PATH) from DATA
... to itemise the distinct file extensions from the column called PATH in the table called DATA.
Note that the PATH field must contain a backslash ('\') in this implementation - i.e. it must be a full path.
How do I use regex to find FS.File on FS.Collection in meteor. My code is as follows and it is not working
partOfFileName = "*User_" + clickedResellerId + "_*";
var imgs = Images.find({fileName:{$regex:partOfFileName}});
//var imgs = Images.find();
return imgs // Where Images is an FS.Collection instance
In place of fileName I've also tried name and it is not working either. Please help
I don't think your regex is valid. Did you perhaps mean the following?
partOfFileName = ".*User_" + clickedResellerId + "_.*";
Please note that POSIX wildcard notation is different from regular expressions. in Regular expressions the * operators indicates repetition of the preceding operator (in my case a ., i.e., anything). A * by itself has no meaning, and it doesn't mean "anything" like in POSIX.
My goal is to access and mutate a property of a node in a cypher query where the name of the property to be accessed and mutated is an unknown string value.
For example, consider a command:
Find all nodes containing a two properties such that the name of the first property is lower-case and the name of the latter is the upper-case representation of the former. Then, propagate the value of the property with the lower-case string name to the value of the property with the upper-case name.
The particular case is easy:
MATCH ( node )
WHERE has(node.age) AND has(node.AGE) AND node.age <> node.AGE
SET node.AGE = node.age
RETURN node;
But I can't seem to find a way to implement the general case in a single request.
Specifically, I am unable to:
Access the property of the node with a string and a value
Mutate the property of the node with a string and a value
For the sake of clarity, I'll include my attempt to handle the general case. Where I failed to modify the property of the node I was able to generate the cypher for a command that would accomplish my end goal if it were executed in a subsequent transaction.
MERGE ( justToMakeSureOneExists { age: 14, AGE : 140 } ) WITH justToMakeSureOneExists
MATCH (node)
WHERE ANY ( kx IN keys(node) WHERE kx = LOWER(kx) AND ANY ( ky in keys(node) WHERE ky = UPPER(kx) ) )
REMOVE node.name_conflicts // make sure results are current
FOREACH(kx in keys(node) |
SET node.name_conflicts
= COALESCE(node.name_conflicts,[])
+ CASE kx
WHEN lower(kx)
THEN []
+ CASE WHEN any ( ky in keys(node) WHERE ky = upper(kx) )
THEN ['match (node) where id(node) = ' + id(node)+ ' and node.' + upper(kx) + ' <> node.' + kx + ' set node.' + upper(kx) + ' = node.' + kx + ' return node;']
ELSE [] END
ELSE []
END )
RETURN node,keys(node)
Afterthought: It seems like the ability to mutate a node property by property name would be a pretty common requirement, but the lack of obvious support for the feature leads me to believe that the feature was omitted deliberately? If this feature is indeed unsupported is there any documentation to explain why and if there is some conflict between the approach and the recommended way of doing things in Neo/Cypher?
There is some discussion going on regarding improved support for dynamic property access in Cypher. I'm pretty confident that we will see support for this in the future, but I cannot comment on a target release nor on a date.
As a workaround I'd recommend implementing that into a unmanaged extension.
It appears that the desired language feature was added to Cypher in Neo4j 2.3.0 under the name "dynamic property". The Cypher docs from version 2.3.0-up declare the following syntax group as a valid cypher expression:
A dynamic property: n["prop"], rel[n.city + n.zip], map[coll[0]].
This feature is documented for 2.3.0 but is absent from the previous version (2.2.9).
Thank you Neo4j Team!
What is the best method to test the existence of an attribute on an XML object in ActionScript 3 ?
http://martijnvanbeek.net/weblog/40/testing_the_existance_of_an_attribute_in_xml_with_as3.html is suggesting to test using
if ( node.#test != node.#nonexistingattribute )
and I saw comments suggesting to use:
if ( node.hasOwnProperty('#test')) { // attribute qtest exists }
But in both case, tests are case sensitive.
From the XML Specs : "XML processors should match character encoding names in a case-insensitive way" so I presume attribute name should also be match using a case-insensitive comparison.
Thank you
Please re-read your quote from the XML specs carefully:
XML processors should match character
encoding names in a case-insensitive
way
This is in chapter 4.3.3 of the specs describing character encoding declarations, and it refers only to the names present in the encoding value of the <?xml> processing instruction, such as "UTF-8" or "utf-8". I see absolutely no reason for this to apply to attribute names and/or element names anywhere else in the document.
In fact, there is no mention of this in section 2.3 of the specs, Common Syntactic Constructs, where names and name tokens are specified. There are a few restrictions on special characters and such, but there is absolutely no restriction on upper and lower case letters.
To make your comparison case-insensitive, you will have to do it in Flash:
for each ( var attr:XML in xml.#*) {
if (attr.name().toString().toLowerCase() == test.toLowerCase()) // attribute present if true
}
or rather:
var found:Boolean = false;
for each ( var attr:XML in xml.#*) {
if (attr.name().toString().toLowerCase() == test.toLowerCase()) {
found = true;
break;
}
}
if (found) // attribute present
else // attribute not present
How about using XML's contains() method or XMLList's length() method ?
e.g.
var xml:XML = <root><child id="0" /><child /></root>;
trace(xml.children().#id.length());//test if any children have the id attribute
trace(xml.child[1].#id.length());//test if the second node has the id attribute
trace(xml.contains(<nephew />));//test for inexistend node using contains()
trace(xml.children().nephew.length());//test for inexistend node using legth()