cancel
Showing results for 
Search instead for 
Did you mean: 

Adding or Creating and deleting Content

aashishraj24
Champ in-the-making
Champ in-the-making
Hi,

I am a new user in alfresco .I want to add content as well as delete the content.Please help me accomplish this,how can i do this?
8 REPLIES 8

jpotts
World-Class Innovator
World-Class Innovator
Are you using Alfresco Explorer, Alfresco Share, some sort of file protocol (like FTP, IMAP, WebDAV, CIFS), or writing code to add and delete content?

Jeff

aashishraj24
Champ in-the-making
Champ in-the-making
Hi Jeff,

I am using Alfresco 4.0c community version i.e Alfresco Explorer.I want to add content like (text document or image ) and delete it using the webscript

aashishraj24
Champ in-the-making
Champ in-the-making
Hi Jeff,

I want to accomplish this  ASAP so that i can proceed further.

jpotts
World-Class Innovator
World-Class Innovator
It sounds like you are trying to upload content and delete content via web scripts. You might want to look at the Hello World examples from the Alfresco Developer Guide. One of the hello world examples shows how to do a form post and then how to persist that content from within the controller.

There is also a free tutorial on web scripts that I wrote a while back but is still applicable.

Packt offers several books on Alfresco including one by Ugo Cei called Alfresco 3 Web Services, which has a lot of content on web scripts.

In addition to web scripts, however, you might also consider using one of the Apache Chemistry APIs. Chemistry includes client-side APIs for Java, Python, PHP, and .NET and allows you to hit the Alfresco repository remotely to create, query, update, and delete content. The custom content types tutorial on ecmarchitect.com includes some Java-based CMIS examples that do this.

Jeff

aashishraj24
Champ in-the-making
Champ in-the-making
Hi Jeff,

That's really what i want.I want to delete the content by running the web script like what i did in creating the hello world web script.
Please help me going through this.as i am unable to find the way to delete the code through the web script.

Thankks and  Regards
Aashish Raj

jpotts
World-Class Innovator
World-Class Innovator
The hello world examples show you how to set up a web script. If you want to delete something from the repository, that code will live in your web script controller. You should look at the JavaScript API to see what you can do from within your web script controller.

For example, suppose you call a web script and pass in a node reference. You could do a search on that node reference and then delete the node, like this:
if (args.nodeRef == null || args.nodeRef.length == 0) {
   logger.log("Node ref arg not set");
   status.code = 400;
   status.message = "Node ref has not been provided";
   status.redirect = true;
} else {
   logger.log("Getting node");
   var curNode = search.findNode(args.nodeRef);   
   if (curNode == null) {
      logger.log("Node not found");
      status.code = 404;
      status.message = "No node found for node ref:" + args.nodeRef;
      status.redirect = true;
   } else {
      curNode.remove();
      model.nodeRef = args.nodeRef;
   }
}

Hope that helps.

Jeff

aashishraj24
Champ in-the-making
Champ in-the-making
Hello Jeff,

Thank you very much for the information,my requirement is that suppose i have created or added an image or some text file like "HELLO WORLD" through first of all writing the  hello world.get.desc.xml and then response is given through free-marker-template when we run the web script,what would be the exact number of steps and procedure i follow in order to delete the helloworld file or any image if i have added any.

Can u give me the exact procedure and steps to delete that content.

jpotts
World-Class Innovator
World-Class Innovator
I've given you examples on how to set up a web script and I've given you controller code that will delete an object given a node reference. I've also pointed you to the JavaScript API so that if this isn't exactly what you need, you can look at that documentation to determine an alternative way to code your controller.

That should be sufficient. If it isn't, then I must be misunderstanding what you are trying to do.

I'm happy to try to provide further assistance, but it would probably be more productive if you would tell me what you've tried and identify any specific questions you have.

Jeff