Semantics of sys:locale - alfresco

The data dictionary pretty much forces every node in Alfresco to have a sys:locale value:
<type name="sys:base">
<title>Base</title>
<mandatory-aspects>
<aspect>sys:referenceable</aspect>
<aspect>sys:localized</aspect>
</mandatory-aspects>
</type>
<!--
Localization:
If you add this aspect to a node, then the server will assume that all non-multilingual
properties apply to this locale.
-->
<aspect name="sys:localized">
<title>Translation</title>
<properties>
<property name="sys:locale">
<title>Locale</title>
<type>d:locale</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
I can imagine a whole lot of content where a locale does not make sense to me at all. Images, video, sound, code are a few examples. I would guess this locale is used for indexing tokenized string type properties. Still, I cannot see how that makes sense in the context of the content mentioned.
What exactly are the semantics of sys:locale and how is it used by Alfresco ?

The sys:locale serves as a fallback for the locale from the ContentData during indexing (if not set), so both #cm:content.locale and the tokenisation of d:content / d:text properties may / will be affected. In addition, sys:locale is used to differentiate the translations within the context of MultilingualContentService. On a site node, it affects the generated workflow descriptions for invitations.
sys:locale is not a real property in the sense that it is maintained in alf_node_properties - it is a virtual property much like sys:uuid derived from alf_node directly, which is why it affects even the content where it might not make much sense (apart from d:text property tokenization).

Related

How to select the right <category> in RSS? is there a list?

i am noting that in a RSS feed you can add the tag
Source: https://www.w3schools.com/xml/rss_tag_category_item.asp
But I don't undestand one thing: is there a list with all the categories? Or can I write anything? I need a category about videogames
Or can I write anything?
You can write anything.
Unless you're submitting your feed to a directory, with a documented set of categories, it's essentially free text.
However, in RSS:
It has one optional attribute, domain, a string that identifies a categorization taxonomy.
The value of the element is a forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy.
and in Atom:
The "scheme" attribute is an IRI that identifies a categorization
scheme.
you can indicate that your term is from a specific scheme.
In practice, some schema extensions like iTunes introduce a separate element:
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
...
<itunes:category text="Sports">
<itunes:category text="Wilderness"/>
</itunes:category>
rather than suggesting use of the scheme attribute. The iTunes guide currently includes:
<itunes:category text="Leisure">
<itunes:category text="Video Games" />
</itunes:category>

where is the XSD and semantics of the web.xml defined?

I am trying to find where the XSD and the semantics for the deployment descriptor web.xm file is defined in the Servlet 3.0 specification.
Alternatively, where is an authoritative description of the various supported elements and attributes that can appear inside web.xml and what the default behavior of the container is, in case some elements / attributes are absent.
This started by me wondering what is the default value for the http-only and secure elements inside session-config, e.g. as in:
<session-config>
<session-timeout>60</session-timeout>
<cookie-config>
<http-only>true</http-only>
<secure>false</secure>
</cookie-config>
</session-config>
I am reasonably certain the default values are false for both but I wanted to see where this is authoritatively specified.
Looking at the Java Servlet 3.0 spec there is no XSD. There is a sample XML file (on pg. 169) which has a schemaLocation attribute with value:
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
… which is broken. Googling for web-app_2_5.xsd an XSD file is found but it doesn't contain the definition of <session-config> element (I couldn't locate it even when googling for the other XSDs that that file imports).
The specification does contain graphical depictions of some elements (in the horrible late 90's style when such "visualizations" were in vogue) but this is all it contains for the session-config element:
There's no futher discussion for the cookie-config element.
I find it hard to believe that a specification does not contain the full XSD (or at least a link to it) and a detailed description of the semantics of all elements and attributes.
Am I missing something?
A list of schemas can be found at
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html
(at the very beginning it is stated "Latest Version: http://xmlns.jcp.org/xml/ns/javaee/", which in turn redirects to the link I've posted first; I think the latter URL should be used as a permalink)
Then you'll find the schemas grouped by Java EE version. I think servlet 3.0 is JEE 6, so:
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html#6
There you'll get the schemas:
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-common_3_0.xsd
http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-fragment_3_0.xsd
Had problems with the schemas from oracle. The URLs were just not working, kept throwing an error.
so I switched to the jboss schema (at https://www.jboss.org/j2ee/schema/)
I replaced
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
with
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee https://www.jboss.org/j2ee/schema/web-app_2_4.xsd"
Also make sure the version attribute on the web-app tag is set correctly (e.g. version="2.4" in this case)

How does spring security's <intercept-url> work.. ?

I have several <intercept-url> in my spring-security XML. I just have this small doubt. Suppose I have something like :
<intercept-url pattern="/data/**" access="ROLE_ADMIN" />
<intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" />
Since the below <intercept-url> has a pattern of /** I was wondering if the second URL over-rides the first one. E.g. I gt acess to /data/** even if I am a USER.
Quote from the reference documentation:
You can use multiple <intercept-url> elements to define different access requirements for different sets of URLs, but they will be evaluated in the order listed and the first match will be used. So you must put the most specific matches at the top.
As long as the rule for /** is listed later, it won't override the more specific rule for /data/**.
As jpprade suggested already, if you get access to /data/** as a plain user with the above rules, there must be some other problem with your configuration. In that case share your web.xml and the whole security config to troubleshoot that.
The second doesn't overides the first one, in theory it is the first matched rules which is applied.
if you can access /data/** as USER maybe it is because your miss something in the configuration, maybe the filter declaration ?

Use HTML markup in web.config file

I want to display a message in my homepage (default.aspx), which is different for each "installation" of my web app. I would like to avoid making a call to the database to show this message.. so I thought of using web.config to store something like this
<add key="WelcomeString" value="lorem ipsus <b>doloret sit amen</b>" />
But I've noticed I can't use html markup in the web.config ...
Is there a better approach, or is there a way to insert html markup into web.config?
Thank you again stack overflow guru's... i'm learning from you a lot of things !
You need to XML encode it, to store it in the XML as a valid attribute value. eg:
<add key="WelcomeString" value="lorem ipsus <b>doloret sit amen</b>" />
Use "<" and ">" instead of "<" and ">":
<add key="WelcomeString" value="lorem ipsus <b>doloret sit amen</b>" />
You have a couple of examples of how to add it to the web.config file, but I would suggest that you consider adding a "localization" XML file to App_Data and read it from there rather than polluting the web.config file with customizations for each installation. You could read this file during application start up and store the values in the HttpRuntime.Cache by key, retrieving them from there as needed. Note that you need a way to regenerate them if they get flushed from the Cache (or mark them as not removable). Use the same technique to encode it for an attribute in the XML file or, if longer, store it in CDATA in the node value.
I use a technique like this with two XML files, defaults and localizations. Defaults supplies default values for the localizable aspects of the application. Localizations, if present, will override the defaults. These are loaded, in my case, into a Singleton object for the application that has strongly-typed properties for the values. Note that this encompasses much more than simply localized strings; they can be arbitrarily complex. The Singleton object has methods to read and apply both defaults and localizations given the path to the XML file.

NHibernate update using composite key

I have a table defnition as given below:
License
ClientId
Type
Total
Used
ClientId and Type together uniquely identifies a row. I have a mapping file as given below:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Acumen.AAM.Domain.Model.License, Acumen.AAM.Domain" lazy="false" table="License">
<id name="ClientId" access="field" column="ClientID" />
<property name="Total" access="field" column="Total"/>
<property name="Used" access="field" column="Used"/>
<property name="Type" access="field" column="Type"/>
</class>
</hibernate-mapping>
If a client used a license to create a user, I need to update the Used column in the table. As I set ClientId column as the id column for this table in the mapping xml, I am getting TooManyRowsAffectedException.
could you please let me know how to set a composite key at mapping level so that NHibernate can udpate based on ClientId and Type.
Something like: Update License SET Used=Used-1 WHERE ClientId='xxx' AND Type=1
Please help.
Thanks,
Mahesh
You have to use a composite-id
http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-compositeid
If you primary key is composite, your mapping should reflect that, and your class needs to override Equals and GetHashCode.
Also, if ClientId is the primary key of your Client entity, you should map it as many-to-many, not just an Id.
Also, why are you specifying lazy="false"? Are you aware of the implications?
Also, why map everything with access="field"? Do the properties have some special logic?
This is a revised mapping considering everything I just wrote. Feel free to ignore those parts that don't apply :-)
<class name="Acumen.AAM.Domain.Model.License, Acumen.AAM.Domain" table="License">
<composite-id>
<key-many-to-one name="Client" column="ClientID" />
<key-property name="Type" />
</composite-id>
<property name="Total" />
<property name="Used" />
</class>
As the other comrades mentioned above, you have to use a composite-id, which is not a best but acceptable practice.
On the other hand, you can simply write an update interceptor and make sure your Type = 1 within it.
Here are some link about the topic to help you see clear in this.
Elegant code : Implementing NHibernate Interceptors
NHibernate Documentation : Interceptors
Sample NHibernate IInterceptor implementation
Enterprise .NET Community : NHibernate Part 2 (Scroll down to : Interceptors and Persistent Lifecycle)
NHibernate Interceptor Auditing Inserted Object Id (SO question)
The main advantage of using interceptors over a composite key is that it doesn't break your DBRM and provides a definitely more flexible solution, without "polluting" your mapping file which will more precisely represent your model.

Resources