org.alfresco.wcm.sandbox.script
Class Asset

java.lang.Object
  extended by org.alfresco.wcm.sandbox.script.Asset
All Implemented Interfaces:
java.io.Serializable

public class Asset
extends java.lang.Object
implements java.io.Serializable

WCM Asset in a sandbox exposed over Java Script API.

See Also:
Serialized Form

Constructor Summary
Asset(Sandbox sandbox, AssetInfo asset)
           
 
Method Summary
 void createFile(java.lang.String name, java.lang.String stringContent)
          create a new file with the specified properties and content.
 void createFolder(java.lang.String name)
          create a new folder
 void deleteAsset()
          Delete this asset, after it has been deleted do not use this asset.
 Asset[] getChildren()
          Get children of this asset, returns an empty array if there are no children.
 java.lang.String getContent()
          Returns textual representation of the Asset content
 java.util.Date getCreatedDate()
           
 java.lang.String getCreatedDateAsISO8601()
           
 java.lang.String getCreator()
          The creator of this asset
 long getFileSize()
           
 java.util.Date getModifiedDate()
           
 java.lang.String getModifiedDateAsISO8601()
           
 java.lang.String getModifier()
           
 java.lang.String getName()
           
 java.lang.String getPath()
          Get the full path of this asset eg.
 java.util.Map getProperties()
          Get the properties as a key value pair.
 Sandbox getSandbox()
          Get the parent sandbox which contains this asset
 int getVersion()
           
 boolean isDeleted()
           
 boolean isFile()
           
 boolean isFolder()
           
 boolean isLocked()
           
 java.lang.String lockOwner()
           
 Asset move(java.lang.String newPath)
          move this asset
 Asset rename(java.lang.String newName)
          rename this asset
 void revert()
          revert this asset
 void save()
          Save the properties please note some system properties are protected and cannot be updated.
 void setProperties(java.lang.Object nativeProperties)
           
 void submit(java.lang.String submitLabel, java.lang.String submitComment)
          Submit this asset to staging
 boolean writeContent(org.springframework.extensions.surf.util.Content content)
          Updates a content of the current Asset
 boolean writeContent(java.lang.String content)
          Updates a content of a current Asset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Asset

public Asset(Sandbox sandbox,
             AssetInfo asset)
Method Detail

getCreator

public java.lang.String getCreator()
The creator of this asset

Returns:
the creator

getCreatedDate

public java.util.Date getCreatedDate()

getFileSize

public long getFileSize()

getCreatedDateAsISO8601

public java.lang.String getCreatedDateAsISO8601()

getModifier

public java.lang.String getModifier()

getModifiedDate

public java.util.Date getModifiedDate()

getModifiedDateAsISO8601

public java.lang.String getModifiedDateAsISO8601()

rename

public Asset rename(java.lang.String newName)
rename this asset

Parameters:
newName -

move

public Asset move(java.lang.String newPath)
move this asset

Parameters:
newPath -

getName

public java.lang.String getName()

getPath

public java.lang.String getPath()
Get the full path of this asset eg. /www/avm_webapps/ROOT/myFile.jpg

Returns:
the path of this asset.

isFile

public boolean isFile()

isFolder

public boolean isFolder()

isDeleted

public boolean isDeleted()

isLocked

public boolean isLocked()

lockOwner

public java.lang.String lockOwner()

getVersion

public int getVersion()

getProperties

public java.util.Map getProperties()
Get the properties as a key value pair. The key will be either a local qname e.g. "cm:content" or a global qname e.g. "{http://www.alfresco.com/content/1.0}content". Some properties will be updatable, protected properties are not.

Returns:
the properties in a key, value pair

save

public void save()
Save the properties please note some system properties are protected and cannot be updated. If you attempt to update a protected property your request will be ignored.

Parameters:
properties -

setProperties

public void setProperties(java.lang.Object nativeProperties)
                   throws org.json.JSONException
Parameters:
properties -
Throws:
org.json.JSONException

writeContent

public boolean writeContent(java.lang.String content)
Updates a content of a current Asset

Parameters:
content - String value which represents new textual content
Returns:
true if a content has been set without errors

writeContent

public boolean writeContent(org.springframework.extensions.surf.util.Content content)
Updates a content of the current Asset

Parameters:
content - a Content value which represents new content
Returns:
true if a content has been set without errors

getContent

public java.lang.String getContent()
                            throws org.alfresco.service.cmr.repository.ContentIOException,
                                   java.io.IOException
Returns textual representation of the Asset content

Returns:
content as a text
Throws:
org.alfresco.service.cmr.repository.ContentIOException
java.io.IOException

submit

public void submit(java.lang.String submitLabel,
                   java.lang.String submitComment)
Submit this asset to staging

Parameters:
submitLabel -
submitComment -

deleteAsset

public void deleteAsset()
Delete this asset, after it has been deleted do not use this asset.


revert

public void revert()
revert this asset


getChildren

public Asset[] getChildren()
Get children of this asset, returns an empty array if there are no children. Only folders have children.


createFile

public void createFile(java.lang.String name,
                       java.lang.String stringContent)
create a new file with the specified properties and content.

Parameters:
name - the name of the file
stringContent - the content of the file. Can be null.

createFolder

public void createFolder(java.lang.String name)
create a new folder

Parameters:
name - the name of the new folder

getSandbox

public Sandbox getSandbox()
Get the parent sandbox which contains this asset

Returns:
the parent sandbox which contains this asset


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.