2017-01-26 8 views
0

pathbrowser에 대한 사용자 지정 OSGI 서비스 조건자를 구현하려고합니다. 만약 누군가가이 코드에 어떤 문제가 있는지 알고 있다면 :) 예외가 있습니다. 어쩌면 그것은 @Component 뭔가 또는 의존성이다AEM 6.2 사용자 지정 경로 브라우저 조건부 만들기

<path jcr:primaryType="nt:unstructured" 
     sling:resourceType="granite/ui/components/foundation/form/pathbrowser" 
     fieldDescription="List item link" 
     fieldLabel="List Item link" 
     name="./path" 
     predicate="predicate" 
     rootPath="/content"> 
</path> 

술어 구현 :

import org.apache.commons.collections.Predicate; 
import org.apache.felix.scr.annotations.Component; 
import org.apache.felix.scr.annotations.Properties; 
import org.apache.felix.scr.annotations.Property; 
import org.apache.felix.scr.annotations.Service; 
import org.apache.sling.api.resource.Resource; 

import com.day.cq.commons.predicate.AbstractResourcePredicate; 
import com.day.cq.wcm.api.Page; 

@Component(label = "Content-page Predicate", description = "This predicate is used to restricted to allow selection of pages that have template content-page") 
@Service(value = Predicate.class) 
@Properties({ 
    @Property(label = "Predicate Name", name = "predicate.name", value = "predicate", propertyPrivate = true) }) 
public class ContentPagePredicate extends AbstractResourcePredicate { 

    private static final String CQ_TEMPLATE_CONTENT = "/conf/xxx-lab/settings/wcm/templates/content-page"; 

    @Override 
    public boolean evaluate(Resource resource) { 
     if (null != resource) { 
      if (!resource.getResourceType().equals("cq:Page")) { 
       return false; 
      } 
      Page page = resource.adaptTo(Page.class); 

      return page.getTemplate().getName().equals(CQ_TEMPLATE_CONTENT); 

     } 
     return false; 
    } 
} 

Maven을 구축 출력 :

[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-scrdescriptor) on project SomethingDemo.core: Execution generate-scr-scrdescriptor of goal org.apache.felix:maven-scr-plugin:1.20.0:scr failed: An API incompatibility was encountered while executing org.apache.felix:maven-scr-plugin:1.20.0:scr: java.lang.VerifyError: Constructor must call super() or this() before return 
[ERROR] Exception Details: 
[ERROR] Location: 
[ERROR] com/day/cq/commons/predicate/AbstractNodePredicate.<init>()V @1: return 
[ERROR] Reason: 
[ERROR] Error exists in the bytecode 
[ERROR] Bytecode: 
[ERROR] 0x0000000: 2ab1 
+0

AbstractResourcePredicate 대신 AbstractNodePredicate를 확장하면 어떻게됩니까? –

답변

2

당신이에서 클래스를 확장 할 때 표시되는 오류가 발생할 수 있습니다 OSGi 번들 디스크립터를 생성하는 데 사용되는 SCR 주석으로 주석 처리 된 AEM API와 동시에 사용중인 Uber Jar에서 난독 화 된 API.

에서 사용중인 AEM 버전의 난해한 Uber Jar를 찾을 수 있습니다.

당신이 고객이나 파트너를 대표하는 경우, 당신은 또한 프로젝트가 이미 읽을 수있게 항아리가있는 저장소를 사용하는 경우 도움말 사이트 https://daycare.day.com/home/products/uberjar.html

에서 하나를 다운로드 할 수 있어야, 그것만큼 간단해야 의존성을 변경합니다. 넓은에 대한

<dependency> 
    <groupId>com.adobe.aem</groupId> 
    <artifactId>uber-jar</artifactId> 
    <version>6.2.0</version> 
    <scope>provided</scope> 
    <classifier>apis</classifier> 
</dependency> 

체크 아웃이 Github issue : 예를 들어

프로젝트에 읽을 수있게 버전을 얻을 그냥 분류를 변경 난독 클래스
<dependency> 
    <groupId>com.adobe.aem</groupId> 
    <artifactId>uber-jar</artifactId> 
    <version>6.2.0</version> 
    <scope>provided</scope> 
    <classifier>obfuscated-apis</classifier> 
</dependency> 

와 AEM 6.2 동네 짱 항아리를 사용하여 매우 비슷한 문제에 대한 토론.

Adobe Help Forum thread은 베타 버전과 관련되어 있지만 이지만 재미있을 수도 있습니다.

+0

FWIW, 이제는 모든 사람이 쉽게 읽을 수있는 uber jar를 사용할 수 있습니다. https://daycare.day.com/home/products/uberjar.html –

+0

@ i.net을 참조하십시오. 그러나 게시 한 링크가 비밀번호로 보호되어 있음을 알 수 있습니다. 기본 HTTP 인증처럼 보이지만 자격 증명을 사용해야한다는 표시는 없습니다. 이것은 Adobe ID를 사용합니까? – toniedzwiedz

+0

죄송합니다. 지금은 주석을 편집 할 수 없으므로 (편집자가 충분하지 않습니까?) 기본적으로 UberJar를 요청할 필요가 없습니다. 링크를 통해 다운로드 할 수 있기 때문에 고객 인 경우 UberJar를 요청할 필요가 없습니다. 그것에 접근 할 수있다). 액세스 할 수없는 경우 Adobe의 공개 레포에서 다음 링크를 통해 알려지지 않은 jar 파일을 얻을 수 있습니다. https://repo.adobe.com/nexus/content/repositories/releases/com/adobe/aem/uber- jar/6.2.0/uber-jar-6.2.0-apis.jar 또한 동일한 폴더에서 난독 화 된 버전을 찾을 수 있습니다. 또한 다른 버전에서도 사용할 수 있습니다. –

1

org.apache.commons.collections.Predicate을 구현하십시오.

또한는 인 cq:Page이므로 true이 아닙니다. page.getTemplate() 게시 할 때 작동하지 않습니다.

public booean evaluate(Resource resource) { 
    if (null == resource) return false; 
    final ValueMap map = resource.getValueMap(); 
    return "cq:Page".equals(map.get("jcr:primaryType", "") 
      && CQ_TEMPLATE_CONTENT.equals(map.get("cq:template", "") 
}