Moer RM-2113 review comments. Renaming SecurityClearance.getClassificationLevel to getClearanceLevel

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@103782 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-05-06 16:26:50 +00:00
parent 0fbe2e59b0
commit 47c161da65
4 changed files with 17 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
<#import "/org/alfresco/repository/generic-paged-results.lib.ftl" as gen/>
<#macro usersecurityclearanceJSON item>
<#local cl=item.classificationLevel>
<#local cl=item.clearanceLevel>
<#local pi=item.personInfo>
<#escape x as jsonUtils.encodeJSONString(x)>
"classificationId": "${cl.id}",

View File

@@ -33,30 +33,31 @@ public final class SecurityClearance implements Serializable
{
/** Serial version uid */
private static final long serialVersionUID = 8410664575120817707L;
private final PersonInfo personInfo;
private final ClassificationLevel classificationLevel;
public SecurityClearance(final PersonInfo personInfo, final ClassificationLevel classificationLevel)
private final PersonInfo personInfo;
private final ClassificationLevel clearanceLevel;
public SecurityClearance(final PersonInfo personInfo, final ClassificationLevel clearanceLevel)
{
Objects.requireNonNull(personInfo);
Objects.requireNonNull(classificationLevel);
Objects.requireNonNull(clearanceLevel);
this.personInfo = personInfo;
this.classificationLevel = classificationLevel;
this.personInfo = personInfo;
this.clearanceLevel = clearanceLevel;
}
/** Returns the {@link PersonInfo} for this security clearance. */
public PersonInfo getPersonInfo() { return this.personInfo; }
/** Returns the {@link ClassificationLevel} for this security clearance. */
public ClassificationLevel getClassificationLevel() { return this.classificationLevel; }
public ClassificationLevel getClearanceLevel() { return this.clearanceLevel; }
@Override public String toString()
{
StringBuilder msg = new StringBuilder();
msg.append(SecurityClearance.class.getSimpleName())
.append(':').append(personInfo.getUserName())
.append(" [").append(classificationLevel).append(']');
.append(" [").append(clearanceLevel).append(']');
return msg.toString();
}
@@ -69,8 +70,8 @@ public final class SecurityClearance implements Serializable
SecurityClearance that = (SecurityClearance) o;
return this.personInfo.equals(that.personInfo) &&
this.classificationLevel.equals(that.classificationLevel);
this.clearanceLevel.equals(that.clearanceLevel);
}
@Override public int hashCode() { return Objects.hash(personInfo, classificationLevel); }
@Override public int hashCode() { return Objects.hash(personInfo, clearanceLevel); }
}

View File

@@ -68,7 +68,7 @@ public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements Sec
if (nodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE))
{
final String clearanceLevel = (String)nodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL);
// TODO Should we fall back to a default here or give an error?
classificationLevel = clearanceLevel == null ? classificationService.getDefaultClassificationLevel() :
classificationService.getClassificationLevelById(clearanceLevel);
}

View File

@@ -26,9 +26,6 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.Serializable;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper;
@@ -46,6 +43,9 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.io.Serializable;
import java.util.Map;
/**
* Unit tests for {@link SecurityClearanceServiceImpl}.
*
@@ -97,7 +97,7 @@ public class SecurityClearanceServiceImplUnitTest
final SecurityClearance clearance = securityClearanceServiceImpl.getUserSecurityClearance();
assertEquals("default", clearance.getClassificationLevel().getId());
assertEquals("default", clearance.getClearanceLevel().getId());
}
/** Check that a user can have their clearance set for the first time. */