Search in sources :

Example 21 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class NamedClusterEmbedManager method addAllClusters.

private void addAllClusters() {
    NamedClusterServiceOsgi ncso = meta.getNamedClusterServiceOsgi();
    if (ncso != null && meta.getMetaStore() != null) {
        try {
            List<String> list = ncso.listNames(meta.getMetaStore());
            for (String name : list) {
                addClusterToMeta(name);
            }
            for (NamedClusterOsgi nc : namedClusterPool.values()) {
                if (!list.contains(nc.getName())) {
                    addClusterToMeta(nc);
                }
            }
            addedAllClusters = true;
        } catch (MetaStoreException e) {
            logMetaStoreException(e);
        }
    }
}
Also used : NamedClusterOsgi(org.pentaho.di.core.osgi.api.NamedClusterOsgi) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) NamedClusterServiceOsgi(org.pentaho.di.core.osgi.api.NamedClusterServiceOsgi)

Example 22 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method createElement.

@Override
public void createElement(String namespace, IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException, MetaStoreElementExistException {
    try {
        IMetaStoreElement found = getElementByName(namespace, elementType, element.getName());
        if (found != null) {
            throw new MetaStoreElementExistException(Arrays.asList(found), "The element with name '" + element.getName() + "' already exists");
        }
        delegate.insertElement(elementType, element);
        repository.commit();
    } catch (MetaStoreElementExistException e) {
        throw e;
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException("Unable to create element with name '" + element.getName() + "' of type '" + elementType.getName() + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 23 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method deleteNamespace.

@Override
public void deleteNamespace(String namespace) throws MetaStoreException, MetaStoreDependenciesExistsException {
    try {
        ObjectId namespaceId = delegate.verifyNamespace(namespace);
        List<IMetaStoreElementType> elementTypes = getElementTypes(namespace);
        if (!elementTypes.isEmpty()) {
            List<String> dependencies = new ArrayList<String>();
            for (IMetaStoreElementType elementType : elementTypes) {
                dependencies.add(elementType.getId());
            }
            throw new MetaStoreDependenciesExistsException(dependencies, "The namespace to delete, '" + namespace + "' is not empty");
        }
        // Now delete the namespace
        // 
        delegate.deleteNamespace(namespaceId);
        repository.commit();
    } catch (MetaStoreDependenciesExistsException e) {
        throw e;
    } catch (MetaStoreException e) {
        repository.rollback();
        throw e;
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException("Unable to delete namespace '" + namespace + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) ArrayList(java.util.ArrayList) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 24 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method updateElement.

@Override
public void updateElement(String namespace, IMetaStoreElementType elementType, String elementId, IMetaStoreElement element) throws MetaStoreException {
    try {
        // This is a delete/insert operation
        // 
        deleteElement(namespace, elementType, elementId);
        createElement(namespace, elementType, element);
        repository.commit();
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException("Unable to update element with id '" + elementId + "' called '" + element.getName() + "' in type '" + elementType.getName() + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 25 with MetaStoreException

use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method getElementTypeByName.

@Override
public IMetaStoreElementType getElementTypeByName(String namespace, String elementTypeName) throws MetaStoreException {
    try {
        LongObjectId namespaceId = delegate.getNamespaceId(namespace);
        if (namespaceId == null) {
            return null;
        }
        LongObjectId elementTypeId = delegate.getElementTypeId(namespaceId, elementTypeName);
        if (elementTypeId == null) {
            return null;
        }
        RowMetaAndData elementTypeRow = delegate.getElementType(elementTypeId);
        return delegate.parseElementType(namespace, namespaceId, elementTypeRow);
    } catch (Exception e) {
        throw new MetaStoreException("Unable to get element type with name '" + elementTypeName + "' in namespace '" + namespace + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Aggregations

MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)43 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)18 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)18 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)17 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)17 LongObjectId (org.pentaho.di.repository.LongObjectId)12 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)11 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)9 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)8 StringObjectId (org.pentaho.di.repository.StringObjectId)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 ObjectId (org.pentaho.di.repository.ObjectId)5 IMetaStore (org.pentaho.metastore.api.IMetaStore)5 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)4 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)4 List (java.util.List)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 NamedClusterOsgi (org.pentaho.di.core.osgi.api.NamedClusterOsgi)2