Search in sources :

Example 1 with CDBFieldIsReadOnlyEx

use of alma.cdbErrType.CDBFieldIsReadOnlyEx in project ACS by ACS-Community.

the class HibernateWDALImpl method saveChanges.

/**
	 * Save changes given by map to the node identified by curl
	 *
	 * @param curl
	 * @param propertyMap
	 *
	 * @throws CDBXMLErrorEx
	 * @throws CDBExceptionEx
	 * @throws CDBFieldDoesNotExistEx
	 */
public void saveChanges(String curl, Map propertyMap) throws CDBXMLErrorEx, CDBExceptionEx, CDBFieldDoesNotExistEx, CDBRecordDoesNotExistEx {
    Object node = curl.length() == 0 ? rootNode : DOMJavaClassIntrospector.getNode(curl, rootNode);
    if (node == null || DOMJavaClassIntrospector.isPrimitive(node.getClass())) {
        AcsJCDBRecordDoesNotExistEx ex = new AcsJCDBRecordDoesNotExistEx();
        ex.setCurl(curl);
        m_logger.log(AcsLogLevel.NOTICE, "WDAL::saveChanges " + ex.getShortDescription());
        throw ex.toCDBRecordDoesNotExistEx();
    }
    boolean commit = false;
    Transaction tr = mainSession.beginTransaction();
    try {
        HibernateWDAOImpl wdao = new HibernateWDAOImpl(mainSession, curl, node, poa, m_logger, false, false);
        for (Object key : propertyMap.keySet()) {
            String propertyName = key.toString();
            wdao.set_field_data(propertyName, propertyMap.get(propertyName).toString());
        }
        commit = true;
    } catch (CDBFieldIsReadOnlyEx fne) {
        AcsJCDBExceptionEx cdbex = new AcsJCDBExceptionEx(fne);
        throw cdbex.toCDBExceptionEx();
    } catch (WrongCDBDataTypeEx fne) {
        AcsJCDBExceptionEx cdbex = new AcsJCDBExceptionEx(fne);
        throw cdbex.toCDBExceptionEx();
    } finally {
        if (commit)
            tr.commit();
        else
            tr.rollback();
    }
/// TODO revert memory state?!!!
}
Also used : AcsJCDBExceptionEx(alma.cdbErrType.wrappers.AcsJCDBExceptionEx) Transaction(org.hibernate.Transaction) CDBFieldIsReadOnlyEx(alma.cdbErrType.CDBFieldIsReadOnlyEx) AcsJCDBRecordDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx) AcsJWrongCDBDataTypeEx(alma.cdbErrType.wrappers.AcsJWrongCDBDataTypeEx) WrongCDBDataTypeEx(alma.cdbErrType.WrongCDBDataTypeEx)

Aggregations

CDBFieldIsReadOnlyEx (alma.cdbErrType.CDBFieldIsReadOnlyEx)1 WrongCDBDataTypeEx (alma.cdbErrType.WrongCDBDataTypeEx)1 AcsJCDBExceptionEx (alma.cdbErrType.wrappers.AcsJCDBExceptionEx)1 AcsJCDBRecordDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx)1 AcsJWrongCDBDataTypeEx (alma.cdbErrType.wrappers.AcsJWrongCDBDataTypeEx)1 Transaction (org.hibernate.Transaction)1