How to map urls? - aem

I would like to map pages such domain/content/myProject/home.html to domain/home.html. /content/myProject/ is not needed. I have the following code:
String newpath = getResourceResolver().map(page.getPath());
this does not change anything. newpath is stay page.getPath()
how to solve this issue?

Answering as this question as it remains unanswered. Here is an example of how the etc mappings should look like:
Trick is you add 2 entries to sling:internalRedirect as / and /content/example/
AEM first tries to resolve resources with first entry '/'. So non page URLs like /etc/designs, /content/dam etc will be addressed by the first entry. If it is unable to resolve using the first one, it uses the second entry to resolve the page.
This is also the adobe recommended way for URL shortening compared to other techniques like apache redirect.

You need to create map in etc.Then Resource Resolver will take care of trimming the path .
CREATING MAPPING DEFINITIONS IN AEM
In a standard installation of AEM you can find the folder:
/etc/map/http
This is the structure used when defining mappings for the HTTP protocol. Other folders (sling:Folder) can be created under /etc/map for any other protocols that you want to map.
Configuring an Internal Redirect to /content
To create the mapping that prefixes any request to http://localhost:4503/ with /content:
Using CRXDE navigate to /etc/map/http.
Create a new node:
Type sling:Mapping
This node type is intended for such mappings, though its use is not mandatory.
Name localhost_any
Click Save All.
Add the following properties to this node:
Name sling:match
Type String
Value localhost.4503/
Name sling:internalRedirect
Type String
Value /content/
Click Save All.
This will handle a request such as:
localhost:4503/geometrixx/en/products.html
as if:
localhost:4503/content/geometrixx/en/products.html
had been requested.
You can refer here for further documentation http://docs.adobe.com/docs/en/cq/5-6-1/deploying/resource_mapping.html

Related

How to generate and resolve custom URLs with TYPO3 9.5

Am using $GLOBALS['TSFE']->cObj->typoLink to generate a link and I've an additional parameter like this: ext__pluginname[d64]=31511 and would like to return something like a/b/c. I would then want TYPO3 to give me back the link so I can resolve it when clicked. I've already tried PersistedAliasMapper but won't allow to return anything with a slash in it. I've even tried a custom aspect mapper. I get the error:
Parameter "tx_ext__pluginname__d64" for route "enhancer_tx_ext__pluginname000000003e62d21a000000000514759a" must match "[^/]++" ("a/c" given) to generate a corresponding URL.
Am able to generate and resolve the slugs(urls). I can store them in db and retrieve them for that matter. No problem.
Am generating them from root page (uid 1).
How can i get this to work?
I assume you already have created the desired path in a database table or view already, making use of the slug feature in the TYPO3 backend or creating it yourself.
You could then use the PersistedAliasMapper in your site config (config/sites/default/config.yaml).
If you need multiple values in a single path divided by slashes (not a combined slug field), take a look at the route configuration for the news extension. You just have to use database mappers instead of static ones, but keep in mind this may impact the performance of the routing!
As you did not provide much detail about your use case, I don't really understand why you need such a path structure with slashes.

Apache Wicket event on Page "page was mouted on ..."

I have mount Page in this form (with one predefined parameter):
mountPage("/lista/${variant}", StronaEntityV2.class);
when parameter "variant" is given all is OK. But when parameter is absent (is OK too from application point of view) URL is build in form
wicket/bookmarkable/all....package...StronaEntityV2?8
It is ok too, but I will know that situation. In simple situation (with one predefined parameter) checking parameter is good, but in more complicated isn't so simple (and must maintain code in distinct places).
My ideal imaged solution is event
page.OnPageIsMountedOn(URL to_me)
I will accept wide range of solutions.
FORMAL: please integrate synonyms on tags wicket-1.6 & wicket-6, and create new wicket-7
Your page is configured to listen to /lista/${variant}.
When you do: setResponsePage(StronaEntityV2.class, paramsWithVariant) then Wicket will use the mount point and produce: /lista/variantValue.
But if you do: setResponsePage(StronaEntityV2.class), i.e. no PageParameters provided, then Wicket will ignore /lista/${variant} (because it doesn't match) and will produce a "default" page url, i.e. /wicket/bookmarkable/com.example.StronaEntityV2.
So the application controls which url should be used.
You can use optional parameter placeholder: /lista/#{variant}. Note that I use # instead of $ now. This way Wicket will produce /lista/ when there is no variant parameter provided. In the page constructor you will know that the url is always "/lista" but the parameter may be null, so better use: pageParameters.get("variant").toXyz(defaultValue) or .toOptionalXyz().

SSRS Deployment complaining about path length when my path is short

I am attempting to deploy my SSRS solution. I have set the "TargetReportFolder" property of my project to "Reports"
When I right-click and select "Deploy", I get the following error:
The path of the item '/Reports' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.
Obviously my path is less than 260 characters long. I've tried setting my TargetReportFolder property to "/Reports", to the name of my project, and to the name of my project with a slash at the beginning - all give the same error.
I don't understand this deployment process very well. Can someone help me understand?
(I also feel like this may not be on topic, but was encouraged by the presence of an SSRS tag)
My problem was that I didn't understand how Reporting Services works with SharePoint. My comment above is incorrect, I did need to deploy, but I had the wrong parameters for my properties. This page helped me:
http://msdn.microsoft.com/en-us/library/bb283155.aspx
The key takeaways from this article are:
All Target*Folder properties need to be either a URL to a document library, or empty
If they are empty, they take the value of TargetReportFolder, which can't be empty and must be a URL to a document library
TargetServerURL needs to be the URL of the site collection in SharePoint

Display an older version of a CQ page

For audit purposes I got the requirment to create a tool where the authors can look at older versions of a CQ page. I managed to get the available versions with the JCR VersionManager using the following code (used in a SlingServlet with cq:Page as the resourceType):
Session session = request.getResourceResolver().adaptTo(Session.class);
VersionManager vm = session.getWorkspace().getVersionManager();
VersionHistory versionHistory = vm.getVersionHistory(request.getResource().getPath());
VersionIterator vIt = versionHistory.getAllVersions();
while (vIt.hasNext()) {
Version version = vIt.nextVersion();
String no = version.getName();
Calendar createdDate = version.getCreated();
// do something with it
}
The path of the version points to e.g. /jcr:system/jcr:versionStorage/d6/23/4f/d6234f36-3360-4024-bee2-411020ac63ae/1.0 where I can see a child node called jcr:frozenNode which seems to represent the jcr:content node of this specific version.
How can I tell CQ to render the page in this version? I would expect an url with some parameter or selector, but I didn't find any documentation. I tried to reverse engineer it with the Timewarp, but there the URL seems to be still the original and the magic is hidden somewhere.
I was also in contact with adobe support regarding this, and beside the timewarp there seems to be no built in feature to achieve this. Nevertheless I did some experimenting and found a feasible workaround. Though it might not be easy for a complex layout with many fixed components in the template, luckily on our case we mainly have a parsys.
So my solution is the following: I load the older version through two selectors in the url:
I called it "versionhistory" which is used to take another rendering script called versionhistory.jsp on the page component.
contains the actual version/node name (replacing "." with "_" to not add more selectors
In my versionhistory.jsp I just add the correct path for the parsys component (taking the example path from the question), and include the same layout elements as in the default script e.g. page.jsp:
<cq:include path="/jcr:system/jcr:versionStorage/d6/23/4f/d6234f36-3360-4024-bee2-411020ac63ae/1.0/jcr:frozenNode/par" resourceType="foundation/components/parsys" />

How to implement copy paste of a resource in REST?

How would you implement copy-paste support in a RESTful way?
Let's say I have book store resource. And books in every store
http://mydomain.com/rest/book-stores/1
http://mydomain.com/rest/book-stores/1/books/12
I need the client to be able to invoke copy paste of a book to another store.
Implementing the following:
PUT http://mydomain.com/rest/books/1/copy-paste
seems very RPC like. Do you have any suggestion how can this operation be modeled in a RESTful way?
Copy = GET http://mydomain.com/book/1
Paste = PUT http://mydomain.com/book/2 or POST http://mydomain.com/book
This is only a problem if your resources are organized to mimic a hierarchical system. Like a file system.
I prefer non-hierarchical resources. The "path" to a file would just be a property of the file. To copy-paste, there are two options.
If you really just want another "path" reference, add another entry for the "path" property. The same exact file is "in" both "folders".
If you need to new version of the file, effectively forking changes thereafter, create a new resource (different URI) with a different "path" property.
To move, just change the "path" property.
If you must insist on hierarchical, just mimic how a file system does copy-paste and move.
The copy is easy. A GET for the resource to copy.
To paste, a POST, because you are creating a new resource, a new URI.
If you need to do a move, you probably need to DELETE the old resource.
If you want, you can specify a location in the delete request, allowing the server to redirect users looking for the moved resource at its old location.
I would have it so that the user executes PUT command to execute the action.
So something like a variable in the form data is contains the correct action to perform.