Saturday 22 August 2015

JAVA - CQ Sync

First Time Ecllipse Setup
CLASSPATH : maven lib path;jdk lib path
JAVA_HOME : jdk path
M2        : maven bin path
MAVEN_HOME: maven path
MAVEN_OPTS: -Xms64m -Xmx256m -XX:MaxPermSize=256
PATH      : %JAVA_HOME%\bin; maven bin path;  vault bin
M2_REPO   : documents and settings\user\.m2\repository

Eclipse Marketplace
MAVEN Integration for Eclipse WTP (Juno)
Preference-> JAVA-> Installed JRE -> add jdk path
maven ->user settings -> C:\Users\pjai42\.m2\settings.xml


Access Nodes in Java
<%@page import="com.sapient.cms.core.utils.Sample"%>
<c:set var="path" value="/content/lcl-trends/en_CA" />
<%=Sample.getValue((String)pageContext.getAttribute("path"), resourceResolver)%>

public class Sample {
public static String getValue(String path, ResourceResolver resolver) throws RepositoryException{
Node tempNode = resolver.adaptTo(Session.class).getNode(path);
 NodeIterator parentNode = tempNode.getNodes();
 StringBuilder sb = new StringBuilder();
 while (parentNode.hasNext()) {
 sb.append(",");
 sb.append(parentNode.nextNode().getName());
    }             
return sb.toString();
}


}

Auto Deploy POM
<profile>
  <id>auto-deploy</id>
  <build>
    <plugins>
      <!-- Use the sling plugin to automatically deploy the bundle to the JCR tree -->
      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>maven-sling-plugin</artifactId>
        <executions>
          <execution>
            <id>install-bundle</id>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <slingUrl>http://localhost:4502</slingUrl>
              <slingUrlSuffix>/apps/myproject/install</slingUrlSuffix>
              <user>admin</user>
              <password>admin</password>
              <usePut>true</usePut>
              <failOnError>true</failOnError>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

No comments:

Post a Comment