return false;
}
try {
Image img = null;
try {
if (source instanceof byte[]) {
byte[] data = (byte[]) source;
MagicMatch match = Magic.getMagicMatch(data);
String mimeType = match.getMimeType();
if (keyAndClass != null) {
img = (Image) ImageHelper.createFile(securityContext, data, mimeType, keyAndClass.getCls());
} else {
ImageHelper.setImageData((Image) currentObject, data, mimeType);
}
} else if (source instanceof String) {
String sourceString = (String) source;
if (StringUtils.isNotBlank(sourceString)) {
if (keyAndClass != null) {
// UUID?
if (sourceString.length() == 32) {
img = (Image) ImageHelper.transformFile(securityContext, sourceString, keyAndClass != null ? keyAndClass.getCls() : null);
}
if (img == null) {
img = (Image) ImageHelper.createFileBase64(securityContext, sourceString, keyAndClass != null ? keyAndClass.getCls() : null);
}
} else {
ImageHelper.decodeAndSetFileData((Image) currentObject, sourceString);
}
}
}
} catch (Throwable t) {
logger.log(Level.WARNING, "Cannot create image node from given data", t);
}
if (img != null) {
// manual indexing of UUID needed here to avoid a 404 in the following setProperty call
img.updateInIndex();
currentObject.setProperty(keyAndClass.getPropertyKey(), img);
}
} catch (Throwable t) {