if (content instanceof XMLObject) {
entry.setContentAsXhtml(content.toString());
} else if (content instanceof String) {
entry.setContent(content.toString());
} else {
throw new ScriptException("Unsupported Content");
}
// process contributor
Object contributorProperty = ScriptableObject.getProperty(
nativeObject, "contributor");
if (contributorProperty instanceof String) {
entry.addContributor(contributorProperty.toString());
}
Object contributorsProperty = ScriptableObject.getProperty(
nativeObject, "contributors");
if (contributorsProperty instanceof NativeArray) {
NativeArray contributorsPropertyArray = (NativeArray) contributorsProperty;
for (Object o1 : contributorsPropertyArray.getIds()) {
int index = (Integer) o1;
String name = contributorsPropertyArray
.get(index, null).toString();
entry.addContributor(name);
}
}
// process id
Object idProperty = ScriptableObject.getProperty(nativeObject,
"id");
if (idProperty instanceof String) {
entry.setId((String) (idProperty));
} else {
entry.setId(FOMHelper.generateUuid());
}
// process link
// TODO link object
Object linkProperty = ScriptableObject.getProperty(
nativeObject, "link");
if (linkProperty instanceof String) {
entry.addLink((String) (linkProperty));
}
Object linksProperty = ScriptableObject.getProperty(
nativeObject, "links");
if (linksProperty instanceof NativeArray) {
NativeArray linksPropertyArray = (NativeArray) contributorsProperty;
for (Object o1 : linksPropertyArray.getIds()) {
int index = (Integer) o1;
String name = linksPropertyArray.get(index, null)
.toString();
entry.addLink(name);
}
}
// process published
// TODO handle javascript date
Object publishedProperty = ScriptableObject.getProperty(
nativeObject, "published");
if (publishedProperty instanceof String) {
if (publishedProperty.equals("now")) {
entry.setPublished(new Date(System.currentTimeMillis()));
} else {
entry.setPublished(publishedProperty.toString());
}
}
// process rights
Object rights = ScriptableObject.getProperty(nativeObject,
"rights");
if (rights instanceof XMLObject) {
entry.setRightsAsXhtml(rights.toString());
} else if (rights instanceof String) {
entry.setRights(rights.toString());
}
// process summary
Object summary = ScriptableObject.getProperty(nativeObject,
"summary");
if (summary instanceof XMLObject) {
entry.setSummaryAsXhtml(summary.toString());
} else if (summary instanceof String) {
entry.setSummary(summary.toString());
}
// process title
Object title = ScriptableObject.getProperty(nativeObject,
"title");
if (title instanceof XMLObject) {
entry.setTitleAsXhtml(title.toString());
} else if (title instanceof String) {
entry.setTitle(title.toString());
} else {
throw new ScriptException("An Entry MUST have a title.");
}
// process updated
Object updated = ScriptableObject.getProperty(nativeObject,
"updated");
if (updated instanceof String) {
if (updated.equals("now")) {
entry.setUpdated(new Date(System.currentTimeMillis()));
} else {
entry.setUpdated((String) updated);
}
}
} catch (IRISyntaxException e) {
throw new ScriptException(e);
}
} else if (!(entryObject instanceof EntryHostObject)) {
throw new ScriptException("Invalid parameter");
}
// log.info("New Added Entry" + entry);
}