setOwner(dirToMake.toString(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used. " + e);
FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}",
/** * Tests getting and setting fields. */ @Test public void fields() { Random random = new Random(); boolean createParent = random.nextBoolean(); String owner = CommonUtils.randomAlphaNumString(10); String group = CommonUtils.randomAlphaNumString(10); Mode mode = new Mode((short) random.nextInt()); MkdirsOptions options = MkdirsOptions.defaults(mConfiguration); options.setCreateParent(createParent); options.setOwner(owner); options.setGroup(group); options.setMode(mode); assertEquals(createParent, options.getCreateParent()); assertEquals(owner, options.getOwner()); assertEquals(group, options.getGroup()); assertEquals(mode, options.getMode()); }
/** * Tests for default {@link MkdirsOptions}. */ @Test public void defaults() throws IOException { MkdirsOptions options = MkdirsOptions.defaults(mConfiguration); // Verify the default createParent is true. assertTrue(options.getCreateParent()); // Verify that the owner and group are not set. assertNull(options.getOwner()); assertNull(options.getGroup()); String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK); assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(), umask), options.getMode()); }
/** * Tests for building an {@link MkdirsOptions} with a security enabled * configuration. */ @Test public void securityEnabled() throws IOException { InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults()); conf.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName()); conf.set(PropertyKey.SECURITY_LOGIN_USERNAME, "foo"); // Use IdentityUserGroupMapping to map user "foo" to group "foo". conf.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName()); MkdirsOptions options = MkdirsOptions.defaults(mConfiguration); // Verify the default createParent is true. assertTrue(options.getCreateParent()); // Verify that the owner and group are not set. assertNull(options.getOwner()); assertNull(options.getGroup()); String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK); assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(), umask), options.getMode()); }
setOwner(dirToMake.toString(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used. " + e);