Search in sources :

Example 6 with RepositoryException

use of org.pentaho.platform.api.repository.RepositoryException in project pentaho-platform by pentaho.

the class RuntimeRepository method loadElementById.

/**
 * Loads an existing RuntimeElement
 *
 * @param instId
 *          The instance Id
 * @return the RuntimeElement
 * @throws RepositoryException
 */
public IRuntimeElement loadElementById(final String instId, final Collection allowableReadAttributeNames) throws RepositoryException {
    if (RuntimeRepository.debug) {
        // $NON-NLS-1$
        debug(Messages.getInstance().getString("RTREPO.DEBUG_LOAD_ELEMENT_BY_ID", instId));
    }
    Session session = HibernateUtil.getSession();
    try {
        RuntimeElement runtimeElement = (RuntimeElement) session.load(RuntimeElement.class, instId);
        runtimeElement.setAllowableAttributeNames(allowableReadAttributeNames);
        return runtimeElement;
    } catch (HibernateException ex) {
        // $NON-NLS-1$
        error(Messages.getInstance().getErrorString("RTREPO.ERROR_0001_LOAD_ELEMENT", instId), ex);
        throw new RepositoryException(Messages.getInstance().getErrorString("RTREPO.ERROR_0001_LOAD_ELEMENT", instId), // $NON-NLS-1$
        ex);
    }
}
Also used : IRuntimeElement(org.pentaho.platform.api.repository.IRuntimeElement) HibernateException(org.hibernate.HibernateException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) Session(org.hibernate.Session) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Example 7 with RepositoryException

use of org.pentaho.platform.api.repository.RepositoryException in project pentaho-platform by pentaho.

the class HibernateUtil method closeSession.

/**
 * Closes the Session local to the thread.
 */
public static void closeSession() throws RepositoryException {
    try {
        Session s = (Session) HibernateUtil.threadSession.get();
        HibernateUtil.threadSession.set(null);
        if ((s != null) && s.isOpen()) {
            if (HibernateUtil.debug) {
                // $NON-NLS-1$
                HibernateUtil.log.debug(Messages.getInstance().getString("HIBUTIL.DEBUG_CLOSING_SESSION"));
            }
            s.close();
        }
        HibernateUtil.threadTransaction.set(null);
    } catch (HibernateException ex) {
        // $NON-NLS-1$
        HibernateUtil.log.error(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0009_CLOSE_SESSION"), ex);
        HibernateUtil.threadTransaction.set(null);
        // $NON-NLS-1$
        throw new RepositoryException(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0009_CLOSE_SESSION"), ex);
    }
}
Also used : HibernateException(org.hibernate.HibernateException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) Session(org.hibernate.Session)

Example 8 with RepositoryException

use of org.pentaho.platform.api.repository.RepositoryException in project pentaho-platform by pentaho.

the class HibernateUtil method flushSession.

public static void flushSession() throws RepositoryException {
    try {
        Session s = HibernateUtil.getSession();
        s.flush();
    } catch (HibernateException ex) {
        throw new RepositoryException(ex);
    }
}
Also used : HibernateException(org.hibernate.HibernateException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) Session(org.hibernate.Session)

Example 9 with RepositoryException

use of org.pentaho.platform.api.repository.RepositoryException in project pentaho-platform by pentaho.

the class HibernateUtil method rebuildSessionFactory.

/**
 * Rebuild the SessionFactory with the given Hibernate Configuration.
 *
 * @param cfg
 */
public static void rebuildSessionFactory(final Configuration cfg) throws RepositoryException {
    if (!HibernateUtil.hibernateManaged) {
        synchronized (HibernateUtil.lock) {
            try {
                HibernateUtil.sessionFactory = cfg.buildSessionFactory();
                HibernateUtil.configuration = cfg;
            } catch (Exception ex) {
                HibernateUtil.log.error(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0007_REBUILD_SESSION_FACTORY"), // $NON-NLS-1$
                ex);
                throw new RepositoryException(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0007_REBUILD_SESSION_FACTORY"), // $NON-NLS-1$
                ex);
            }
        }
    } else {
        try {
            cfg.buildSessionFactory();
            HibernateUtil.configuration = cfg;
        } catch (Exception ex) {
            HibernateUtil.log.error(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0007_REBUILD_SESSION_FACTORY"), // $NON-NLS-1$
            ex);
            throw new RepositoryException(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0007_REBUILD_SESSION_FACTORY"), // $NON-NLS-1$
            ex);
        }
    }
}
Also used : RepositoryException(org.pentaho.platform.api.repository.RepositoryException) NamingException(javax.naming.NamingException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) ContentException(org.pentaho.platform.api.repository.ContentException) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) HibernateException(org.hibernate.HibernateException)

Example 10 with RepositoryException

use of org.pentaho.platform.api.repository.RepositoryException in project pentaho-platform by pentaho.

the class MultipleComponentIT method testMiscExceptionClasses.

/*
   * public void testCrosstab() { startTest(); IRuntimeContext context = run("test", "rules", "CrossTabTest.xaction");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ IActionParameter rtn = context.getOutputParameter("rule-result"); //$NON-NLS-1$
   * assertNotNull(rtn); IPentahoResultSet resultset = (IPentahoResultSet) rtn.getValue();
   * assertEquals(resultset.getRowCount(), 7); Object[][] colHeaders = resultset.getMetaData().getColumnHeaders();
   * assertEquals(colHeaders[0][0], "DEPARTMENT"); //$NON-NLS-1$ assertEquals(colHeaders[0][1], "Central"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][2], "Western"); //$NON-NLS-1$ assertEquals(colHeaders[0][3], "Southern"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][4], "Eastern"); //$NON-NLS-1$
   * 
   * finishTest(); }
   */
public void testMiscExceptionClasses() {
    // Making sure we create an instance of all the Hitachi Vantara
    // Exception classes.
    startTest();
    Exception ex = new RepositoryException();
    // $NON-NLS-1$
    Exception ex2 = new RepositoryException("Ignored");
    Exception ex3 = new RepositoryException(ex2);
    // $NON-NLS-1$
    Exception ex4 = new RepositoryException("Ignored", ex3);
    Exception ex5 = new AuditException();
    // $NON-NLS-1$
    Exception ex6 = new AuditException("Ignored");
    // $NON-NLS-1$
    Exception ex7 = new AuditException("Ignored", ex);
    Exception ex8 = new AuditException(ex4);
    // $NON-NLS-1$
    ex = new ContentException("Ignored");
    // $NON-NLS-1$
    ex = new ContentException("Ignored", ex5);
    ex = new ContentException(ex6);
    ex = new InvalidParameterException();
    ex = new SQLResultSetException();
    ex = new PentahoChainedException();
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored");
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored", ex7);
    ex = new PentahoChainedException(ex8);
    finishTest();
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException)

Aggregations

RepositoryException (org.pentaho.platform.api.repository.RepositoryException)12 HibernateException (org.hibernate.HibernateException)6 Session (org.hibernate.Session)4 HashMap (java.util.HashMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Map (java.util.Map)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 ContentException (org.pentaho.platform.api.repository.ContentException)2 IRuntimeElement (org.pentaho.platform.api.repository.IRuntimeElement)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 NamingException (javax.naming.NamingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 Transaction (org.hibernate.Transaction)1 ConstraintViolationException (org.hibernate.exception.ConstraintViolationException)1 Test (org.junit.Test)1 AuditException (org.pentaho.platform.api.engine.AuditException)1 InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)1