@Test(expected = IllegalArgumentException.class) public void testInvalidACEId() { String aceId = "pedro:read:"; ACE.fromId(aceId); }
public static ACE fromId(String aceId) { if (aceId == null) { return null; } Matcher m = ID_PATTERN.matcher(aceId); if (!m.matches()) { throw new IllegalArgumentException(String.format("Invalid ACE id: %s", aceId)); } String[] parts = new String[m.groupCount()]; for (int i = 1; i <= m.groupCount(); i++) { parts[i - 1] = m.group(i); } String username = parts[0]; String permission = parts[1]; boolean isGranted = Boolean.parseBoolean(parts[2]); ACEBuilder builder = ACE.builder(username, permission).isGranted(isGranted); if (parts.length >= 4 && StringUtils.isNotBlank(parts[3])) { builder.creator(parts[3]); } if (parts.length >= 5 && StringUtils.isNotBlank(parts[4])) { Calendar begin = new GregorianCalendar(); begin.setTimeInMillis(Long.parseLong(parts[4])); builder.begin(begin); } if (parts.length >= 6 && StringUtils.isNotBlank(parts[5])) { Calendar end = new GregorianCalendar(); end.setTimeInMillis(Long.parseLong(parts[5])); builder.end(end); } return builder.build(); }
ACE implements Serializable, Cloneable { public static ACE fromId(String aceId) { if (aceId == null) { return null; } Matcher m = ID_PATTERN.matcher(aceId); if (!m.matches()) { throw new IllegalArgumentException(String.format("Invalid ACE id: %s", aceId)); } String[] parts = new String[m.groupCount()]; for (int i = 1; i <= m.groupCount(); i++) { parts[i - 1] = m.group(i); } String username = parts[0]; String permission = parts[1]; boolean isGranted = Boolean.parseBoolean(parts[2]); ACEBuilder builder = ACE.builder(username, permission).isGranted(isGranted); if (parts.length >= 4 && StringUtils.isNotBlank(parts[3])) { builder.creator(parts[3]); } if (parts.length >= 5 && StringUtils.isNotBlank(parts[4])) { Calendar begin = new GregorianCalendar(); begin.setTimeInMillis(Long.parseLong(parts[4])); builder.begin(begin); } if (parts.length >= 6 && StringUtils.isNotBlank(parts[5])) { Calendar end = new GregorianCalendar(); end.setTimeInMillis(Long.parseLong(parts[5])); builder.end(end); } return builder.build(); } }
ACE implements Serializable, Cloneable { public static ACE fromId(String aceId) { if (aceId == null) { return null; } Matcher m = ID_PATTERN.matcher(aceId); if (!m.matches()) { throw new IllegalArgumentException(String.format("Invalid ACE id: %s", aceId)); } String[] parts = new String[m.groupCount()]; for (int i = 1; i <= m.groupCount(); i++) { parts[i - 1] = m.group(i); } String username = parts[0]; String permission = parts[1]; boolean isGranted = Boolean.parseBoolean(parts[2]); ACEBuilder builder = ACE.builder(username, permission).isGranted(isGranted); if (parts.length >= 4 && StringUtils.isNotBlank(parts[3])) { builder.creator(parts[3]); } if (parts.length >= 5 && StringUtils.isNotBlank(parts[4])) { Calendar begin = new GregorianCalendar(); begin.setTimeInMillis(Long.parseLong(parts[4])); builder.begin(begin); } if (parts.length >= 6 && StringUtils.isNotBlank(parts[5])) { Calendar end = new GregorianCalendar(); end.setTimeInMillis(Long.parseLong(parts[5])); builder.end(end); } return builder.build(); } ACE();  ACE(String username, String permission, boolean isGranted);  ACE(String username, String permission);   ACE(String username, String permission, boolean isGranted, String creator, Calendar begin, Calendar end,
            Map<String, Serializable> contextData); }
ACE implements Serializable, Cloneable { public static ACE fromId(String aceId) { if (aceId == null) { return null; } Matcher m = ID_PATTERN.matcher(aceId); if (!m.matches()) { throw new IllegalArgumentException(String.format("Invalid ACE id: %s", aceId)); } String[] parts = new String[m.groupCount()]; for (int i = 1; i <= m.groupCount(); i++) { parts[i - 1] = m.group(i); } String username = parts[0]; String permission = parts[1]; boolean isGranted = Boolean.parseBoolean(parts[2]); ACEBuilder builder = ACE.builder(username, permission).isGranted(isGranted); if (parts.length >= 4 && StringUtils.isNotBlank(parts[3])) { builder.creator(parts[3]); } if (parts.length >= 5 && StringUtils.isNotBlank(parts[4])) { Calendar begin = new GregorianCalendar(); begin.setTimeInMillis(Long.parseLong(parts[4])); builder.begin(begin); } if (parts.length >= 6 && StringUtils.isNotBlank(parts[5])) { Calendar end = new GregorianCalendar(); end.setTimeInMillis(Long.parseLong(parts[5])); builder.end(end); } return builder.build(); } ACE();  ACE(String username, String permission, boolean isGranted);  ACE(String username, String permission);   ACE(String username, String permission, boolean isGranted, String creator, Calendar begin, Calendar end,
            Map<String, Serializable> contextData); static ACE fromId(String aceId); String getId(); String getUsername(); String getPermission(); boolean isGranted(); boolean isDenied(); Calendar getBegin(); void setBegin(Calendar begin); Calendar getEnd(); void setEnd(Calendar end); String getCreator(); void setCreator(String creator); Status getStatus(); Long getLongStatus(); boolean isEffective(); boolean isPending(); boolean isArchived(); Serializable getContextData(String key); void putContextData(String key, Serializable value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override Object clone(); static ACEBuilder builder(ACE ace); static ACEBuilder builder(String username, String permission); }
ACE implements Serializable, Cloneable { public static ACE fromId(String aceId) { if (aceId == null) { return null; } Matcher m = ID_PATTERN.matcher(aceId); if (!m.matches()) { throw new IllegalArgumentException(String.format("Invalid ACE id: %s", aceId)); } String[] parts = new String[m.groupCount()]; for (int i = 1; i <= m.groupCount(); i++) { parts[i - 1] = m.group(i); } String username = parts[0]; String permission = parts[1]; boolean isGranted = Boolean.parseBoolean(parts[2]); ACEBuilder builder = ACE.builder(username, permission).isGranted(isGranted); if (parts.length >= 4 && StringUtils.isNotBlank(parts[3])) { builder.creator(parts[3]); } if (parts.length >= 5 && StringUtils.isNotBlank(parts[4])) { Calendar begin = new GregorianCalendar(); begin.setTimeInMillis(Long.parseLong(parts[4])); builder.begin(begin); } if (parts.length >= 6 && StringUtils.isNotBlank(parts[5])) { Calendar end = new GregorianCalendar(); end.setTimeInMillis(Long.parseLong(parts[5])); builder.end(end); } return builder.build(); } ACE();  ACE(String username, String permission, boolean isGranted);  ACE(String username, String permission);   ACE(String username, String permission, boolean isGranted, String creator, Calendar begin, Calendar end,
            Map<String, Serializable> contextData); static ACE fromId(String aceId); String getId(); String getUsername(); String getPermission(); boolean isGranted(); boolean isDenied(); Calendar getBegin(); void setBegin(Calendar begin); Calendar getEnd(); void setEnd(Calendar end); String getCreator(); void setCreator(String creator); Status getStatus(); Long getLongStatus(); boolean isEffective(); boolean isPending(); boolean isArchived(); Serializable getContextData(String key); void putContextData(String key, Serializable value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override Object clone(); static ACEBuilder builder(ACE ace); static ACEBuilder builder(String username, String permission); static final ACE BLOCK; }