This is actually two small web scripts, which between them allow you to select an Alfresco web project and fix up the metadata on all form generated assets, including renditions. I wrote it to allow me to reassociate assets with their forms after using CIFS to do an export and import of some sites I’ve been working on.
The functionality is similar to that provided by Uzi’s Web Project Tools AMP which isn’t yet building against 2.2, but rather than being Java-based uses the JavaScript API against the AVM – which should remain stable over time.
At the moment the script iterates through the site directory structure looking for any XML item not associated with a web form. Then, if a form with a matching root tag is found associated with the web project then the appropriate aspects and properties are added to the node and any existing renditions.
Unlike with the Web Project Tools AMP existing form metadata cannot be removed or repaired, but I quite like the simpleness of this approach. Adding the ability to do this would perhaps be useful, but would complicate the UI and wasn’t required for my purposes. I might add this later, in addition to the ability to preview the changes.
Right now it’s recommended to ensure the current user’s sandbox is empty before executing the script, so that you can easily undo all changes should your data get munged. The script has been tested against a couple of web projects that I have access to but as it has not yet had widespread testing it should be used with caution!
Note, you need to have a sandbox for the web project you want to repair. If you do not then the site will not show up in the initial list.
To install the web script extract the contents of the ZIP file somewhere in your web script package hierarchy, either on the classpath or inside the Data Dictionary – org/alfresco/wcm works for me. Remember you’ll need to reload Alfresco or at least refresh the list of web scripts to get Alfresco to pick it up.
Comments welcome!
Update: Thanks to Nancy for pointing me at the Developer Tools area of the Content Community – the code is also now available there.
Hello,
I have used your webscript. and it works fine. but it works onley when you have a prefix() in your form as rootelement. when you ditn’t have it() then are there a few problems.
webscript can not found rootelement of the form.
but we chances a few things in the repair-web-project.post.js.
firts we chance in the xmlGetRootElementName function the regular expression to var re = /0){
outputPath = “” + outputPath;
}
this becaus we go to check if the rootPrefix > 0 and the we create outputPath.
thanks Peter
Hi,
I met with described issue and it looks like this solution can help me. however the repair-web-project.zip link is dead and I can’t download the archive. Could you please check the link or email me this zip file.
Thank you,
Ivan
Hello,
I’m trying your webscript but I have a problem with Lucene search. The script find the associated forms with the web project, but when trying to find the web forms at this line :
var formResults = search.luceneSearch(“TYPE:wca\\:formfolder AND @cm\\:name:\”” + formname + “\””);
no forms are returned. If I try to execute this query in the node browser, in the workspace://SpacesStore, the query works fine and the requested web form is returned.
After a lot of search, I can’t find a solution to this problem.
Please can you help me?
Thanks.
Alexis
Same problems with Lucene search
We did follow your link and we are able to achieve our xml to webform association along with metadata extraction.
This is our use case
a) Using FTP client/java program to upload the XML content to AVM.
b) Associating the XML content to a pre configured web form.
c) Metadata extraction using aspects
d) Generate Renditions
As mentioned the renditions didnot work. Web form has been configured to have xml and html. Are we missing something or any further configuration required.
Please suggest.