use of org.eclipse.che.api.core.factory.FactoryParameter.Version in project che by eclipse.
the class FactoryBuilder method checkValid.
/**
* Validate factory compatibility.
*
* @param factory
* - factory object to validate
* @param isUpdate
* - indicates is validation performed on update time.
* Set-by-server variables are allowed during update.
* @throws ConflictException
*/
public void checkValid(FactoryDto factory, boolean isUpdate) throws ConflictException {
if (null == factory) {
throw new ConflictException(FactoryConstants.UNPARSABLE_FACTORY_MESSAGE);
}
if (factory.getV() == null) {
throw new ConflictException(FactoryConstants.INVALID_VERSION_MESSAGE);
}
Version v;
try {
v = Version.fromString(factory.getV());
} catch (IllegalArgumentException e) {
throw new ConflictException(FactoryConstants.INVALID_VERSION_MESSAGE);
}
Class usedFactoryVersionMethodProvider;
switch(v) {
case V4_0:
usedFactoryVersionMethodProvider = FactoryDto.class;
break;
default:
throw new ConflictException(FactoryConstants.INVALID_VERSION_MESSAGE);
}
validateCompatibility(factory, null, FactoryDto.class, usedFactoryVersionMethodProvider, v, "", isUpdate);
}
Aggregations