05-30-2006 01:38 AM
NamespaceDAO namespaceDAO = new NamespaceDAOImpl();
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO);
DictionaryBootstrap bootstrap = new DictionaryBootstrap();
List<String> bootstrapModels = new ArrayList<String>();
bootstrapModels.add("alfresco/model/dictionaryModel.xml");
bootstrapModels.add("alfresco/model/systemModel.xml");
bootstrapModels.add("alfresco/model/contentModel.xml");
bootstrapModels.add("alfresco/model/applicationModel.xml");
bootstrapModels.add("alfresco/extension/customModel.xml");
bootstrap.setModels(bootstrapModels);
bootstrap.setDictionaryDAO(dictionaryDAO);
bootstrap.bootstrap();
[exec] 11:03:41,597 INFO [STDOUT] java.lang.NullPointerException
[exec] 11:03:41,597 INFO [STDOUT] at org.alfresco.jcr.item.PropertyImpl.checkSingleValued(PropertyImpl.java:630)
[exec] 11:03:41,597 INFO [STDOUT] at org.alfresco.jcr.item.PropertyImpl.setPropertyValue(PropertyImpl.java:509)
[exec] 11:03:41,597 INFO [STDOUT] at org.alfresco.jcr.item.NodeImpl.setProperty(NodeImpl.java:348)
[exec] 11:03:41,597 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor326.invoke(Unknown Source)
[exec] 11:03:41,607 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] 11:03:41,607 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
[exec] 11:03:41,607 INFO [STDOUT] at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:130)
[exec] 11:03:41,607 INFO [STDOUT] at $Proxy135.setProperty(Unknown Source)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.jsp.jsp.dam_005fpoc.assetCreate_jsp._jspService(org.apache.jsp.jsp.dam_005fpoc.assetCreate_jsp:183)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
[exec] 11:03:41,607 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
[exec] 11:03:41,607 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[exec] 11:03:41,607 INFO [STDOUT] at com.xpflow.admin.access.RequestServiceHandler.doFilter(RequestServiceHandler.java:69)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[exec] 11:03:41,607 INFO [STDOUT] at com.xpflow.admin.access.SessionServiceHandler.doFilter(SessionServiceHandler.java:133)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[exec] 11:03:41,607 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
[exec] 11:03:41,607 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
[exec] 11:03:41,607 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
[exec] 11:03:41,607 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
[exec] 11:03:41,607 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
[exec] 11:03:41,607 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
[exec] 11:03:41,617 INFO [XPFlowDBManager] Local JTA Transaction rolled back as it was
05-31-2006 04:52 PM
package org.alfresco.repo.dictionary;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
public class RegisterModel
{
/**
* @param args
*/
public static void main(String[] args)
throws Exception
{
// initialise application context
// Note: the dictionary bootstrap will take during this step
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
DictionaryService service = (DictionaryService)ctx.getBean(ServiceRegistry.DICTIONARY_SERVICE.getLocalName());
// retrieve type that does not yet exist via Dictionary Service
QName typeName = QName.createQName("newModelURI", "newType");
TypeDefinition typeDef = service.getType(typeName);
assert(typeDef == null);
// create new model and new type (this can also be parsed from XML definition)
M2Model model = M2Model.createModel("newModelPrefix:newModel");
M2Namespace importD = model.createImport("http://www.alfresco.org/model/dictionary/1.0", "d");
M2Namespace importSys = model.createImport("http://www.alfresco.org/model/system/1.0", "sys");
M2Namespace namespace = model.createNamespace("newModelURI", "newModelPrefix");
M2Type type = model.createType("newModelPrefix:newType");
type.setParentName("sys:base");
M2Property prop = type.createProperty("newModelPrefix:newProp");
prop.setType("d:text");
// register model programmatically (this is currently only possible via the Dictionary DAO)
DictionaryDAO dao = (DictionaryDAO)ctx.getBean("dictionaryDAO");
dao.putModel(model);
// retrieve type that's now been registered programmatically (via Dictionary Service)
typeDef = service.getType(typeName);
assert(typeDef != null);
// perform simple create of node with new type
Repository repository = (Repository)ctx.getBean("JCR.Repository");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
Node rootNode = session.getRootNode();
Node newNode = rootNode.addNode("test", "newModelPrefix:newType");
newNode.setProperty("newModelPrefix:newProp", "dave");
System.out.println(newNode.getProperty("newModelPrefix:newProp").getString());
System.exit(0);
}
}
04-16-2007 10:13 AM
<type name="dml:rsscontent">
<title>rsscontent</title>
<parent>cm:content</parent>
<properties>
<property name="rss:title">
<type>d:text</type>
</property>
<property name="rss:description">
<type>d:text</type>
</property>
<property name="rss:link">
<type>d:text</type>
</property>
<property name="rss:author">
<type>d:text</type>
</property>
</properties>
</type>
04-30-2007 06:12 AM
package org.alfresco.repo.dictionary;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
public class RegisterModel
{
/**
* @param args
*/
public static void main(String[] args)
throws Exception
{
// initialise application context
// Note: the dictionary bootstrap will take during this step
ApplicationContext context= ApplicationContextHelper.getApplicationContext();
DictionaryService service = (DictionaryService)context.getBean(ServiceRegistry.DICTIONARY_SERVICE.getLocalName());
// retrieve type that does not yet exist via Dictionary Service
QName typeName = QName.createQName("newModelURI", "newType");
TypeDefinition typeDef = service.getType(typeName);
assert(typeDef == null);
// create new model and new type (this can also be parsed from XML definition)
M2Model model = M2Model.createModel("newModelPrefix:newModel");
M2Namespace importD = model.createImport("http://www.alfresco.org/model/dictionary/1.0", "d");
M2Namespace importSys = model.createImport("http://www.alfresco.org/model/system/1.0", "sys");
M2Namespace namespace = model.createNamespace("newModelURI", "newModelPrefix");
M2Type type = model.createType("newModelPrefix:newType");
type.setParentName("sys:base");
M2Property prop = type.createProperty("newModelPrefix:newProp");
prop.setType("d:text");
// register model programmatically (this is currently only possible via the Dictionary DAO)
DictionaryDAO dao = (DictionaryDAO)context.getBean("dictionaryDAO");
dao.putModel(model);
// retrieve type that's now been registered programmatically (via Dictionary Service)
typeDef = service.getType(typeName);
assert(typeDef != null);
// perform simple create of node with new type
Repository repository = (Repository)context.getBean("JCR.Repository");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
Node rootNode = session.getRootNode();
Node newNode = rootNode.addNode("test", "newModelPrefix:newType");
newNode.setProperty("newModelPrefix:newProp", "dave");
setMimeType(context, newNode , MimetypeMap.MIMETYPE_TEXT_PLAIN);
System.out.println(newNode.getProperty("newModelPrefix:newProp").getString());
System.exit(0);
}
private static void setMimeType(ApplicationContext context, Node node,
String mimeType) throws RepositoryException {
System.out.println("mime");
// retrieve service registry
ServiceRegistry serviceRegistry = (ServiceRegistry) context
.getBean(ServiceRegistry.SERVICE_REGISTRY);
NodeService nodeService = serviceRegistry.getNodeService();
// convert the JCR Node to an Alfresco Node Reference
NodeRef nodeRef = JCRNodeRef.getNodeRef(node);
// retrieve the Content Property (represented as a ContentData object in Alfresco)
ContentData content = (ContentData) nodeService.getProperty(nodeRef,
ContentModel.PROP_CONTENT);
// update the Mimetype
content = ContentData.setMimetype(content, mimeType);
nodeService.setProperty(nodeRef, ContentModel.PROP_CONTENT, content);
}
} Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.