cancel
Showing results for 
Search instead for 
Did you mean: 

Ask for Type and Aspects on File Upload (and delete on cancel)

djsumdog
Champ in-the-making
Champ in-the-making
So I'm working on a project with pretty specific client requirements. They want a document that, once uploaded, is automatically given a custom content model (which I've already made) and then, immediately after upload, allow the user to select aspects to add to it. If the user cancels out of the aspect selection, the document needs to be deleted.

We have a full Maven space setup for alfresco and share development and have our standard-document.xml in alfresco/src/main/resource/alfrescco/extension/model and I can choose this model in the share interface. I realize I can setup a space to automatically give all uploaded documents a specific type, but I'm more concerted about the aspects and deleting the document on cancellation.

The question I have is, where in my share environment do I start working on this process? Would it be best to make a custom dashlet that deals with the upload process, or is there some class or function I can rewire within the Slingshot/Spring Application Context. I couldn't find any existing plugins or share amp files that I could use as a reference. Is there anything out there that currently has something similar to this functionality?
2 REPLIES 2

zladuric
Champ on-the-rise
Champ on-the-rise
Here are a couple of thoughts. I have been working on a custom site logo upload script (per site), which has, in a manner, a similar requirement.
What I did was the following:
- on the client side (dashlet client-side javascript), I used Alfresco's file upload.
- When you fire a file upload dialog, you define a callback listener (ie:
onFileUploadComplete: this.myListener
).
- I've set a destination to a temporary folder - I guess you can setup an additional site container, like a "temporary" document library. (on the repo:
var conainer = site.createContainer('unassignedDocuments');
).
- back to the share clientside, on my callback listener (myListener), I've hooked an additional call to backend webscript, which took the nodeRef of the newly uploaded file (<strong>response.successful[]</strong> is an array of uploaded docs)

My guess would be that your onFileUploadComplete listener should:
- open up an instance of YUI Panel (
Alfresco.util.createYUIPanel
or any kind of panel, for that manner.
- display a list of uploaded documents (from the response.successful array, there are few useful information, like nodeRef, name etc).
- have the user select one and then select aspects from a dropdown or similar
- when the user confirms aspects, do another Ajax call to repository to a webscript which sets custom aspects and move the doc to the document library
- if the user cancels, take another Ajax call or set of calls to standard backend DELETE nodeRef for the remaining docs
- also, run a hourly/daily/whatever scheduled cleanup task for the temporary container. Make it delete any doc older then an hour and in your custom container. That is in case somebody just closed the browser after upload so the files remained hanging. And 1 hour is because if the user uploaded docs, he is on the "select aspects" screen, right? And if he didn't select anything after one hour, his session expired anyway, so he won't be able to get them documents anyway.

Anyway, that is something to start with, I hope. Ask if you have any more questions.

zladuric
Champ on-the-rise
Champ on-the-rise
Another thought - if you want this for ANY uploaded document, then maybe extend the client-side file uploader? Which will offer the user aspects selection for any uploaded file, instead of just showing green upload progress bars and count of successful documents?

And not make the temporary container, but make a "temporary" aspect, which you set on any uploaded doc (override backend upload handler/webscript) so you can have scheduled task look for anything older then the session time + temporary aspect?

That way you can upload anywhere in the document library and not worry if the user has set the aspect?

There are a lot of posibilities.