public class StudyRights {
- private User user;
- private Study operand;
- private boolean author = false; // For optimizing
- public StudyRights (User user, Study study) {
+ private final transient User _user;
+ private final transient Study _operand;
+ private transient boolean _author = false; // For optimizing
+ public StudyRights (final User user, final Study study) {
// -------------------------------------------
- this.user = user;
- this.operand = study;
+ this._user = user;
+ this._operand = study;
- if (operand != null && operand.getAuthor() != null) {
- this.author = operand.getAuthor().equals(user); // user may be null
+ if (_operand != null && _operand.getAuthor() != null) {
+ this._author = _operand.getAuthor().equals(user); // user may be null
}
}
- public StudyRights (Study study) {
+ public StudyRights (final Study study) {
// --------------------------------
- this.user = study.getAuthor();
- this.operand = study;
- this.author = true; // In order to ignore the author in this context
+ this._user = study.getAuthor();
+ this._operand = study;
+ this._author = true; // In order to ignore the author in this context
}
// ==============================================================================================================================
public boolean canAddScenario () {
// --------------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
}
/**
*/
public boolean canEditDescription () {
// ------------------------------------
- return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
+ return (_operand.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(_operand, _user));
}
public boolean canEditProperties () {
// -----------------------------------
- return author;
+ return _author;
}
/**
*/
public boolean canPublish () {
// ----------------------------
- if (!author) return false;
- return (!operand.isPublic());
+ if (!_author) {
+ return false;
+ }
+ return (!_operand.isPublic());
}
public boolean canPurge () {
// --------------------------
- if (!author) return false;
- return operand.isVersioned();
+ if (!_author) {
+ return false;
+ }
+ return _operand.isVersioned();
}
public boolean canRemove () {
// ---------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return author;
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return _author;
}
public boolean canVersion () {
// ----------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
}
// ==============================================================================================================================
public Study getOperand () {
// --------------------------
- return operand;
+ return _operand;
}
}
\ No newline at end of file