This discussion is archived
1 Reply Latest reply: Jul 15, 2010 2:29 AM by frank.closheim RSS

Moving documents

user8726358 Newbie
Currently Being Moderated
Hi all

I have folowing problem. When I save documents in content db I create folders according to atributtes added to category.
For example I have category TEST with Attribute 1, Attribute 2, Attribute 3. So when I add document to content db I create following folders:

Attribute 1 value/Attribute 2 value/Attribute 3 value/name_of_file.jpg

Now when user changes any of those attributes in our application I have to move file in content DB to different folders (to match new attribute values). And here is the problem I try the following code:


Item sandbox = fManager.resolvePath(destinationPath,null);

NamedValueSet valueSet = new NamedValueSet();

valueSet.setNamedValues(
          new NamedValue[] {
          // folder to upload the document to
          ClientUtils.newNamedValue(Options.DESTFOLDER, new Long(sandbox.getId()))           
          }     
);

fManager.move(docIds, null, new NamedValueSet[]{valueSet} );     
     
and I get Invalid Parameters exeption. The same results with fManager.move(docIds, new NamedValue[0], new NamedValueSet[]{valueSet} ); The problem is probably in the second parameter workflow params but I dont need any workflow. I just need to simply move files.

Or maybe there is simpler way to accomplish scenario above without creating folders. Maybe it is possible to create some kind of "VIEW" that
will show documents in content DB in some hierarchy according to category attributes ?

Thank You in advance
  • 1. Re: Moving documents
    frank.closheim Newbie
    Currently Being Moderated
    Hi,

    I think I don't need to understand why your are storing the files in a folder structure based on the attributes assigned to the file. This makes absolutely no sense to me, but maybe you have a good business case for this.

    - Do you have the full stack of your exception client side and from the application.log server side?
    - Is there any workflow configuration on your sandbox folder? Or inherited from any parent of the sandbox folder?

    Several options here:
    1. You could have one physical location of your files, totally unrelated to attributes and create links in your attribute folders to those files. Then if an attribute changes, you only need to move the link. This would give you a kind of virtual view of your files. But this makes only sense if you have the same attribute values on multiple files.

    2. Use a different neutral folder structure and search for the docs by attributes instead of navigating to them.

    3. Try this code:

    Item sandbox = fManager.resolvePath(destinationPath,null);

    NamedValueSet[] valueSet = new NamedValueSet[] {
    CommonUtils.newNamedValueSet( new NamedValue[] {
    ClientUtils.newNamedValue(Options.DESTFOLDER, new Long(sandbox.getId()))
    })
    };

    fManager.move(new long[]{doc.getId()},null, valueSet);

    Regards,
    Frank

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points