public class OxmModelValidator {
private static Logger logger = LoggerFactory.getInstance().getLogger(OxmModelValidator.class.getName());
-
+ private static final String OXM_LOAD_ERROR = "Error loading oxm model";
+
public enum Metadata {
NODE_TYPE("aai-node-type"),
URI("aai-uri"),
Map<String, Object> result = new HashMap<String, Object>();
if (jaxbContext == null) {
- logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, "Error loading oxm model: " + version);
- throw new CrudException("Error loading oxm model: " + version, Status.NOT_FOUND);
+ logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, OXM_LOAD_ERROR + ": " + version);
+ throw new CrudException(OXM_LOAD_ERROR + ": " + version, Status.NOT_FOUND);
}
- final DynamicType modelObjectType = jaxbContext.getDynamicType(
- CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type)));
+ final DynamicType modelObjectType = OxmModelLoader.getDynamicTypeForVersion(version, type);
final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames");
for (String key : filter.keySet()) {
}
if (jaxbContext == null) {
- logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, "Error loading oxm model: " + version);
- throw new CrudException("Error loading oxm model: " + version, Status.NOT_FOUND);
+ logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, OXM_LOAD_ERROR + ": " + version);
+ throw new CrudException(OXM_LOAD_ERROR + ": " + version, Status.NOT_FOUND);
}
// Determine if the Object part is a collection type in the model
// definition
- final DynamicType modelObjectType = jaxbContext.getDynamicType(
- CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type)));
+ final DynamicType modelObjectType = OxmModelLoader.getDynamicTypeForVersion(version, type);
if (modelObjectType == null) {
logger.error(CrudServiceMsgs.INVALID_OXM_FILE, "Object of collection type not found: " + type);
try {
type = resolveCollectionType(version, type);
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
- String modelObjectClass = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
- CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type));
- final DynamicType modelObjectType = jaxbContext.getDynamicType(modelObjectClass);
+ final DynamicType modelObjectType = OxmModelLoader.getDynamicTypeForVersion(version, type);
final DynamicType reservedType = jaxbContext.getDynamicType("ReservedPropNames");
Set<Map.Entry<String, JsonElement>> payloadEntriesSet = properties.getAsJsonObject().entrySet();
try {
type = resolveCollectionType(version, type);
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
- String modelObjectClass = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
- CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type));
-
- final DynamicType modelObjectType = jaxbContext.getDynamicType(modelObjectClass);
+
+ final DynamicType modelObjectType = OxmModelLoader.getDynamicTypeForVersion(version, type);
final DynamicType reservedType = jaxbContext.getDynamicType("ReservedPropNames");
Set<Map.Entry<String, JsonElement>> payloadEntriesSet = properties.getAsJsonObject().entrySet();
try {
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
- String modelObjectClass = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
- CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL,
- vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()) != null
- ? vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()).toString() : vertex.getType()));
- final DynamicType modelObjectType = jaxbContext.getDynamicType(modelObjectClass);
+
+ final DynamicType modelObjectType = OxmModelLoader.getDynamicTypeForVersion(version,
+ vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()) != null
+ ? vertex.getProperties().get(Metadata.NODE_TYPE.propertyName()).toString()
+ : vertex.getType());
final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames");
for (String key : vertex.getProperties().keySet()) {