javascript - copy content problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2007 11:19 AM
hi,
I've added some custom types to alfresco. one of them is 'Image' which adds some properties to to the regular 'Content' props.
I need to make a copy of that image (which is an 'Image' type) using javascript API.
I am using the copy method :
which works great - with one major problem - the copy is not just a copy of the image, but a full copy of the properties and type.
I need to make a copy of an image, that will not have the same type of the copied image…..
so, for example, if i have myPic.jpg which is an 'Image' type - i need to create copy of myPic.jpg which is a 'Content' type.
any ideas???
:shock:
thanks,
Dror
I've added some custom types to alfresco. one of them is 'Image' which adds some properties to to the regular 'Content' props.
I need to make a copy of that image (which is an 'Image' type) using javascript API.
I am using the copy method :
document.copy(currentFolder);
which works great - with one major problem - the copy is not just a copy of the image, but a full copy of the properties and type.
I need to make a copy of an image, that will not have the same type of the copied image…..
so, for example, if i have myPic.jpg which is an 'Image' type - i need to create copy of myPic.jpg which is a 'Content' type.
any ideas???
:shock:
thanks,
Dror
Labels:
- Labels:
-
Archive
8 REPLIES 8

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2007 05:41 AM
The JavaScript API supports modification of the object type and setting of various properties and aspects. You can either "specializeType()" the type using that API call and clear the properties you don't want or you can try creating a new object of the desired type (again all the APIs are there - see the examples) and then setting the content property of the destination object to a copy of the source object.
Thanks,
Kevin
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2007 07:18 AM
Hi Kevin,
I've tried using the "specializeType()" method you've suggested on my custom type (which inherits from "cm:content" type).
I've done this:
i've also tried this:
* the document that i copy is, of course, a custom-type content.
after running this java script, there is no change in the type of the copied content (typeChanged = false).
:?
am i doing anything wrong?
thanks,
Dror
I've tried using the "specializeType()" method you've suggested on my custom type (which inherits from "cm:content" type).
I've done this:
changeFile = document.copy(currentFolder);var typeChanged = changeFile.specializeType("cm:content");
i've also tried this:
var typeChanged = changeFile.specializeType("{http://www.alfresco.org/model/content/1.0}content");
* the document that i copy is, of course, a custom-type content.
after running this java script, there is no change in the type of the copied content (typeChanged = false).
:?
am i doing anything wrong?
thanks,
Dror
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2007 08:05 AM
I looked deeper into "specializeType" method and found that since it uses
"isSubClass" i will always get false. (since i want to convert a type to its parent's class type).
Is there any way to bypass this ?
:?:
Thanks,
Dror
"isSubClass" i will always get false. (since i want to convert a type to its parent's class type).
public boolean specializeType(String type) { ParameterCheck.mandatoryString("Type", type); QName qnameType = createQName(type); if (getType().equals(qnameType) == false && this.services.getDictionaryService().isSubClass(qnameType, getType()) == true) { this.nodeService.setType(this.nodeRef, qnameType); this.type = qnameType; return true; } return false; }
Is there any way to bypass this ?
:?:
Thanks,
Dror

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2007 04:36 AM
No at the moment i don't think there is. I'm not sure what the implication of converting a node from a type to a non-specialised type i.e. not a related type or one that has a sub-set of the properties - i'll try and find out.
Thanks,
Kevin
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2007 07:13 AM
thanks Kevin.
I need to convert the copy of a specific content to another type since in my application i query by type and i don't want to get duplicated results just because i have a copy of a content.
the copy is used to create a thumbnail for every image in the CMS, and if it'll be of the same type it will return in the query as well.
this is why i must convert that copy to a basic type.
hope i made it clear.
:roll:
Best regards ,
Dror
I need to convert the copy of a specific content to another type since in my application i query by type and i don't want to get duplicated results just because i have a copy of a content.
the copy is used to create a thumbnail for every image in the CMS, and if it'll be of the same type it will return in the query as well.
this is why i must convert that copy to a basic type.
hope i made it clear.
:roll:
Best regards ,
Dror
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 09:48 AM
Hi Kevin,
I try to set the content property of the destination object to a copy of the source object using xxx.content = document.content.
For images, Binary thats does not work. Any other way to do that?
The JavaScript API supports modification of the object type and setting of various properties and aspects. You can either "specializeType()" the type using that API call and clear the properties you don't want or you can try creating a new object of the desired type (again all the APIs are there - see the examples) and then setting the content property of the destination object to a copy of the source object.
I try to set the content property of the destination object to a copy of the source object using xxx.content = document.content.
For images, Binary thats does not work. Any other way to do that?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2007 01:51 AM
Hi,
One more Q,
I notice the write function in java script API. The wiki say:
Does the 2.1 Enterprise version is different from 2.1 Community version?
Thx,
Itay
One more Q,
I notice the write function in java script API. The wiki say:
write(ScriptContent content)
Copy the content from the specified ScriptContent (sorry, available from 2.1 Enterprise onwards).
Does the 2.1 Enterprise version is different from 2.1 Community version?
Thx,
Itay

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2007 07:06 AM
This function only made it in after 2.1 Community release - however it has already been merged into the community HEAD code stream so is available in public SVN or a nightly build download.
Thanks,
Kevin
Thanks,
Kevin
