public HomeConfig newMessage() { return new HomeConfig(); }
private static void createHomeDir(NamespaceService ns, String user) throws NamespaceException { final NamespaceKey homeKey = new HomePath(HomeName.getUserHomePath(user)).toNamespaceKey(); if (!ns.exists(homeKey, Type.HOME)) { final HomeConfig homeConfig = new HomeConfig().setOwner(user); ns.addOrUpdateHome(homeKey, homeConfig); } }
public static void addHome(NamespaceService ns, String name) throws Exception { final HomeConfig homeConfig = new HomeConfig(); homeConfig.setOwner(name); ns.addOrUpdateHome(new NamespaceKey("@" + name), homeConfig); }
@RolesAllowed("admin") @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public UserUI createUser(UserForm userForm, @PathParam("userName") UserName userName) throws IOException, IllegalArgumentException, NamespaceException, DACUnauthorizedException { checkUser(userName, "create"); User newUser = SimpleUser.newBuilder(userForm.getUserConfig()).setCreatedAt(System.currentTimeMillis()).build(); newUser = userService.createUser(newUser, userForm.getPassword()); try { namespaceService.addOrUpdateHome(new HomePath(HomeName.getUserHomePath(userName.getName())).toNamespaceKey(), new HomeConfig().setCtime(System.currentTimeMillis()).setOwner(userName.getName())); } catch (Exception e) { try { userService.deleteUser(newUser.getUserName(), newUser.getVersion()); } catch (UserNotFoundException e1) { logger.warn("Could not delete a user {} after failing to create corresponding home space", userName.getName()); } finally { throw UserException.unsupportedError() .message("Could not create user '%s', make sure you don't already have a similar user with different casing", newUser.getUserName()) .addContext("Cause", e.getMessage()) .build(); } } return new UserUI(new UserResourcePath(userName), userName, newUser); }
new HomeConfig().setCtime(System.currentTimeMillis()).setOwner(userConfig.getUserName()) );
@PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("firstuser") public UserUI createUser(UserForm userForm) throws IOException, IllegalArgumentException, NamespaceException, DACUnauthorizedException, UserNotFoundException { synchronized (this) { if (dContext.getUserService().hasAnyUser()) { throw UserException.validationError().message(ERROR_MSG).build(logger); } final UserName userName = new UserName(userForm.getUserConfig().getUserName()); User newUser = SimpleUser.newBuilder(userForm.getUserConfig()).setCreatedAt(System.currentTimeMillis()).build(); newUser = userService.createUser(newUser, userForm.getPassword()); dContext.getNamespaceService(SystemUser.SYSTEM_USERNAME) .addOrUpdateHome( new HomePath(HomeName.getUserHomePath(userName.getName())).toNamespaceKey(), new HomeConfig().setCtime(System.currentTimeMillis()).setOwner(userName.getName()) ); return new UserUI(new UserResourcePath(userName), userName, newUser); } } }
private void addHome(String name) throws Exception { final HomeConfig home = new HomeConfig() .setId(new EntityId().setId(UUID.randomUUID().toString())) .setOwner(name); final NameSpaceContainer container = new NameSpaceContainer() .setType(NameSpaceContainer.Type.HOME) .setFullPathList(Arrays.asList(name)) .setHome(home); namespaceStore.put(NamespaceServiceImpl.getKey(new NamespaceKey("@" + name)), container); }
@Test public void previewTableInSubschemaExposedAsTopLevelSchema() throws Exception { // Namespace is cleaned up before the test. So make sure to create a home directory for the test user. final NamespaceKey homeKey = new HomePath(HomeName.getUserHomePath(DEFAULT_USERNAME)).toNamespaceKey(); final NamespaceService ns = l(NamespaceService.class); if (!ns.exists(homeKey, Type.HOME)) { final HomeConfig homeConfig = new HomeConfig().setOwner(DEFAULT_USERNAME); ns.addOrUpdateHome(homeKey, homeConfig); } final NASConf nas = new NASConf(); nas.path = new File("src/test/resources").getAbsolutePath(); SourceUI source = new SourceUI(); source.setName("testNAS"); source.setConfig(nas); source.setMetadataPolicy(UIMetadataPolicy.of(CatalogService.DEFAULT_METADATA_POLICY_WITH_AUTO_PROMOTE)); final SourceService sourceService = newSourceService(); sourceService.registerSourceWithRuntime(source); InitialDataPreviewResponse resp = getPreview(new DatasetPath(asList("testNAS", "datasets", "users.json"))); // Now try to query the table as "testNAS.datasets"."users.json" createDatasetFromSQL("SELECT * FROM \"testNAS.datasets\".\"users.json\"", asList("cp")); }
config.setName("testB"); namespaceService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); final HomeConfig home1 = new HomeConfig(); home1.setOwner(DEFAULT_USER_NAME); namespaceService.addOrUpdateHome(new HomePath(HomeName.getUserHomePath(home1.getOwner())).toNamespaceKey(), home1);
@Test public void testGetTopLevelCatalogItems() throws Exception { HomeConfig homeConfig = new HomeConfig(); homeConfig.setOwner("user"); homeConfig.setId(new EntityId("home-id"));