use of com.emc.storageos.db.client.upgrade.CustomMigrationCallback in project coprhd-controller by CoprHD.
the class CollectionChangeTracker method isUpgradable.
public boolean isUpgradable() {
boolean returnVal = true;
if (!removedList.isEmpty()) {
for (T schema : removedList) {
// CustomMigrationCallback can be removed
if (clazz.equals(AnnotationType.class)) {
AnnotationType at = (AnnotationType) schema;
// type associated with it. Do string comparison instead.
if (CustomMigrationCallback.class.getCanonicalName().equals(at.getType())) {
log.info("CustomMigrationCallback {} has been removed", at.describe());
continue;
} else if (EnumType.class.getCanonicalName().equals(at.getType())) {
log.info("EnumType {} has been removed", at.describe());
continue;
}
if (at.canBeIgnore()) {
continue;
}
}
log.warn("An unsupported schema change has been made. {} has been removed.", schema.describe());
returnVal = false;
}
}
if (!duplicateList.isEmpty()) {
for (T schema : duplicateList) {
log.warn("An unsupported schema change has been made. Duplicate {} has been added", schema.describe());
}
returnVal = false;
}
for (S diff : diffs) {
if (!diff.isUpgradable()) {
returnVal = false;
}
}
if (clazz.equals(AnnotationType.class)) {
for (T element : newList) {
AnnotationType at = (AnnotationType) element;
Class cfClass = at.getCfClass();
// refuse adding any annotation (including index) on existing field
if (cfClass.isAnnotationPresent(DbKeyspace.class)) {
DbKeyspace keyspaceType = (DbKeyspace) cfClass.getAnnotation(DbKeyspace.class);
if (DbKeyspace.Keyspaces.GLOBAL.equals(keyspaceType.value())) {
log.warn("An unsupported geo schema change has been made. {} has been added", at.describe());
returnVal = false;
break;
}
}
// check UpgradeAllowed annotation for new annotations
if (!CustomMigrationCallback.class.isAssignableFrom(at.getAnnoClass()) && !at.getAnnoClass().isAnnotationPresent(UpgradeAllowed.class)) {
log.warn("An unsupported schema change has been made. {} has been added", at.describe());
returnVal = false;
break;
}
}
}
return returnVal;
}
Aggregations