Search in sources :

Example 6 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class ManagerProxyImpl method restart_component.

/**
	 * Restarts an component.
	 * @param	id 	identification of the caller. Called has to be an owner of the component.
	 * @param	component_url	CURL of the component to be restarted.
	 * @return	CORBA reference of the restarted component, <code>null</code> if it fails.
	 */
public Object restart_component(int id, String component_url) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.restartComponent(id, uri);
        // extract component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJBadParameterEx bpe) {
        reportException(bpe);
        //throw bpe.toBadParameterEx();
        throw new BAD_PARAM(bpe.getMessage());
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 7 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class HibernateWDAOImpl method set_double.

/* (non-Javadoc)
	 * @see com.cosylab.CDB.WDAOOperations#set_double(java.lang.String, double)
	 */
@SuppressWarnings("unchecked")
public void set_double(String propertyName, double value) throws CDBFieldIsReadOnlyEx, CDBFieldDoesNotExistEx {
    NodeAndMutator nodeAndMutator = DOMJavaClassIntrospector.getRecursiveMutatorMethod(propertyName, m_rootNode);
    if (nodeAndMutator == null) {
        AcsJCDBFieldDoesNotExistEx ex = new AcsJCDBFieldDoesNotExistEx();
        ex.setFieldName(propertyName);
        throw ex.toCDBFieldDoesNotExistEx();
    }
    Transaction tr = null;
    try {
        if (nodeAndMutator.mutator.getParameterTypes().length != 1) {
            AcsJCDBFieldIsReadOnlyEx acsex = new AcsJCDBFieldIsReadOnlyEx();
            acsex.setFieldName(propertyName);
            throw acsex.toCDBFieldIsReadOnlyEx();
        }
        Object toSet;
        Class parameterClass = nodeAndMutator.mutator.getParameterTypes()[0];
        if (parameterClass.isAssignableFrom(String.class))
            toSet = String.valueOf(value);
        else if (parameterClass.isAssignableFrom(Integer.class) || parameterClass.isAssignableFrom(int.class))
            toSet = Integer.valueOf((int) value);
        else if (parameterClass.isAssignableFrom(Long.class) || parameterClass.isAssignableFrom(long.class))
            toSet = Long.valueOf((long) value);
        else if (parameterClass.isAssignableFrom(Byte.class) || parameterClass.isAssignableFrom(byte.class))
            toSet = Byte.valueOf((byte) value);
        else if (parameterClass.isAssignableFrom(Short.class) || parameterClass.isAssignableFrom(short.class))
            toSet = Short.valueOf((short) value);
        else if (parameterClass.isAssignableFrom(Double.class) || parameterClass.isAssignableFrom(double.class))
            toSet = Double.valueOf(value);
        else if (parameterClass.isAssignableFrom(Float.class) || parameterClass.isAssignableFrom(float.class))
            toSet = Float.valueOf((float) value);
        else if (parameterClass.isAssignableFrom(Boolean.class) || parameterClass.isAssignableFrom(boolean.class))
            toSet = (value != 0);
        else
            throw new NO_RESOURCES("cannot convert value");
        if (m_autoCommit)
            tr = m_session.beginTransaction();
        nodeAndMutator.mutator.invoke(nodeAndMutator.node, new Object[] { toSet });
        if (tr != null)
            tr.commit();
    } catch (Throwable th) {
        if (tr != null)
            tr.rollback();
        if (!m_silent)
            m_logger.log(AcsLogLevel.NOTICE, "Failed to set '" + value + "' to : " + (this.m_name + "/" + propertyName), th);
        throw new NO_RESOURCES(th.getMessage());
    }
}
Also used : NodeAndMutator(com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.NodeAndMutator) AcsJCDBFieldDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx) Transaction(org.hibernate.Transaction) AcsJCDBFieldIsReadOnlyEx(alma.cdbErrType.wrappers.AcsJCDBFieldIsReadOnlyEx) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 8 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class HibernateWDALImpl method clear_cache.

public void clear_cache(String curl) {
    System.out.println("clear_cache(curl)");
    if (loadInProgress.get()) {
        m_logger.warning("Incoming Corba call denied (NO_RESOURCES) because data is being loaded.");
        throw new NO_RESOURCES("load in progress");
    }
    curl = curl.replaceAll("/+", "/");
    //Reload curl data from DB
    if (curl.matches("/")) {
        System.out.println("clear_cache_all()");
        clear_cache_all();
        return;
    } else {
        loadInProgress.set(true);
        m_logger.info("clear_cache(curl): Main1");
        try {
            hibernateUtil.getSession().clear();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        m_logger.info("clear_cache(curl): Main2");
        String c = curl.replaceFirst("^/", "");
        c = curl.replaceFirst("/$", "");
        if (plugin != null) {
            try {
                Map<String, Object> rootMap = (Map<String, Object>) rootNode;
                Session session = hibernateUtil.getSession();
                plugin.updatePrologue(session, config, rootMap, c);
            } catch (Throwable th) {
                this.m_logger.log(Level.SEVERE, "Failure in plugin " + plugin.getClass().getName(), th);
                th.printStackTrace();
            }
        }
        m_logger.info("clear_cache(curl): Main3");
        if (c.startsWith("MACI")) {
            loadMACI(c, true);
        //} else if (c.startsWith("Alarms"){
        //	loadAlarms(c);
        } else if (c.startsWith(COMPONENT_TREE_NAME)) {
            loadComponentsTree(c, true);
        } else {
            System.out.println("Unsupported curl: " + curl);
        }
        m_logger.info("clear_cache(curl): Main4");
        if (plugin != null) {
            try {
                Map<String, Object> rootMap = (Map<String, Object>) rootNode;
                Session session = hibernateUtil.getSession();
                plugin.updateEpilogue(session, config, rootMap, c);
            } catch (Throwable th) {
                this.m_logger.log(Level.SEVERE, "Failure in plugin " + plugin.getClass().getName(), th);
                th.printStackTrace();
            }
        }
        m_logger.info("clear_cache(curl): Main5");
        loadInProgress.set(false);
    }
    //Set<String> curls = new HashSet<String>();
    //curls.add(curl);
    //synchronized (daoMap) {
    //	Iterator iter = daoMap.keySet().iterator();
    //	while (iter.hasNext()) {
    //		String c = (String) iter.next();
    //		if(c.startsWith(curl))
    //			curls.add(c);
    //	}
    //}
    //synchronized (wdaoMap) {
    //	Iterator iter = wdaoMap.keySet().iterator();
    //	while (iter.hasNext()) {
    //		String c = (String) iter.next();
    //		if(c.startsWith(curl))
    //			curls.add(c);
    //	}
    //}
    //
    //synchronized (listenedCurls) {
    //	Iterator iter = listenedCurls.keySet().iterator();
    //	while (iter.hasNext()) {
    //		String c = (String) iter.next();
    //		if(c.startsWith(curl))
    //			curls.add(c);
    //	}
    //}
    Set<String> curls = new HashSet<String>();
    synchronized (daoMap) {
        curls.addAll(daoMap.keySet());
    }
    m_logger.info("clear_cache(curl): Main6");
    synchronized (wdaoMap) {
        curls.addAll(wdaoMap.keySet());
    }
    m_logger.info("clear_cache(curl): Main7");
    synchronized (listenedCurls) {
        Iterator iter = listenedCurls.keySet().iterator();
        while (iter.hasNext()) {
            String c = (String) iter.next();
            curls.add(c);
        }
    }
    m_logger.info("clear_cache(curl): Main8");
    for (String c : curls) clearCache(c);
    m_logger.info("clear_cache(curl): Main9");
}
Also used : Iterator(java.util.Iterator) Map(java.util.Map) RootMap(com.cosylab.cdb.jdal.hibernate.RootMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES) Session(org.hibernate.Session) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 9 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class HibernateWDAOImpl method set_string.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.cosylab.CDB.WDAOOperations#set_string(java.lang.String,
	 * java.lang.String)
	 */
@SuppressWarnings("unchecked")
public void set_string(String propertyName, String value) throws CDBFieldIsReadOnlyEx, CDBFieldDoesNotExistEx {
    NodeAndMutator nodeAndMutator = DOMJavaClassIntrospector.getRecursiveMutatorMethod(propertyName, m_rootNode);
    if (nodeAndMutator == null) {
        AcsJCDBFieldDoesNotExistEx ex = new AcsJCDBFieldDoesNotExistEx();
        ex.setFieldName(propertyName);
        throw ex.toCDBFieldDoesNotExistEx();
    }
    Transaction tr = null;
    try {
        if (nodeAndMutator.mutator.getParameterTypes().length != 1) {
            AcsJCDBFieldIsReadOnlyEx acsex = new AcsJCDBFieldIsReadOnlyEx();
            acsex.setFieldName(propertyName);
            throw acsex.toCDBFieldIsReadOnlyEx();
        }
        Object toSet;
        Class parameterClass = nodeAndMutator.mutator.getParameterTypes()[0];
        if (parameterClass.isAssignableFrom(String.class))
            toSet = String.valueOf(value);
        else if (parameterClass.isAssignableFrom(Integer.class) || parameterClass.isAssignableFrom(int.class))
            toSet = Integer.valueOf(value);
        else if (parameterClass.isAssignableFrom(Long.class) || parameterClass.isAssignableFrom(long.class))
            toSet = Long.valueOf(value);
        else if (parameterClass.isAssignableFrom(Byte.class) || parameterClass.isAssignableFrom(byte.class))
            toSet = Byte.valueOf(value);
        else if (parameterClass.isAssignableFrom(Short.class) || parameterClass.isAssignableFrom(short.class))
            toSet = Short.valueOf(value);
        else if (parameterClass.isAssignableFrom(Double.class) || parameterClass.isAssignableFrom(double.class))
            toSet = Double.valueOf(value);
        else if (parameterClass.isAssignableFrom(Float.class) || parameterClass.isAssignableFrom(float.class))
            toSet = Float.valueOf(value);
        else if (parameterClass.isAssignableFrom(Boolean.class) || parameterClass.isAssignableFrom(boolean.class))
            toSet = Boolean.valueOf(value);
        else
            throw new NO_RESOURCES("cannot convert value");
        if (m_autoCommit)
            tr = m_session.beginTransaction();
        nodeAndMutator.mutator.invoke(nodeAndMutator.node, new Object[] { toSet });
        if (tr != null)
            tr.commit();
    } catch (Throwable th) {
        if (tr != null)
            tr.rollback();
        if (!m_silent)
            m_logger.log(AcsLogLevel.NOTICE, "Failed to set '" + value + "' to : " + (this.m_name + "/" + propertyName), th);
        throw new NO_RESOURCES(th.getMessage());
    }
}
Also used : NodeAndMutator(com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.NodeAndMutator) AcsJCDBFieldDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx) Transaction(org.hibernate.Transaction) AcsJCDBFieldIsReadOnlyEx(alma.cdbErrType.wrappers.AcsJCDBFieldIsReadOnlyEx) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 10 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class CommonPropertyImpl method addValueToHistory.

/**
	 * Add value to the history.
	 * @param value		value to be added to the history.
	 * @param timestamp	value timestamp (OMG) to be added to the history.
	 */
protected void addValueToHistory(Object value, long timestamp) {
    // if history is disabled
    if (historySize == 0)
        return;
    synchronized (historyValue) {
        // add			
        historyTime[historyPosition] = timestamp;
        if (propertyType.isPrimitive()) {
            if (propertyType.isAssignableFrom(double.class))
                Array.setDouble(historyValue, historyPosition, ((Double) value).doubleValue());
            else if (propertyType.isAssignableFrom(int.class))
                Array.setInt(historyValue, historyPosition, ((Integer) value).intValue());
            else if (propertyType.isAssignableFrom(long.class))
                Array.setLong(historyValue, historyPosition, ((Long) value).longValue());
            else if (propertyType.isAssignableFrom(short.class))
                Array.setShort(historyValue, historyPosition, ((Short) value).shortValue());
            else if (propertyType.isAssignableFrom(boolean.class))
                Array.setBoolean(historyValue, historyPosition, ((Boolean) value).booleanValue());
            else if (propertyType.isAssignableFrom(byte.class))
                Array.setByte(historyValue, historyPosition, ((Byte) value).byteValue());
            else if (propertyType.isAssignableFrom(float.class))
                Array.setFloat(historyValue, historyPosition, ((Float) value).floatValue());
            else if (propertyType.isAssignableFrom(char.class))
                Array.setChar(historyValue, historyPosition, ((Character) value).charValue());
            else {
                m_logger.log(Level.WARNING, "jBaci::CommonPropertyImpl::addValueToHistory - Unhandled primitive.");
                throw new NO_RESOURCES("Unhandled primitive");
            }
        } else
            Array.set(historyValue, historyPosition, value);
        // manage control variables
        historyPosition = ++historyPosition % historySize;
        if (!historyTurnaround && historyPosition == 0)
            historyTurnaround = true;
    }
}
Also used : NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Aggregations

NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)28 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)12 BadParametersException (com.cosylab.acs.maci.BadParametersException)12 CoreException (com.cosylab.acs.maci.CoreException)12 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)12 BAD_PARAM (org.omg.CORBA.BAD_PARAM)12 UNKNOWN (org.omg.CORBA.UNKNOWN)12 Object (org.omg.CORBA.Object)8 NoSuchCharacteristic (alma.ACS.NoSuchCharacteristic)6 AcsJCDBFieldDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx)6 AcsJCDBFieldIsReadOnlyEx (alma.cdbErrType.wrappers.AcsJCDBFieldIsReadOnlyEx)6 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 NodeAndMutator (com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.NodeAndMutator)6 URI (java.net.URI)6 URISyntaxException (java.net.URISyntaxException)6 Transaction (org.hibernate.Transaction)6 Condition (alma.ACS.Condition)5 Component (com.cosylab.acs.maci.Component)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 AcsJComponentNotAlreadyActivatedEx (alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx)2