Search in sources :

Example 1 with WDAOPOATie

use of com.cosylab.CDB.WDAOPOATie in project ACS by ACS-Community.

the class HibernateWDALImpl method get_WDAO_Servant.

/* (non-Javadoc)
	 * @see com.cosylab.CDB.WDALOperations#get_WDAO_Servant(java.lang.String)
	 */
public WDAO get_WDAO_Servant(String curl) throws CDBRecordIsReadOnlyEx, CDBXMLErrorEx, CDBRecordDoesNotExistEx {
    checkAccess();
    // remove trailing slashes, to have unique curl (used for key)
    if (curl.length() > 0 && curl.charAt(0) == '/')
        curl = curl.substring(1);
    // make sure there are no identical DAOs created
    synchronized (wdaoMap) {
        // get cached
        if (wdaoMap.containsKey(curl))
            return (WDAO) wdaoMap.get(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);
            m_logger.log(AcsLogLevel.NOTICE, "WDAL::get_WDAO_Servant " + ex.getShortDescription());
            throw ex.toCDBRecordDoesNotExistEx();
        }
        try {
            Object objImpl = null;
            WDAOPOA wdaoImpl = null;
            if (node instanceof WDAOPOA)
                objImpl = wdaoImpl = (WDAOPOA) node;
            else //else if (node instanceof XMLTreeNode)
            //{
            //	DAOImpl daoImpl = new DAOImpl(curl, (XMLTreeNode)node, poa, m_logger);
            //	objImpl = wdaoImpl = new WDAOImpl(this, curl, daoImpl, poa, m_logger);
            //}
            {
                HibernateWDAOImpl impl = new HibernateWDAOImpl(mainSession, curl, node, poa, m_logger);
                objImpl = impl;
                wdaoImpl = new WDAOPOATie(impl);
                impl.setSetvant(wdaoImpl);
            }
            // create object id
            byte[] id = ("WDAO" + curl).getBytes();
            // activate object
            poa.activate_object_with_id(id, wdaoImpl);
            WDAO href = WDAOHelper.narrow(poa.servant_to_reference(wdaoImpl));
            // map DAO reference
            wdaoMap.put(curl, href);
            wdaoObjMap.put(curl, objImpl);
            m_logger.log(AcsLogLevel.INFO, "Returning WDAO servant for: " + curl);
            return href;
        } catch (Throwable t) {
            // @todo not clean, just to be consistent v DAL impl
            String info = "WDAL::get_WDAO_Servant " + t;
            AcsJCDBXMLErrorEx xmlErr = new AcsJCDBXMLErrorEx(t);
            xmlErr.setErrorString(info);
            m_logger.log(AcsLogLevel.NOTICE, info);
            throw xmlErr.toCDBXMLErrorEx();
        }
    }
}
Also used : WDAO(com.cosylab.CDB.WDAO) WDAOPOA(com.cosylab.CDB.WDAOPOA) AcsJCDBRecordDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx) AcsJCDBXMLErrorEx(alma.cdbErrType.wrappers.AcsJCDBXMLErrorEx) WDAOPOATie(com.cosylab.CDB.WDAOPOATie)

Aggregations

AcsJCDBRecordDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBRecordDoesNotExistEx)1 AcsJCDBXMLErrorEx (alma.cdbErrType.wrappers.AcsJCDBXMLErrorEx)1 WDAO (com.cosylab.CDB.WDAO)1 WDAOPOA (com.cosylab.CDB.WDAOPOA)1 WDAOPOATie (com.cosylab.CDB.WDAOPOATie)1