use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class JpaUserDevfilePermissionDao method getByInstance.
@Override
@Transactional
public Page<UserDevfilePermissionImpl> getByInstance(String instanceId, int maxItems, long skipCount) throws ServerException {
requireNonNull(instanceId, "User devfile identifier required");
checkArgument(skipCount <= Integer.MAX_VALUE, "The number of items to skip can't be greater than " + Integer.MAX_VALUE);
try {
final EntityManager entityManager = managerProvider.get();
final List<UserDevfilePermissionImpl> permissions = entityManager.createNamedQuery("UserDevfilePermission.getByUserDevfileId", UserDevfilePermissionImpl.class).setParameter("userDevfileId", instanceId).setMaxResults(maxItems).setFirstResult((int) skipCount).getResultList().stream().map(UserDevfilePermissionImpl::new).collect(toList());
final Long permissionsCount = entityManager.createNamedQuery("UserDevfilePermission.getCountByUserDevfileId", Long.class).setParameter("userDevfileId", instanceId).getSingleResult();
return new Page<>(permissions, skipCount, maxItems, permissionsCount);
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class UserDevfilePermissionDaoTest method setUp.
@BeforeMethod
public void setUp() throws TckRepositoryException {
accountRepository.createAll(ImmutableList.of(TestObjectGenerator.TEST_ACCOUNT));
permissions = new UserDevfilePermissionImpl[] { new UserDevfilePermissionImpl("devfile_id1", "user1", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id1", "user2", Arrays.asList(READ, DELETE)), new UserDevfilePermissionImpl("devfile_id2", "user1", Arrays.asList(READ, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user2", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user0", Arrays.asList(READ, DELETE, UPDATE)) };
final UserImpl[] users = new UserImpl[] { new UserImpl("user0", "user0@com.com", "usr0"), new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2") };
userRepository.createAll(Arrays.asList(users));
devfileRepository.createAll(ImmutableList.of(createUserDevfile("devfile_id1", generate("name", 6)), createUserDevfile("devfile_id2", generate("name", 6)), createUserDevfile("devfile_id3", generate("name", 6)), createUserDevfile("devfile_id4", generate("name", 6)), createUserDevfile("devfile_id5", generate("name", 6))));
permissionTckRepository.createAll(Stream.of(permissions).map(UserDevfilePermissionImpl::new).collect(Collectors.toList()));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class MultiuserJpaUserDevfileDaoTest method setupEntities.
@BeforeClass
public void setupEntities() throws Exception {
permissions = ImmutableList.of(new UserDevfilePermissionImpl("devfile_id1", "user1", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user1", Arrays.asList(READ, UPDATE)), new UserDevfilePermissionImpl("devfile_id3", "user1", Arrays.asList(DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id1", "user2", Arrays.asList(READ, DELETE, UPDATE)));
users = ImmutableList.of(new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2"));
accounts = ImmutableList.of(new AccountImpl("acc-1", NameGenerator.generate("account", 6), "user"), new AccountImpl("acc-2", NameGenerator.generate("account", 6), "user"));
userDevfiles = ImmutableList.of(createUserDevfile("devfile_id1", accounts.get(0), generate("name", 6)), createUserDevfile("devfile_id2", accounts.get(0), generate("name", 6)), createUserDevfile("devfile_id3", accounts.get(0), generate("name", 6)));
Injector injector = Guice.createInjector(new UserDevfileTckModule());
manager = injector.getInstance(EntityManager.class);
dao = injector.getInstance(MultiuserJpaUserDevfileDao.class);
tckResourcesCleaner = injector.getInstance(TckResourcesCleaner.class);
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class UserDevfileTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, VolumeImpl.class, // devfile
UserDevfileImpl.class, UserDevfilePermissionImpl.class, ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfilePermissionImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermissionImpl.class));
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfilePermissionDaoTest.TestDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class JpaTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, UserDevfilePermissionImpl.class, // devfile
ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, UserDevfileImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfilePermissionDaoTest.TestDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
}
Aggregations