Search in sources :

Example 11 with AcsJCDBRecordDoesNotExistEx

use of alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx in project ACS by ACS-Community.

the class HibernateWDALImpl method get_DAO.

/* (non-Javadoc)
	 * @see com.cosylab.CDB.DALOperations#get_DAO(java.lang.String)
	 */
public String get_DAO(String curl) throws CDBXMLErrorEx, CDBRecordDoesNotExistEx {
    checkAccess();
    // remove trailing slashes, to have unique curl (used for key)
    if (curl.length() > 0 && curl.charAt(0) == '/')
        curl = curl.substring(1);
    m_logger.log(AcsLogLevel.INFO, "Returning XML record for: " + curl);
    Object node = curl.length() == 0 ? rootNode : DOMJavaClassIntrospector.getNode(curl, rootNode);
    if (node == null || DOMJavaClassIntrospector.isPrimitive(node.getClass())) {
        AcsJCDBRecordDoesNotExistEx ex = new AcsJCDBRecordDoesNotExistEx();
        ex.setCurl(curl);
        String detailMsg = (node == null ? "node is null." : "node is primitive (" + node.getClass().getName() + ").");
        m_logger.log(AcsLogLevel.NOTICE, detailMsg, ex);
        throw ex.toCDBRecordDoesNotExistEx();
    } else if (node instanceof DAOImpl) {
        String ret = ((DAOImpl) node).getRootNode().toString(false);
        m_logger.finest("get_DAO(" + curl + ") returning " + ret);
        return ret;
    }
    // remove last slash
    if (curl.length() > 0 && curl.charAt(curl.length() - 1) == '/')
        curl = curl.substring(0, curl.length() - 1);
    // get node name only
    String name;
    int pos = curl.lastIndexOf('/');
    if (pos == -1)
        name = curl;
    else
        name = curl.substring(pos + 1, curl.length());
    // root
    if (name.length() == 0)
        name = "root";
    try {
        String ret = "<?xml version='1.0' encoding='ISO-8859-1'?>" + DOMJavaClassIntrospector.toXML(DOMJavaClassIntrospector.getRootNodeXMLName(name, node), node, curl, m_logger);
        m_logger.finest("get_DAO(" + curl + ") returning " + ret);
        return ret;
    } catch (Throwable t) {
        t.printStackTrace();
        String info = "DAL::get_DAO " + t;
        AcsJCDBXMLErrorEx xmlErr = new AcsJCDBXMLErrorEx(t);
        xmlErr.setErrorString(info);
        m_logger.log(AcsLogLevel.NOTICE, info);
        throw xmlErr.toCDBXMLErrorEx();
    }
}
Also used : AcsJCDBRecordDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx) AcsJCDBXMLErrorEx(alma.cdbErrType.wrappers.AcsJCDBXMLErrorEx)

Aggregations

AcsJCDBRecordDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx)11 AcsJCDBXMLErrorEx (alma.cdbErrType.wrappers.AcsJCDBXMLErrorEx)8 AcsJCDBExceptionEx (alma.cdbErrType.wrappers.AcsJCDBExceptionEx)2 DAO (com.cosylab.CDB.DAO)2 DAOPOATie (com.cosylab.CDB.DAOPOATie)2 WDAO (com.cosylab.CDB.WDAO)2 WDAOPOA (com.cosylab.CDB.WDAOPOA)2 WDAOPOATie (com.cosylab.CDB.WDAOPOATie)2 Transaction (org.hibernate.Transaction)2 StopWatch (alma.acs.util.StopWatch)1 CDBFieldIsReadOnlyEx (alma.cdbErrType.CDBFieldIsReadOnlyEx)1 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)1 CDBXMLErrorEx (alma.cdbErrType.CDBXMLErrorEx)1 WrongCDBDataTypeEx (alma.cdbErrType.WrongCDBDataTypeEx)1 AcsJCDBFieldDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx)1 AcsJWrongCDBDataTypeEx (alma.cdbErrType.wrappers.AcsJWrongCDBDataTypeEx)1 DAOOperations (com.cosylab.CDB.DAOOperations)1 DAOPOA (com.cosylab.CDB.DAOPOA)1 XMLHandler (com.cosylab.cdb.jdal.XMLHandler)1 XMLSaver (com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.XMLSaver)1