How to create pages, dashboards and navigation programmatically?
agnaldo4j Aug 9, 2011 5:21 PMHello everyone,
I need two things:
1. I need to create a default dashboard for my users. it must be created during the start of the gatein, I developed an integration with the gatein, I can use the api organization, but I can not use the mop api to create my pages, navigation and dashboard.
I need it because every database installation on a clean setting I have to stay in the hand, this is bad.
2. I need to know how to understand the basis of the jcr gatein to make the modifications mentioned above.
I can already access the repository with this code:
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Session;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.CredentialsImpl;
public class JCRWrapper {
public JCRWrapper() {}
public void executeJCR() throws Exception {
PortalContainer container = PortalContainer.getInstance();
Session jcrSession = buildSession(container);
Node node = getRootNodeFormJCR(jcrSession).getNode("production");
System.out.println("------------JCR----------------");
System.out.println("name: "+node.getName());
System.out.println("path: "+node.getPath());
NodeIterator nodeIterator = node.getNodes();
while (nodeIterator.hasNext()) {
Node child = nodeIterator.nextNode();
System.out.println("------------CHILD----------------");
System.out.println("child name: "+child.getName());
System.out.println("child path: "+child.getPath());
System.out.println("=============CHILD================");
}
System.out.println("=============JCR================");
}
private Node getRootNodeFormJCR(Session jcrSession) throws Exception {
return jcrSession.getRootNode();
}
private Session buildSession(ExoContainer container) throws Exception {
RepositoryService repositoryService = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class);
Session jcrSession = repositoryService.getDefaultRepository().login(new CredentialsImpl("root", "gtn".toCharArray()),"portal-system");
return jcrSession;
}
}
Maven dependencies:
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.organization.api</artifactId>
<version>2.3.7-GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.component.core</artifactId>
<version>1.12.7-GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.component.ext</artifactId>
<version>1.12.7-GA</version>
<scope>provided</scope>
</dependency>
Now I need to create the pages, navigations, dashboards and portlets using the gadgets.
someone can help me, thank you