@samr2b1 There is no other way to achieve your goal without customization. AEM OOTB is not providing any option to configure the default path, either specific or dedicated endpoint you could use. Of course it can be done many ways, my first post shows probably the easiest customization. Here is an alternative, backend only solution that is using using Sling Filter.
package com.example.filters;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.engine.EngineConstants;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import java.io.IOException;
@Component(service = Filter.class,
property = {
EngineConstants.SLING_FILTER_SCOPE + "=" + EngineConstants.FILTER_SCOPE_REQUEST,
})
public class AssetsFinderFilter implements Filter {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void doFilter(final ServletRequest request, final ServletResponse response,
final FilterChain filterChain) throws IOException, ServletException {
final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
if (slingRequest.getRequestPathInfo().getResourcePath().startsWith("/bin/wcm/contentfinder/asset/view")) {
filterChain.doFilter(new AssetsFinderSlingHttpServletRequest(slingRequest), response);
}
else {
filterChain.doFilter(request, response);
}
}
@Override
public void init(FilterConfig filterConfig) {
}
@Override
public void destroy() {
}
}
package com.example.filters;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.RequestPathInfo;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class AssetsFinderSlingHttpServletRequest extends SlingHttpServletRequestWrapper {
protected RequestPathInfo requestPathInfo;
public AssetsFinderSlingHttpServletRequest(SlingHttpServletRequest wrappedRequest) {
super(wrappedRequest);
WrappedRequestPathInfo wrappedRequestPathInfo = createWrappedRequestPathInfo();
RequestPathInfo wrappedRequestInfo = (RequestPathInfo) Proxy.newProxyInstance(
RequestPathInfo.class.getClassLoader(),
new Class[] { RequestPathInfo.class},
wrappedRequestPathInfo);
requestPathInfo = wrappedRequestInfo;
}
public WrappedRequestPathInfo createWrappedRequestPathInfo() {
return new WrappedRequestPathInfo();
}
@Override
public RequestPathInfo getRequestPathInfo() {
return requestPathInfo;
}
class WrappedRequestPathInfo implements InvocationHandler {
private final static String DEFAULT_SUFFIX = "/content/dam/we-retail";
private RequestPathInfo getOriginal() {
return getSlingRequest().getRequestPathInfo();
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
switch (methodName) {
case "getResourcePath":
return getResourcePath();
case "getExtension":
return getExtension();
case "getSelectorString":
return getSelectorString();
case "getSelectors":
return getSelectors();
case "getSuffix":
return getSuffix();
case "getSuffixResource":
return getSuffixResource();
default:
throw new UnsupportedOperationException("REQUESTPATHINFOWRAPPER >> NO IMPLEMENTATION FOR " + methodName);
}
}
public String getResourcePath() {
return getOriginal().getResourcePath();
}
public String getExtension() {
return getOriginal().getExtension();
}
public String getSelectorString() {
return getOriginal().getSelectorString();
}
public String[] getSelectors() {
return getOriginal().getSelectors();
}
public String getSuffix() {
return StringUtils.defaultIfBlank(getOriginal().getSuffix(), DEFAULT_SUFFIX);
}
public Resource getSuffixResource() {
return getOriginal().getSuffixResource();
}
}
}
Summarizing, if you do not want to write custom code, then the only OOTB option is that authors will always set path manually. In other case customization is needed, you can choose which customization way will be the best from your perspective.