Search in sources :

Example 1 with RepositoryException

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

the class MondrianCatalogRepositoryHelper method getModrianSchemaFiles.

public Map<String, InputStream> getModrianSchemaFiles(String catalogName) {
    Map<String, InputStream> values = new HashMap<String, InputStream>();
    RepositoryFile catalogFolder = repository.getFile(ETC_MONDRIAN_JCR_FOLDER + RepositoryFile.SEPARATOR + catalogName);
    if (catalogFolder == null) {
        logger.warn("Catalog " + catalogName + " not found");
        throw new RepositoryException("Catalog " + catalogName + " not found");
    }
    for (RepositoryFile repoFile : repository.getChildren(catalogFolder.getId())) {
        RepositoryFileInputStream is;
        if (repoFile.getName().equals("metadata")) {
            continue;
        }
        try {
            is = new RepositoryFileInputStream(repoFile, repository);
        } catch (FileNotFoundException e) {
            throw new RepositoryException(e);
        }
        values.put(repoFile.getName(), is);
    }
    if (values.containsKey(ANNOTATIONS_XML) && values.containsKey(SCHEMA_XML)) {
        return includeAnnotatedSchema(values);
    }
    return values;
}
Also used : HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryFileInputStream(org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) RepositoryFileInputStream(org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream)

Example 2 with RepositoryException

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

the class SimpleRuntimeElement method checkType.

protected void checkType(final String key, final String type, final boolean setIt) {
    Map localTypesMap = getTypesMap();
    String curType = (String) localTypesMap.get(key);
    if (curType != null) {
        if (!curType.equals(type)) {
            throw new RepositoryException(Messages.getInstance().getErrorString("RTREPO.ERROR_0001_INVALIDTYPE", curType, // $NON-NLS-1$
            type));
        }
    }
    if (setIt) {
        localTypesMap.put(key, type);
    }
}
Also used : RepositoryException(org.pentaho.platform.api.repository.RepositoryException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with RepositoryException

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

the class RuntimeRepository method newRuntimeElement.

/**
 * Creates a new RuntimeElement
 *
 * @param parId
 *          Parent ID of this instance
 * @param parType
 *          Parent type of the instance
 * @return the created runtime element
 */
public IRuntimeElement newRuntimeElement(final String parId, final String parType, boolean transientOnly) {
    if (RuntimeRepository.debug) {
        // $NON-NLS-1$
        debug(Messages.getInstance().getString("RTREPO.DEBUG_NEW_ELEMENT_PARENT", parId, parType));
    }
    Session session = HibernateUtil.getSession();
    String instanceId = UUIDUtil.getUUIDAsString();
    if (RuntimeRepository.debug) {
        // $NON-NLS-1$
        debug(Messages.getInstance().getString("RTREPO.DEBUG_CREATE_INSTANCE", instanceId));
    }
    RuntimeElement re = new RuntimeElement(instanceId, parId, parType);
    if (!transientOnly) {
        try {
            session.save(re);
        } catch (HibernateException ex) {
            // $NON-NLS-1$
            error(Messages.getInstance().getErrorString("RTREPO.ERROR_0002_SAVING_ELEMENT"), ex);
            throw new RepositoryException(Messages.getInstance().getErrorString("RTREPO.ERROR_0002_SAVING_ELEMENT"), ex);
        }
    }
    return re;
}
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 4 with RepositoryException

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

the class HibernateUtil method beginTransaction.

/**
 * Start a new database transaction.
 */
public static void beginTransaction() throws RepositoryException {
    // commitNeeded.set(Boolean.TRUE);
    Transaction tx = (Transaction) HibernateUtil.threadTransaction.get();
    try {
        if (tx == null) {
            if (HibernateUtil.debug) {
                // $NON-NLS-1$
                HibernateUtil.log.debug(Messages.getInstance().getString("HIBUTIL.DEBUG_START_TRANS"));
            }
            tx = HibernateUtil.getSession().beginTransaction();
            HibernateUtil.threadTransaction.set(tx);
        }
    } catch (HibernateException ex) {
        // $NON-NLS-1$
        HibernateUtil.log.error(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0004_START_TRANS"), ex);
        // $NON-NLS-1$
        throw new RepositoryException(Messages.getInstance().getErrorString("HIBUTIL.ERROR_0004_START_TRANS"), ex);
    }
}
Also used : Transaction(org.hibernate.Transaction) HibernateException(org.hibernate.HibernateException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException)

Example 5 with RepositoryException

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

the class RuntimeElement method checkType.

protected void checkType(final String key, final String type, final boolean setIt) {
    Map localTypesMap = getTypesMap();
    String curType = (String) localTypesMap.get(key);
    if (curType != null) {
        if (!curType.equals(type)) {
            throw new RepositoryException(Messages.getInstance().getErrorString("RTREPO.ERROR_0001_INVALIDTYPE", curType, // $NON-NLS-1$
            type));
        }
    }
    if (setIt) {
        localTypesMap.put(key, type);
    }
}
Also used : RepositoryException(org.pentaho.platform.api.repository.RepositoryException) HashMap(java.util.HashMap) Map(java.util.Map)

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