Search in sources :

Example 11 with RepositoryException

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

the class MondrianCatalogRepositoryHelper method includeAnnotatedSchema.

private Map<String, InputStream> includeAnnotatedSchema(final Map<String, InputStream> values) {
    MondrianSchemaAnnotator annotator = PentahoSystem.get(MondrianSchemaAnnotator.class, ANNOTATOR_KEY, PentahoSessionHolder.getSession());
    try {
        if (annotator != null) {
            byte[] schemaBytes = IOUtils.toByteArray(values.get(SCHEMA_XML));
            byte[] annotationBytes = IOUtils.toByteArray(values.get(ANNOTATIONS_XML));
            values.put(SCHEMA_XML, new ByteArrayInputStream(schemaBytes));
            values.put(ANNOTATIONS_XML, new ByteArrayInputStream(annotationBytes));
            values.put("schema.annotated.xml", annotator.getInputStream(new ByteArrayInputStream(schemaBytes), new ByteArrayInputStream(annotationBytes)));
        }
    } catch (IOException e) {
        throw new RepositoryException(e);
    }
    return values;
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) IOException(java.io.IOException)

Example 12 with RepositoryException

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

the class AnalysisResourceTest method testDoGetAnalysisFilesAsDownloadError.

@Test
public void testDoGetAnalysisFilesAsDownloadError() throws Exception {
    // Test 1
    PentahoAccessControlException mockException = mock(PentahoAccessControlException.class);
    RepositoryException repositoryException = mock(RepositoryException.class);
    doThrow(mockException).doThrow(repositoryException).when(analysisResource.service).doGetAnalysisFilesAsDownload("analysisId");
    try {
        Response response = analysisResource.downloadSchema("analysisId");
        fail("Should have gotten a WebApplicationException");
    } catch (WebApplicationException e) {
    // Good
    }
    try {
        Response response = analysisResource.downloadSchema("analysisId");
        fail("Should have gotten a WebApplicationException");
    } catch (WebApplicationException e) {
    // Good
    }
    verify(analysisResource, times(2)).downloadSchema("analysisId");
}
Also used : Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Test(org.junit.Test)

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