cancel
Showing results for 
Search instead for 
Did you mean: 

How to get versions of wbecontent?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I want to know how can i

1. Create a versioned web content with different versions in a web project so that every time  i update content, it creates new version in web project & same is shown in properties of content? I tried like this but of little use


serviceRegistry.getAVMService().createFile(lsWebProjectPath, lsFileName).close();
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(2, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, lsFileName);
titledProps.put(ContentModel.PROP_DESCRIPTION, lsFileName);
serviceRegistry.getNodeService().addAspect(loFileNodeRef,   ContentModel.ASPECT_TITLED, titledProps);
//Adding versionable aspect      
Map<QName, Serializable> loVersionProps = new HashMap<QName, Serializable>();
loVersionProps.put(ContentModel.ASPECT_VERSIONABLE, true);
loVersionProps.put(ContentModel.PROP_AUTO_VERSION, true);
loVersionProps.put(ContentModel.PROP_VERSION_LABEL, VersionType.MINOR);
serviceRegistry.getNodeService().addAspect(loFileNodeRef, ContentModel.ASPECT_VERSIONABLE,loVersionProps);
serviceRegistry.getAVMService().addAspect(lsFilePath, ContentModel.ASPECT_VERSIONABLE);      

2. Access all these versions in a web project?

Please help.
6 REPLIES 6

dynamolalit
Champ on-the-rise
Champ on-the-rise
Any HELP Please!!  :idea:

Anyone from Forums or Alfresco team? :roll:

dpqmw80
Champ in-the-making
Champ in-the-making
From where i can get the latest version of Alfresco webcontent?

dynamolalit
Champ on-the-rise
Champ on-the-rise
I tried with this but when i am trying to update same content again; either it is updating content inside same file or throw exception :File already exists


if(loAvmNodeDescriptor == null) {//Creating new content
         if (logger.isDebugEnabled())
            logger.debug("Creating new content");
         
         //serviceRegistry.getAVMService().createFile(lsWebProjectPath, lsFileName).close();
         NodeRef loFileNodeRef = AVMNodeConverter.ToNodeRef(-1, lsFilePath);
         Integer lIFirst = AVMNodeConverter.ToAVMVersionPath(loFileNodeRef).getFirst();
         String lsVersionPath = AVMNodeConverter.ToAVMVersionPath(loFileNodeRef).getSecond();               
         
         Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(1, 1.0f);
         
         List<QName> aspects = new ArrayList<QName>(4);
         aspects.add(ContentModel.ASPECT_TITLED);         
         aspects.add(ContentModel.ASPECT_VERSIONABLE);         
         serviceRegistry.getAVMService().createFile(lsWebProjectPath, lsFileName,
               new ByteArrayInputStream((lsFileContent == null ? "" : lsFileContent).getBytes("UTF-8")),
                     aspects,
                     props);         
                  
         loAvmNodeDescriptor = serviceRegistry.getAVMService().lookup(-1, lsFilePath,false);
         
         if (logger.isDebugEnabled()) {
            logger.debug("loAvmNodeDescriptor : "+loAvmNodeDescriptor);
            logger.debug("loAvmNodeDescriptor getGuid : "+loAvmNodeDescriptor.getGuid());
            logger.debug("loAvmNodeDescriptor getId : "+loAvmNodeDescriptor.getId());
            logger.debug("loAvmNodeDescriptor getIndirection : "+loAvmNodeDescriptor.getIndirection());
            logger.debug("loAvmNodeDescriptor getIndirectionVersion : "+loAvmNodeDescriptor.getIndirectionVersion());
            logger.debug("loAvmNodeDescriptor getLayerID : "+loAvmNodeDescriptor.getLayerID());
            logger.debug("loAvmNodeDescriptor getVersionID : "+loAvmNodeDescriptor.getVersionID());
         }
         List loVerList = serviceRegistry.getAVMService().getHistory(loAvmNodeDescriptor, -1);
         ListIterator lstItr = loVerList.listIterator();
         while(lstItr.hasNext()) {
            if (logger.isDebugEnabled())
               logger.debug("lstItr : "+lstItr.next());
         }
      }else{ .. }

Alos i looked into org.alfresco.web.bean.wcm.CreateWebContentWizard & tried to implement as below with AVMDifference


List<AVMDifference> diffList = new ArrayList<AVMDifference>(4);
diffList.add(new AVMDifference(-1, lsVersionPath, -1, AVMUtil.getCorrespondingPathInMainStore(lsVersionPath), AVMDifference.NEWER));
serviceRegistry.getAVMSyncService().update(diffList, null, true, true, true, true, null, null);
loAvmNodeDescriptor = serviceRegistry.getAVMService().lookup(-1, lsFilePath,false);

But of little help. Running out of ideas.

dynamolalit
Champ on-the-rise
Champ on-the-rise
Any hep..any clue..not getting how it stores versions internally as i could not find anything relevant  in either of user/preview/other stores of a web project? Only file with -1 version is available but nowhere i can see file with other versions.

I can see only following node in node browser


http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin/-1;www;avm_webapps;ROOT;asdasdsadasdasd....

But none of these:


http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin/11;www;avm_webapps;ROOT;asdasdsadasdasd....

http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin--preview/4;www;avm_webapps;ROOT;asdasdsa...

http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin--preview/3;www;avm_webapps;ROOT;asdasdsa...

http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin/5;www;avm_webapps;ROOT;asdasdsadasdasd.h...

http://localhost:8080/alfresco/d/d/avm/WCDesignerDNS--admin--preview/2;www;avm_webapps;ROOT;asdasdsa...

Does alfresco wcm generate versions of web content on fly only for web content created thru web forms but versioning not allowed for any other content added using  "Add Content" action link or thru web script or any other mean?

Confused of this behavior.  :? Any confirmation?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Anyone there to help out on how to create version of a web content in a web project in alfresco??

mitchellnickie
Champ in-the-making
Champ in-the-making
I hope somebody will post about this topic 'cause i want to know about the solution as well.