use of org.openmrs.api.InvalidFileTypeException in project openmrs-core by openmrs.
the class FormServiceImpl method saveFormResource.
/**
* @see org.openmrs.api.FormService#saveFormResource(org.openmrs.FormResource)
*/
@Override
public FormResource saveFormResource(FormResource formResource) throws APIException {
if (formResource == null) {
return null;
}
// If a form resource with same name exists, replace it with current value
FormResource toPersist = formResource;
FormResource original = Context.getFormService().getFormResource(formResource.getForm(), formResource.getName());
if (original != null) {
original.setName(formResource.getName());
original.setValue(formResource.getValue());
original.setDatatypeClassname(formResource.getDatatypeClassname());
original.setDatatypeConfig(formResource.getDatatypeConfig());
original.setPreferredHandlerClassname(formResource.getPreferredHandlerClassname());
toPersist = original;
}
try {
CustomDatatypeUtil.saveIfDirty(toPersist);
} catch (ConstraintViolationException ex) {
throw new InvalidFileTypeException(ex.getMessage(), ex);
}
return dao.saveFormResource(toPersist);
}
Aggregations