private static Log log = ExoLogger.getLogger("ext.AddMetadataAction");
public boolean execute(Context ctx) throws Exception
{
PropertyImpl property = (PropertyImpl)ctx.get("currentItem");
NodeImpl parent = (NodeImpl)property.getParent();
if (!parent.isNodeType("nt:resource"))
throw new Exception("incoming node is not nt:resource type");
InputStream data = null;
String mimeType;
try
{
if (property.getInternalName().equals(Constants.JCR_DATA))
{
data = ((TransientPropertyData)property.getData()).getValues().get(0).getAsStream();
try
{
mimeType = parent.getProperty("jcr:mimeType").getString();
}
catch (PathNotFoundException e)
{
return false;
}
}
else if (property.getInternalName().equals(Constants.JCR_MIMETYPE))
{
mimeType = property.getString();
try
{
PropertyImpl propertyImpl = (PropertyImpl)parent.getProperty("jcr:data");
data = ((TransientPropertyData)propertyImpl.getData()).getValues().get(0).getAsStream();
}
catch (PathNotFoundException e)
{
return false;
}