use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.
the class ExperimentalDesignControllerTest method testGetExperimentalFactors.
@Test
public void testGetExperimentalFactors() throws Exception {
// readonly.
ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(true);
Collection<ExperimentalFactorValueObject> experimentalFactors = experimentalDesignController.getExperimentalFactors(new EntityDelegator(ee.getExperimentalDesign()));
assertTrue(!experimentalFactors.isEmpty());
}
use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.
the class ExperimentalDesignControllerTest method testGetExperimentalFactorValues.
@Test
public void testGetExperimentalFactorValues() throws Exception {
ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
ee = this.eeService.thawLite(ee);
Collection<FactorValueValueObject> fvs = experimentalDesignController.getFactorValuesWithCharacteristics(new EntityDelegator(ee.getExperimentalDesign().getExperimentalFactors().iterator().next()));
assertTrue(!fvs.isEmpty());
}
use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.
the class SecurityControllerTest method setup.
@Before
public void setup() {
this.ee = super.getTestPersistentBasicExpressionExperiment();
securityService.makePublic(ee);
this.eeId = ee.getId();
this.userName = this.randomName();
this.makeUser(userName);
ed = new EntityDelegator();
ed.setClassDelegatingFor(ee.getClass().getName());
ed.setId(this.eeId);
securityService.makeOwnedByUser(ee, userName);
}
use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.
the class PhenotypeController method makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis.
public ValidateEvidenceValueObject makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis(Long geneDifferentialExpressionMetaAnalysisId, SortedSet<CharacteristicValueObject> phenotypes, Double selectionThreshold) {
ValidateEvidenceValueObject validateEvidenceValueObject;
try {
validateEvidenceValueObject = this.phenotypeAssociationManagerService.makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis(geneDifferentialExpressionMetaAnalysisId, phenotypes, selectionThreshold);
// get the permission of the metaAnalysis
EntityDelegator ed = new EntityDelegator();
ed.setId(geneDifferentialExpressionMetaAnalysisId);
ed.setClassDelegatingFor(GeneDifferentialExpressionMetaAnalysis.class.getName());
// update the permission of the meta analysis,(this will update all evidence linked to it)
this.securityController.updatePermission(this.securityController.getSecurityInfo(ed));
} catch (Throwable throwable) {
validateEvidenceValueObject = this.generateValidateEvidenceValueObject(throwable);
}
return validateEvidenceValueObject;
}
use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.
the class SecurityControllerImpl method updatePermission.
@Override
public SecurityInfoValueObject updatePermission(SecurityInfoValueObject settings) {
EntityDelegator sd = new EntityDelegator();
sd.setId(settings.getEntityId());
sd.setClassDelegatingFor(settings.getEntityClazz());
Securable s = this.getSecurable(sd);
if (settings.isPubliclyReadable()) {
securityService.makePublic(s);
} else {
securityService.makePrivate(s);
}
try {
if (settings.getOwner().isPrincipal()) {
securityService.makeOwnedByUser(s, settings.getOwner().getAuthority());
} else {
// this warning is not even worth issuing if we are not an administrator.
if (SecurityUtil.isUserAdmin())
SecurityControllerImpl.log.warn("Can't make groupauthority " + settings.getOwner().getAuthority() + " owner, not implemented");
}
} catch (AccessDeniedException e) {
SecurityControllerImpl.log.warn("Non-administrators cannot change the owner of an entity");
// okay, only works if you are administrator.
}
/*
* This works in one of two ways. If settings.currentGroup is non-null, we just update the permissions for that
* group - this may leave them unchanged. Otherwise, we update them all based on
* groupsThatCanRead/groupsThatCanWrite
*/
String currentGroupName = settings.getCurrentGroup();
if (StringUtils.isNotBlank(currentGroupName) && !(currentGroupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || currentGroupName.equals(AuthorityConstants.AGENT_GROUP_NAME))) {
// this test only makes sense for changing the group's name, not for changing the permissions
// of potentially shared entities
// if ( !getGroupsUserCanEdit().contains( currentGroupName ) ) {
// throw new AccessDeniedException( "Access denied to permissions for group=" + currentGroupName );
// }
Boolean readable = settings.isCurrentGroupCanRead();
Boolean writeable = settings.isCurrentGroupCanWrite();
if (readable) {
securityService.makeReadableByGroup(s, currentGroupName);
} else {
securityService.makeUnreadableByGroup(s, currentGroupName);
}
if (writeable) {
// if writable should be readable
securityService.makeReadableByGroup(s, currentGroupName);
securityService.makeWriteableByGroup(s, currentGroupName);
} else {
securityService.makeUnwriteableByGroup(s, currentGroupName);
}
} else {
/*
* Remove all group permissions - we'll set them back to what was requested. Exception: we don't allow
* changes to admin or agent permissions by this route.
*/
for (String groupName : this.getGroupsUserCanEdit()) {
if (groupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || groupName.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
// never changes this.
continue;
}
securityService.makeUnreadableByGroup(s, groupName);
securityService.makeUnwriteableByGroup(s, groupName);
}
/*
* Add selected ones back
*/
for (String reader : settings.getGroupsThatCanRead()) {
if (reader.equals(AuthorityConstants.ADMIN_GROUP_NAME) || reader.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
// never changes this.
continue;
}
securityService.makeReadableByGroup(s, reader);
}
for (String writer : settings.getGroupsThatCanWrite()) {
if (writer.equals(AuthorityConstants.ADMIN_GROUP_NAME) || writer.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
// never changes this.
continue;
}
// when it is writable it should be readable
securityService.makeReadableByGroup(s, writer);
securityService.makeWriteableByGroup(s, writer);
}
}
// special case for Phenocarta, changing the meta analysis, changes the permissions of all evidence linked
if (s instanceof GeneDifferentialExpressionMetaAnalysis) {
Collection<DifferentialExpressionEvidence> differentialExpressionEvidence = this.phenotypeAssociationService.loadEvidenceWithGeneDifferentialExpressionMetaAnalysis(s.getId(), -1);
for (DifferentialExpressionEvidence d : differentialExpressionEvidence) {
settings.setEntityId(d.getId());
settings.setEntityClazz(d.getClass().getName());
this.updatePermission(settings);
}
}
SecurityControllerImpl.log.info("Updated permissions on " + s);
return this.securable2VO(s);
}
Aggregations