]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.jcr/src/org/argeo/app/jcr/JcrEntityDefinition.java
Adapt to changes in Argeo Build and Argeo Commons
[gpl/argeo-suite.git] / org.argeo.app.jcr / src / org / argeo / app / jcr / JcrEntityDefinition.java
1 package org.argeo.app.jcr;
2
3 import java.util.Map;
4
5 import javax.jcr.Repository;
6 import javax.jcr.RepositoryException;
7 import javax.jcr.Session;
8
9 import org.argeo.app.api.EntityConstants;
10 import org.argeo.app.api.EntityDefinition;
11 import org.argeo.cms.jcr.CmsJcrUtils;
12 import org.argeo.jcr.Jcr;
13 import org.osgi.framework.BundleContext;
14
15 /** An entity definition based on a JCR data structure. */
16 @Deprecated
17 public class JcrEntityDefinition implements EntityDefinition {
18 private Repository repository;
19
20 private String type;
21 // private String defaultEditorId;
22
23 public void init(BundleContext bundleContext, Map<String, String> properties) throws RepositoryException {
24 Session adminSession = CmsJcrUtils.openDataAdminSession(repository, null);
25 try {
26 type = properties.get(EntityConstants.TYPE);
27 if (type == null)
28 throw new IllegalArgumentException("Entity type property " + EntityConstants.TYPE + " must be set.");
29 // defaultEditorId = properties.get(EntityConstants.DEFAULT_EDITOR_ID);
30 // String definitionPath = EntityNames.ENTITY_DEFINITIONS_PATH + '/' + type;
31 // if (!adminSession.itemExists(definitionPath)) {
32 // Node entityDefinition = JcrUtils.mkdirs(adminSession, definitionPath, EntityTypes.ENTITY_DEFINITION);
33 //// entityDefinition.addMixin(EntityTypes.ENTITY_DEFINITION);
34 // adminSession.save();
35 // }
36 initJcr(adminSession);
37 } finally {
38 Jcr.logout(adminSession);
39 }
40 }
41
42 /** To be overridden in order to perform additional initialisations. */
43 protected void initJcr(Session adminSession) throws RepositoryException {
44
45 }
46
47 public void destroy(BundleContext bundleContext, Map<String, String> properties) throws RepositoryException {
48
49 }
50
51 // @Override
52 // public String getEditorId(Node entity) {
53 // return defaultEditorId;
54 // }
55
56 @Override
57 public String getType() {
58 return type;
59 }
60
61 protected Repository getRepository() {
62 return repository;
63 }
64
65 public void setRepository(Repository repository) {
66 this.repository = repository;
67 }
68
69 public String toString() {
70 return "Entity Definition " + getType();
71 }
72
73 }