cancel
Showing results for 
Search instead for 
Did you mean: 

[Resolved] : Duplicate child name not allowed

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi

I am working on file uploading program on Alfresco server using webservices API.
This program is working fine for uploading diffrent file. But when i try to upload the same file second time, it is thowing the following exception

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed: Formtek_Alfresco.pdf</ns1:message>
   {http://xml.apache.org/axis/}exceptionNameSmiley Surprisedrg.alfresco.repo.webservice.repository.RepositoryFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.repository.RepositoryWebService.update(RepositoryWebService.java:518)
   at sun.reflect.GeneratedMethodAccessor527.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Thread.java:595)

   {http://xml.apache.org/axis/}hostnameSmiley FrustratedJP1-184217


   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
   at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
   at org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
   at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
   at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
   at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
   at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
   at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
   at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.update(RepositoryServiceSoapBindingStub.java:986)
   at org.alfresco.sample.webservice.NEBContentReadAndWrite.createContent(NEBContentReadAndWrite.java:241)
   at org.alfresco.sample.webservice.NEBContentReadAndWrite.upload(NEBContentReadAndWrite.java:124)
   at org.alfresco.sample.webservice.NEBContentReadAndWrite.main(NEBContentReadAndWrite.java:88)

Regards
Nishant Chauhan
3 REPLIES 3

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi All

I resolved this.I added versioning aspect to the file.

Regards
Nishant

mayanksahai
Champ in-the-making
Champ in-the-making
Hi ,

i am encountering the same issue . i did add the versioning aspect to my file but still error is same.
i am performing steps :

1) generate 30 unique file names: mayank_0 , mayank_1….
2) create these files in alfresco repository ——– creation works fine.
3) try to recreate files —- search for any file with same name – delete the file – recreate..

code is :

       // create parent reference
         ParentReference companyHomeParent = new ParentReference(STORE, null,
                                                         "/app:company_home/cm:TaxPlanning",  Constants.ASSOC_CONTAINS, "{" +
                                                         Constants.NAMESPACE_CONTENT_MODEL + "}" + "name");
         NamedValue[] contentProps = new NamedValue[3];
         NamedValue[] titledProps = new NamedValue[2];
         CML cml = new CML();
         Query query1 = new Query();
         for(String fileName : files){
          // Assign name to children
          companyHomeParent.setChildName("{http://www.alfresco.org/model/content/1.0}" + fileName);
          //
          ContentFormat contentFormat = new ContentFormat("Adobe PDF Document", "UTF-8");
          contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
          contentProps[1] = Utils.createNamedValue(Constants.PROP_CONTENT,
                                                       ContentFormat.getMimetype());
          contentProps[2] = Utils.createNamedValue(Constants.PROP_USER_ORGID, customerId);
          //Construct CML statement to add titled aspect
          titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, fileName);
          titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "Document for
                                                                                           customer");
         
          CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, contentProps,
                         null, "1");
          // query to search for existing file with same name
          query1 = new Query(Constants.QUERY_LANG_LUCENE,
                                         "PATH:\"app:company_home/cm:TaxPlanning/cm:" + fileName + "\"");
          ResultSet rs =service.query(STORE, query1, false).getResultSet();
          // file already exist, then, delete it and create a new one
          if(rs.getTotalRowCount() > 0){
             System.out.println("file found ::" + fileName);
             ResultSetRow[] rsRows = rs.getRows();
             System.out.println("Removing file " + rsRows[0].getColumns(3).getValue()); //show file name
             Reference reference = new Reference(STORE, rsRows[0].getNode().getId(), null);
             System.out.println("removing reference" + rsRows[0].getNode().getId());
             Predicate predicate = new Predicate(new Reference[]{reference}, null, null);
             CMLDelete delete = new CMLDelete(predicate);
             cml.setDelete(new CMLDelete[] {delete});
             service.update(cml); ————— EXCEPTION COMES HERE – DUPLICATE CHILD NAME NOT
                                ALLOWED.
          }
          logger.log(Level.INFO, "creating new content from scratch");
          //create content
          // Construct CML statement to create content node
          // Note: Assign "1" as a local id, so we can refer to it in subsequent
          // CML statements within the same CML block
          CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
          // Construct CML Block
          cml = new CML();
          cml.setAddAspect(new CMLAddAspect[] {addAspect});
          cml.setCreate(new CMLCreate[] {create});
          // Issue CML statement via Repository Web Service and retrieve result
          // Note: Batching of multiple statements into a single web call
          UpdateResult[] result = service.update(cml);
          Reference content = result[0].getDestination();

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi mayank

I didn't go through your code. I think you didn't  use checkout/checkin concept here . Just Follow these steps which i am using—

1: get your file Reference object inwhich you want to add versioning aspect and repositoryService object like this–
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

2: pass this file Reference object and repositoryService object to makeVersionable method–
makeVersionable(RepositoryServiceSoapBindingStub repositoryService, Reference fileRef);

3: then checkout the file. When you will do checkout then Alfresco will create a working copy of the original file

4: get the working copy Reference

5: get the Input stream from the file object and pass this object to convertToByteArray method like this—-
byte[] bytes=ContentUtils.convertToByteArray(stream);

6:then update the content of the working copy using contentService.write(—)

7: then checkin

Hope it'll help.

Regards
Nishant