Search in sources :

Example 11 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryJaxwsWebServiceIT method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    String address = "http://localhost:9000/repo";
    try {
        Endpoint.publish(address, new DefaultUnifiedRepositoryJaxwsWebService(repo));
    } catch (Throwable th) {
    // ignore
    }
    Service service = Service.create(new URL("http://localhost:9000/repo?wsdl"), new QName("http://www.pentaho.org/ws/1.0", "unifiedRepository"));
    IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort(IUnifiedRepositoryJaxwsWebService.class);
    // accept cookies to maintain session on server
    ((BindingProvider) repoWebService).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    // support streaming binary data
    ((BindingProvider) repoWebService).getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) repoWebService).getBinding();
    binding.setMTOMEnabled(true);
    repo = new UnifiedRepositoryToWebServiceAdapter(repoWebService);
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Matchers.anyString(org.mockito.Matchers.anyString) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) URL(java.net.URL) Before(org.junit.Before)

Example 12 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.

the class RepositoryFileTreeAdapterTest method testBIServer7777.

/**
 * Assert empty list in RepositoryFileTree#children survives full jaxb serialization roundtrip
 */
@Test
public void testBIServer7777() throws Exception {
    IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
    PentahoSystem.registerObject(unifiedRepository);
    RepositoryFileAcl acl = new RepositoryFileAcl.Builder("admin").build();
    when(unifiedRepository.getAcl(anyString())).thenReturn(acl);
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
    // file tree with empty children
    RepositoryFile empty = new RepositoryFile.Builder("empty").build();
    RepositoryFileTree emptyDir = new RepositoryFileTree(empty, Collections.<RepositoryFileTree>emptyList());
    RepositoryFile root = new RepositoryFile.Builder("rootDir").build();
    ArrayList<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>(1);
    children.add(emptyDir);
    RepositoryFileTree rootDir = new RepositoryFileTree(root, children);
    // to DTO
    RepositoryFileTreeAdapter adapter = new RepositoryFileTreeAdapter();
    RepositoryFileTreeDto dtoThere = adapter.marshal(rootDir);
    assertNotNull(dtoThere.getChildren().get(0).getChildren());
    // serialize
    final JAXBContext jaxbContext = JAXBContext.newInstance(RepositoryFileTreeDto.class);
    Marshaller marshaller = jaxbContext.createMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal(dtoThere, sw);
    // and bring it back
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    StringReader sr = new StringReader(sw.toString());
    RepositoryFileTreeDto dtoBackAgain = (RepositoryFileTreeDto) unmarshaller.unmarshal(sr);
    assertNotNull(dtoBackAgain.getChildren().get(0).getChildren());
    // unmarshall
    RepositoryFileTree rootDir2 = adapter.unmarshal(dtoBackAgain);
    assertNotNull(rootDir2.getChildren().get(0).getChildren());
    assertEquals(rootDir, rootDir2);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Unmarshaller(javax.xml.bind.Unmarshaller) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 13 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.

the class DefaultRepositoryVersioningManagerTest method testFullTrue.

/*
   * Test a file set to versioningEnable=True, versionCommentsEnabled=true with various combinations
   * of the master switch.
   */
@Test
public void testFullTrue() {
    IRepositoryVersionManager repositoryVersionManager = defaultRepositoryVersionManagerFullTrue;
    assertTrue(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
    assertTrue(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
    repositoryVersionManager = defaultRepositoryVersionManagerPartialTrue;
    assertTrue(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
    assertFalse(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
    repositoryVersionManager = defaultRepositoryVersionManagerFalse;
    assertFalse(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
    assertFalse(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
}
Also used : IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) Test(org.junit.Test)

Example 14 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.

the class DefaultRepositoryVersioningManagerTest method testFalse.

/*
   * Test a file set to versioningEnable=false, versionCommentsEnabled=false with various combinations
   * of the master switch.
   */
@Test
public void testFalse() {
    IRepositoryVersionManager repositoryVersionManager = defaultRepositoryVersionManagerFullTrue;
    assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
    assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
    repositoryVersionManager = defaultRepositoryVersionManagerPartialTrue;
    assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
    assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
    repositoryVersionManager = defaultRepositoryVersionManagerFalse;
    assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
    assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
}
Also used : IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) Test(org.junit.Test)

Example 15 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.

the class JcrRepositoryFileDaoTest method setUp.

@Before
public void setUp() throws RepositoryException {
    Node node = mock(Node.class);
    Node nodeParent = mock(Node.class);
    when(node.getIdentifier()).thenReturn("");
    when(nodeParent.getIdentifier()).thenReturn("");
    when(node.getParent()).thenReturn(nodeParent);
    when(node.isNodeType("null:pentahoFile")).thenReturn(true);
    when(node.isNodeType("null:pentahoVersionable")).thenReturn(true);
    VersionManagerImpl versionManager = mock(VersionManagerImpl.class);
    Workspace workspace = mock(Workspace.class);
    when(workspace.getVersionManager()).thenReturn(versionManager);
    Session session = mock(Session.class);
    when(session.getWorkspace()).thenReturn(workspace);
    when(session.getNodeByIdentifier(anyString())).thenReturn(node);
    when(session.getItem(anyString())).thenReturn(node);
    pentahoSession = mock(IPentahoSession.class);
    PentahoSessionHolder.setSession(pentahoSession);
    IRepositoryVersionManager repositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(repositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    PentahoSystem.registerObject(repositoryVersionManager);
    JcrTemplate jcrTemplate = new JcrTemplate() {

        @Override
        public Object execute(JcrCallback callback) throws DataAccessException {
            try {
                return callback.doInJcr(session);
            } catch (Exception e) {
                // wrapping exception to comply overriding rules
                throw new RuntimeException(e);
            }
        }
    };
    List<ITransformer<IRepositoryFileData>> transformerList = Collections.emptyList();
    IPathConversionHelper pathConversionHelper = new DefaultPathConversionHelper();
    IRepositoryFileAclDao aclDao = mock(IRepositoryFileAclDao.class);
    accessVoterManager = mock(IRepositoryAccessVoterManager.class);
    JcrRepositoryFileDao jcrDao = new JcrRepositoryFileDao(jcrTemplate, transformerList, null, null, pathConversionHelper, aclDao, null, accessVoterManager);
    dao = spy(jcrDao);
}
Also used : JcrTemplate(org.springframework.extensions.jcr.JcrTemplate) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Node(javax.jcr.Node) JcrCallback(org.springframework.extensions.jcr.JcrCallback) IRepositoryFileAclDao(org.pentaho.platform.repository2.unified.IRepositoryFileAclDao) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) DataAccessException(org.springframework.dao.DataAccessException) AccessDeniedException(javax.jcr.AccessDeniedException) RepositoryException(javax.jcr.RepositoryException) VersionManagerImpl(org.apache.jackrabbit.core.VersionManagerImpl) IRepositoryAccessVoterManager(org.pentaho.platform.api.repository2.unified.IRepositoryAccessVoterManager) Workspace(javax.jcr.Workspace) Session(javax.jcr.Session) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Before(org.junit.Before)

Aggregations

IRepositoryVersionManager (org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager)15 Before (org.junit.Before)7 Test (org.junit.Test)4 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 Map (java.util.Map)1 Properties (java.util.Properties)1 AccessDeniedException (javax.jcr.AccessDeniedException)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 Workspace (javax.jcr.Workspace)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1