@Test public void canWriteArticle() throws Exception { ZoneInfo site = ZoneInfo.createKaif("site", "public", Instant.now()); UUID accountId = UUID.randomUUID(); assertFalse(site.canWriteArticle(auth(accountId, EnumSet.of(SYSOP)))); assertFalse(site.canWriteArticle(auth(accountId, EnumSet.of(TOURIST)))); assertFalse(site.canWriteArticle(auth(accountId, EnumSet.of(CITIZEN)))); ZoneInfo managed = site.withAdmins(Arrays.asList(accountId)); assertTrue("admin should ignore authority", managed.canWriteArticle(auth(accountId, EnumSet.noneOf(Authority.class)))); assertFalse("not admin", managed.canWriteArticle(auth(UUID.randomUUID(), EnumSet.noneOf(Authority.class)))); }
public boolean canWriteArticle(Authorization auth) { if (auth.belongToAccounts(adminAccountIds)) { return true; } return auth.containsAuthority(writeAuthority); }
ZoneInfo { public boolean canWriteArticle(Authorization auth) { if (auth.belongToAccounts(adminAccountIds)) { return true; } return auth.containsAuthority(writeAuthority); } }
ZoneInfo { public boolean canWriteArticle(Authorization auth) { if (auth.belongToAccounts(adminAccountIds)) { return true; } return auth.containsAuthority(writeAuthority); } ZoneInfo(Zone zone,
      String aliasName,
      String theme,
      Authority voteAuthority,
      Authority debateAuthority,
      Authority writeAuthority,
      List<UUID> adminAccountIds,
      boolean hideFromTop,
      Instant createTime); }
ZoneInfo { public boolean canWriteArticle(Authorization auth) { if (auth.belongToAccounts(adminAccountIds)) { return true; } return auth.containsAuthority(writeAuthority); } ZoneInfo(Zone zone,
      String aliasName,
      String theme,
      Authority voteAuthority,
      Authority debateAuthority,
      Authority writeAuthority,
      List<UUID> adminAccountIds,
      boolean hideFromTop,
      Instant createTime); static ZoneInfo createKVoting(String zoneValue,
      String aliasName,
      Account creator,
      Instant now); static ZoneInfo createNormalVoting(String zoneValue,
      String aliasName,
      Account creator,
      Instant now); static ZoneInfo createTourist(String zoneValue, String aliasName, Instant now); static ZoneInfo createKaif(String zoneValue, String aliasName, Instant now); static ZoneInfo createDefault(String zoneValue, String aliasName, Instant now); static boolean isValidDefault(String zoneValue); @Override boolean equals(Object o); @Override int hashCode(); Zone getZone(); String getAliasName(); Authority getVoteAuthority(); String getTheme(); Authority getWriteAuthority(); List<UUID> getAdminAccountIds(); Instant getCreateTime(); Authority getDebateAuthority(); boolean canUpVote(Authorization auth); boolean canDebate(Authorization auth); boolean canWriteArticle(Authorization auth); boolean canContributeVoteStats(); boolean isHideFromTop(); ZoneInfo withAdmins(List<UUID> accountIds); String getName(); @Override String toString(); V1ZoneDto toV1Dto(); }
ZoneInfo { public boolean canWriteArticle(Authorization auth) { if (auth.belongToAccounts(adminAccountIds)) { return true; } return auth.containsAuthority(writeAuthority); } ZoneInfo(Zone zone,
      String aliasName,
      String theme,
      Authority voteAuthority,
      Authority debateAuthority,
      Authority writeAuthority,
      List<UUID> adminAccountIds,
      boolean hideFromTop,
      Instant createTime); static ZoneInfo createKVoting(String zoneValue,
      String aliasName,
      Account creator,
      Instant now); static ZoneInfo createNormalVoting(String zoneValue,
      String aliasName,
      Account creator,
      Instant now); static ZoneInfo createTourist(String zoneValue, String aliasName, Instant now); static ZoneInfo createKaif(String zoneValue, String aliasName, Instant now); static ZoneInfo createDefault(String zoneValue, String aliasName, Instant now); static boolean isValidDefault(String zoneValue); @Override boolean equals(Object o); @Override int hashCode(); Zone getZone(); String getAliasName(); Authority getVoteAuthority(); String getTheme(); Authority getWriteAuthority(); List<UUID> getAdminAccountIds(); Instant getCreateTime(); Authority getDebateAuthority(); boolean canUpVote(Authorization auth); boolean canDebate(Authorization auth); boolean canWriteArticle(Authorization auth); boolean canContributeVoteStats(); boolean isHideFromTop(); ZoneInfo withAdmins(List<UUID> accountIds); String getName(); @Override String toString(); V1ZoneDto toV1Dto(); static final int ALIAS_NAME_MAX; static final String THEME_DEFAULT; static final String THEME_KAIF; static final String THEME_NORMAL_VOTING; static final String THEME_K_VOTING; static final String RESERVED_WORD; }