@Property
@Deprecated
public String getKeyword(){
return getKeywords()[0];
}
public void setKeyword(String keyword) {
setKeywords(new String[]{keyword, “”});
}
@Property
@Deprecated
public String getSecondaryKeyword(){
return getKeywords()[1];
}
public void setSecondaryKeyword(String keyword) {
setKeywords(new String[]{“”, keyword});
}
@Property
public String[] getKeywords() {...}
public void setKeywords(String[] keywords) {...}
public static void upgradeContent(String fromVersion,
Node[] nodes) throws
IncompatibeUpdateException {
if (fromVersion.compareTo(“1.1”) != 0) {
String msg = “This update requires 1.1. “;
msg += “Current WCBPlugin version is “ + fromVersion;
throw new IncompatibeUpdateException(msg);
} else {
updateKeywords(nodes);
}
}
public static void updateKeywords(Node[] nodes) {
for (int i=0; i<nodes.length;i++) {
String pKeyword = nodes[i].getProperty("keyword").getString();
String sKeyword = nodes[i].getProperty("secondaryKeyword").getString();
String[] keywords = new String[]{pKeyword, sKeyword};
nodes[i].setProperty(“keywords”, keywords);
}
nodes[0].getSession().save();
}
|