URL Mapping for Digital Assets in AEM - aem

I want to give URL mappings to DAM/Digital Assets of My sites. Especially for PDFs. Whenever I give a Download link to PDF it's Showing the full folder structure to the PDF. I want to shorten this.
I am Using AEM 6.2 .

You can also do the mapping in Sling resource resolver factory configuration
1. Go to system config manager and search for Sling resource resolver factory.
2. Add new entry "/content/dam/you-project-structure/>/" and "/content/dam/you-project-structure/</"

You can define URL mappings under the /etc/map location. Take a look at https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html, which includes this example:
Under /etc/map you can create a folder, and then within that folder create a .content.xml file that contains properties such as these:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Mapping"
sling:internalRedirect="/content/dam/the/full/path/to/your/file.pdf"
sling:match=".+/content/short-url.pdf"/>

Related

AEM custom logs creation from scripts

we are automating the AEM configurations, we have a requirement for creating a custom log file. current Manual step followed is
login to AEM Felix console -> Sling -> log support ->Add new logger
parameters updated are log level, log file and logger.
is there a way to automate this log creation ? Please share your inputs.
Thanks in advance,
You can do this by configuring OSGI content nodes or by creating OSGI config files. For instance, I created an OSGI config node at this location:
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.config-util.xml
That file has contents such as this:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.level="debug"
org.apache.sling.commons.log.names="[com.myorg.commons.util.MyUtil,com.myorg.commons.util.OtherUtil]"
org.apache.sling.commons.log.pattern="\{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}"/>
Similarly, you can also do this for
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.writer-util.xml
With contents such as
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.file.buffered="{Boolean}false"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="20MB"/>
See https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/configuring-osgi.html for more details on how these files can be made specific to run modes.
When you install the package containing these nodes, since they are jcr:primaryType of sling:OsgiConfig they will automatically be picked up and configured in your environment (per run mode matching).

How to remove auto generated classes in jax-ws clients

I have a web service which I created with jax-ws in NetBeans. When I create the soap client from the wsdl file, Netbeans generates the mapping classes used for serialisation.
My problem is that I don't want them. I wrote them myself and they are used in other parts of the application. I tried everything to use my classes instead of the auto generated to send the SOAP message but with no success.
The cumbersome solution would be to copy the data from one class to the other and then send the message, but my class has about twenty subclasses so I would like very much to skip this.
Use the JAXB episode option which basically allows you to instruct JAXB to reuse classes in a package. You specify the desired packages in an episode file. "episode" is just a fancy name for a jaxb binding file and it's not very different from your regular jaxb config file. Your episode file would look something like this (bindings file excerpt courtesty of Blaise Doughan's blog)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bindings version="2.1" xmlns="http://java.sun.com/xml/ns/jaxb">
<bindings scd="x-schema::tns"
xmlns:tns="http://www.example.org/Product">
<schemaBindings map="false"/>
<bindings scd="tns:product">
<class ref="com.you.yourclass"/>
</bindings>
</bindings>
</bindings>
Save the file as a .episode file and configure in your Netbeans project like so. I assume here that you've run the Create Webservice from WSDL wizard in Netbeans
Right click on Webservice node within your project. Navigate to the WSimport options tab
Under the Jaxb(xjc) options frame, add the following
(where myepisodefile.episode refers to the episode file you created earlier. Make sure the file is available within your project)

Change web.xml after deployment

Is it advisable to change web.xml (or, in fact, any other file) in app server after the deployment? Do ALL app servers expose their deployment/directory structure?
I would prefer making changes locally, re-building the war (or .ear, etc.), and re-deploying the application.
Regarding your first question, it depends on the type of the resource. For a classpath resource, you can override the file in any directory that has a higher priority in the class loading mechanism of your application server ($CATALINA_HOME/lib for instance if you're using Tomcat). For an xml file, like web.xml, you can declare an external entity in the packaged file with an absolute path, but you have to be sure that the file will be present on the target server. For instance, your packaged web.xml could look like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document [
<!ENTITY webEntity SYSTEM 'C:\Temp\web.xml'>
]>
&webEntity;
So the actual content of the web.xml would be the content of the file C:\Temp\web.xml.
In short, there is no official way to do it but there are tricks. I guess, what people do is to produce a custom package for each production site. There are multiple ways to automate this with Maven like war overlay or classifiers. Here is an interesting link.
Regarding your second question, I would not rely on this assumption. It's quite straight-forward to modify an exploded resource on a Tomcat server but it's is not that simple on a JBoss AS.

How Eclipse download and store XSD external files?

When I open XSD file in Eclipse( in XSD Editor), it download all xsd:import's are contained in file. But if I don't have internet, editor cannot download, it's obvious. In preferences(Window -> Preferences) is XML-> XML Catalog. Is possible add my xsd:import (xsd files) to catalog and Eclipse will use it in offline mode?
Yes you can add your xsd/dtd file to the catalog.
I did it like this (for test) and eclipse does not complain:
Entry element: URI
Location: C:\Users\me\Desktop\log4j.dtd
URI: file:///C:/Users/me/Desktop/log4j.dtd
Key type: URI
Key: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd
I used the native URL in my log4j.xml afterwards
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
I suppose this should also work with xsd files.
This comes from another answer from me.

How do I hide menus without a layer file in NetBeans Platform?

I am having a hard time customizing my menus in the NetBeans Platform. The examples I've seen require you to have a Layer file which I don't believe I have in my NetBeans Platform Project.
To hide a menu via layers you are supposed to do this:
<folder name="Menu">
<folder name="View_hidden"/>
<folder name="Edit">
<file name="org-openide-actions-FindAction.shadow_hidden"/>
</folder>
</folder>
I would like to know the annotation way of hiding menus. However, if this is the only way to do it, where would I put the layer file and what would i name it?
The only way to hide menu items is to add the entries to your layer file. To add a layer file to your module you'll need to
Create a new xml file called layer.xml in any package in your module
Register the new layer file in your Module Manifest file (under the Important Files node) using the following pattern OpenIDE-Module-Layer: com/example/layer.xml where com/example is the package that you created the layer file in
In the layer.xml file you'll need to start with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
</filesystem>
Shortcut for adding the _hidden nodes
Once you've added a layer file to your module you can get NetBeans to add the necessary _hidden nodes by:
Expand the Important Files node in your module (any module will do but if/when this module is uninstalled then the layer file is also uninstalled)
Expand the XML Layer node (this is added once you've manually added the layer.xml file as above)
Expand the this layer in context node
Expand the Menu Bar node
Right click the menu item you want to hide and select Delete