Search in sources :

Example 1 with Project

use of com.thinkbiganalytics.metadata.api.project.Project in project kylo by Teradata.

the class JcrProjectProviderTest method testFindProjectByName.

@Test(dependsOnMethods = "testCreateProject2")
public void testFindProjectByName() {
    metadata.read(() -> {
        Optional<Project> optional = projProvider.findProjectByName("Project2");
        assertThat(optional.isPresent()).isTrue();
        Project project = optional.get();
        assertThat(project).extracting(Project::getSystemName, Project::getProjectName, Project::getDescription, Project::getContainerImage).containsExactly("ProjectName2", "Project Name 2", "This is a fully defined project", "kylo/nonExistentContainer");
    }, MetadataAccess.SERVICE);
}
Also used : Project(com.thinkbiganalytics.metadata.api.project.Project) Test(org.testng.annotations.Test)

Example 2 with Project

use of com.thinkbiganalytics.metadata.api.project.Project in project kylo by Teradata.

the class JcrProjectProviderTest method afterClass.

@AfterClass
public void afterClass() {
    metadata.commit(() -> {
        Collection<Project> projects = projProvider.getProjects();
        for (Project project : projects) {
            logger.info("Deleting remaing project '{}' after tests completed.", project);
            projProvider.deleteProject(project);
        }
    }, MetadataAccess.SERVICE);
}
Also used : Project(com.thinkbiganalytics.metadata.api.project.Project) AfterClass(org.testng.annotations.AfterClass)

Example 3 with Project

use of com.thinkbiganalytics.metadata.api.project.Project in project kylo by Teradata.

the class JcrProjectProviderTest method testCreateProject.

@Test
public void testCreateProject() throws Exception {
    metadata.commit(() -> {
        Project pj1 = this.projProvider.ensureProject("Project1");
        assertThat(pj1).isNotNull();
    /*Session session =  metadata.getActiveSession();
            JcrTools tools = new JcrTools();
            tools.setDebug(true);
            try {
                tools.printSubgraph(session.getRootNode().getNode("metadata"));
            } catch (RepositoryException e) {
                e.printStackTrace();
            }*/
    }, MetadataAccess.SERVICE);
}
Also used : Project(com.thinkbiganalytics.metadata.api.project.Project) Test(org.testng.annotations.Test)

Example 4 with Project

use of com.thinkbiganalytics.metadata.api.project.Project in project kylo by Teradata.

the class JcrProjectProviderTest method testCreateProject2.

@Test
public void testCreateProject2() throws Exception {
    metadata.commit(() -> {
        Project pj1 = this.projProvider.ensureProject("Project2");
        assertThat(pj1).isNotNull();
        pj1.setSystemName("ProjectName2");
        pj1.setProjectName("Project Name 2");
        pj1.setDescription("This is a fully defined project");
        pj1.setContainerImage("kylo/nonExistentContainer");
    }, MetadataAccess.SERVICE);
}
Also used : Project(com.thinkbiganalytics.metadata.api.project.Project) Test(org.testng.annotations.Test)

Example 5 with Project

use of com.thinkbiganalytics.metadata.api.project.Project in project kylo by Teradata.

the class JcrProjectProvider method getMyEditableProjects.

@Override
public List<Project> getMyEditableProjects() {
    UsernamePrincipal user = JcrMetadataAccess.getActiveUser();
    logger.debug("user={}", user);
    List<Project> projects = getProjects();
    return projects.stream().filter(prj -> {
        try {
            prj.getAllowedActions().checkPermission(ProjectAccessControl.EDIT_PROJECT);
            return true;
        } catch (AccessControlException ace) {
            return false;
        }
    }).collect(Collectors.toList());
}
Also used : UsernamePrincipal(com.thinkbiganalytics.security.UsernamePrincipal) AllowedEntityActionsProvider(com.thinkbiganalytics.security.action.AllowedEntityActionsProvider) LoggerFactory(org.slf4j.LoggerFactory) JcrProject(com.thinkbiganalytics.metadata.modeshape.project.JcrProject) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) Inject(javax.inject.Inject) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) RepositoryException(javax.jcr.RepositoryException) Node(javax.jcr.Node) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) Nonnull(javax.annotation.Nonnull) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) RoleMembership(com.thinkbiganalytics.metadata.api.security.RoleMembership) UsernamePrincipal(com.thinkbiganalytics.security.UsernamePrincipal) Session(javax.jcr.Session) Set(java.util.Set) ProjectAccessControl(com.thinkbiganalytics.metadata.api.project.security.ProjectAccessControl) ProjectPaths(com.thinkbiganalytics.metadata.modeshape.project.ProjectPaths) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Project(com.thinkbiganalytics.metadata.api.project.Project) Serializable(java.io.Serializable) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) AccessControlException(java.security.AccessControlException) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Optional(java.util.Optional) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) Collections(java.util.Collections) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) JcrProject(com.thinkbiganalytics.metadata.modeshape.project.JcrProject) Project(com.thinkbiganalytics.metadata.api.project.Project) AccessControlException(java.security.AccessControlException)

Aggregations

Project (com.thinkbiganalytics.metadata.api.project.Project)11 Test (org.testng.annotations.Test)6 JcrProject (com.thinkbiganalytics.metadata.modeshape.project.JcrProject)4 UsernamePrincipal (com.thinkbiganalytics.security.UsernamePrincipal)3 Node (javax.jcr.Node)2 RepositoryException (javax.jcr.RepositoryException)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 ProjectAccessControl (com.thinkbiganalytics.metadata.api.project.security.ProjectAccessControl)1 RoleMembership (com.thinkbiganalytics.metadata.api.security.RoleMembership)1 BaseJcrProvider (com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider)1 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)1 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 JcrEntity (com.thinkbiganalytics.metadata.modeshape.common.JcrEntity)1 ProjectPaths (com.thinkbiganalytics.metadata.modeshape.project.ProjectPaths)1 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)1 JcrQueryUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil)1 JcrUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrUtil)1 AccessController (com.thinkbiganalytics.security.AccessController)1 AllowedActions (com.thinkbiganalytics.security.action.AllowedActions)1