Search in sources :

Example 6 with Securable

use of gemma.gsec.model.Securable in project Gemma by PavlidisLab.

the class SecurityControllerImpl method makeGroupReadable.

@Override
public boolean makeGroupReadable(EntityDelegator ed, String groupName) {
    Securable s = this.getSecurable(ed);
    securityService.makeReadableByGroup(s, groupName);
    return true;
}
Also used : Securable(gemma.gsec.model.Securable)

Example 7 with Securable

use of gemma.gsec.model.Securable in project Gemma by PavlidisLab.

the class SecurityControllerImpl method makePrivate.

@Override
public boolean makePrivate(EntityDelegator ed) {
    Securable s = this.getSecurable(ed);
    securityService.makePrivate(s);
    return true;
}
Also used : Securable(gemma.gsec.model.Securable)

Example 8 with Securable

use of gemma.gsec.model.Securable in project Gemma by PavlidisLab.

the class SecurityControllerImpl method removeGroupWriteable.

@Override
public boolean removeGroupWriteable(EntityDelegator ed, String groupName) {
    Securable s = this.getSecurable(ed);
    securityService.makeUnwriteableByGroup(s, groupName);
    return true;
}
Also used : Securable(gemma.gsec.model.Securable)

Example 9 with Securable

use of gemma.gsec.model.Securable in project Gemma by PavlidisLab.

the class SecurityControllerImpl method securables2VOs.

/**
 * @param securables   securables
 * @param currentGroup A specific group that we're focusing on. Can be null
 * @return security info VOs
 */
private <T extends Securable> Collection<SecurityInfoValueObject> securables2VOs(Collection<T> securables, String currentGroup) {
    Collection<SecurityInfoValueObject> result = new HashSet<>();
    if (securables.isEmpty()) {
        return result;
    }
    /*
         * Fast computations out-of-loop
         */
    Collection<String> groupsForCurrentUser = this.getGroupsForCurrentUser();
    Map<T, Boolean> privacy = securityService.arePrivate(securables);
    Map<T, Boolean> sharedness = securityService.areShared(securables);
    Map<T, Sid> owners = securityService.getOwners(securables);
    Map<T, Collection<String>> groupsReadableBy = securityService.getGroupsReadableBy(securables);
    Map<T, Collection<String>> groupsEditableBy = securityService.getGroupsEditableBy(securables);
    // int i = 0; // TESTING
    for (Securable s : securables) {
        Collection<String> groupsThatCanRead = groupsReadableBy.get(s);
        Collection<String> groupsThatCanWrite = groupsEditableBy.get(s);
        SecurityInfoValueObject vo = new SecurityInfoValueObject(s);
        vo.setCurrentGroup(currentGroup);
        vo.setAvailableGroups(groupsForCurrentUser);
        vo.setPubliclyReadable(!privacy.get(s));
        vo.setShared(sharedness.get(s));
        vo.setOwner(new SidValueObject(owners.get(s)));
        // FIXME this does not seem to be used in the UI and it fixes issue #41: https://github.com/ppavlidis/Gemma/issues/41
        // securityService.isOwnedByCurrentUser( s ) );
        vo.setCurrentUserOwns(false);
        vo.setCurrentUserCanwrite(securityService.isEditable(s));
        vo.setGroupsThatCanRead(groupsThatCanRead == null ? new HashSet<String>() : groupsThatCanRead);
        vo.setGroupsThatCanWrite(groupsThatCanWrite == null ? new HashSet<String>() : groupsThatCanWrite);
        vo.setEntityClazz(s.getClass().getName());
        if (currentGroup != null) {
            vo.setCurrentGroupCanRead(groupsThatCanRead != null && groupsThatCanRead.contains(currentGroup));
            vo.setCurrentGroupCanWrite(groupsThatCanWrite != null && groupsThatCanWrite.contains(currentGroup));
        }
        if (ExpressionExperiment.class.isAssignableFrom(s.getClass())) {
            vo.setEntityShortName(((ExpressionExperiment) s).getShortName());
            vo.setEntityName(((ExpressionExperiment) s).getName());
        } else if (Describable.class.isAssignableFrom(s.getClass())) {
            vo.setEntityShortName(((Describable) s).getName());
            vo.setEntityName(((Describable) s).getDescription());
        }
        result.add(vo);
    // if ( ++i > 10 ) break; // TESTING
    }
    return result;
}
Also used : Securable(gemma.gsec.model.Securable) Describable(ubic.gemma.model.common.Describable) Sid(org.springframework.security.acls.model.Sid)

Aggregations

Securable (gemma.gsec.model.Securable)9 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 Sid (org.springframework.security.acls.model.Sid)1 GeneDifferentialExpressionMetaAnalysis (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis)1 DifferentialExpressionEvidence (ubic.gemma.model.association.phenotype.DifferentialExpressionEvidence)1 PhenotypeAssociation (ubic.gemma.model.association.phenotype.PhenotypeAssociation)1 Describable (ubic.gemma.model.common.Describable)1 GeneSet (ubic.gemma.model.genome.gene.GeneSet)1 EntityDelegator (ubic.gemma.web.remote.EntityDelegator)1