Environment

AEM Assets 6.0, 6.1, 6.2, 6.3

Steps

Assets cannot be moved properly using the JCR Session.move API.  Instead you must use the PageManager.move API.

For example:

PageManager pageManager = ((PageManager)resourceResolver.adaptTo(PageManager.class));
Resource sourceResource = resourceResolver.getResource("/content/dam/example.jpg");
String destinationPath = "/content/dam/test/example.jpg";
pageManager.move(sourceResource, destinationPath, null, false, true, null, null);

Unfortunately, that method call doesn't fully include everything that is done by the com.day.cq.wcm.core.impl.commands. AbstractCopyMoveCommand class which handles the request from the UI. To fully simulate the UI, you would have to internally fire off this request using the SlingRequestProcessor.

See this article for details on how to internally fire off such a request:
http://www.nateyolles.com/blog/2015/10/get-rendered-html-for-an-aem-resource-or-component

The request would be:

POST /bin/wcmcommand

with these POST parameters:

cmd=movePage
integrity=true
_charset=utf-8
destParentPath=/content/dam
destName=test1.png
srcPath=/content/dam/test.png

이 작업에는 Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License의 라이센스가 부여되었습니다.  Twitter™ 및 Facebook 게시물은 Creative Commons 약관을 적용받지 않습니다.

법적 고지 사항   |   온라인 개인 정보 보호 정책