Package com.infoclinika.mssharing.model

Examples of com.infoclinika.mssharing.model.AccessDenied


    @Override
    public FileItem readFileDetails(long actor, long fileId) {
        final FileMetaData fileMetaData = checkPresence(fileMetaDataRepository.findOne(fileId));
        if (!ruleValidator.userHasReadPermissionsOnFile(actor).apply(Util.FILE_FROM_ID.apply(fileId))) {
            throw new AccessDenied("User has no permissions to read file");
        }
        final Instrument instrument = fileMetaData.getInstrument();
        return new FileItem(fileMetaData.getId(),
                instrument.getName(),
                instrument.getLab().getName(), instrument.getId(),
View Full Code Here


    @Override
    public FileItem readFileDetailsWithConditions(long actor, final long fileId, long experimentId) {
        final FileMetaData fileMetaData = checkPresence(fileMetaDataRepository.findOne(fileId));
        if (!ruleValidator.userHasReadPermissionsOnFile(actor).apply(Util.FILE_FROM_ID.apply(fileId))) {
            throw new AccessDenied("User has no permissions to read file");
        }
        final Instrument instrument = fileMetaData.getInstrument();
        final Experiment experiment = experimentRepository.findOne(experimentId);
        RawFile rawFile = Iterables.find(experiment.getRawFiles().data, new Predicate<RawFile>() {
            @Override
View Full Code Here

    @Override
    public ExperimentShortInfo readExperimentShortInfo(long actor, final long experimentId) {
        final Experiment experiment = experimentRepository.findOne(experimentId);
        if(experiment == null) throw new ObjectNotFoundException("Experiment not found");

        if(!ruleValidator.isUserCanReadExperiment(actor).apply(experiment)) throw new AccessDenied("Can't read experiment");

        final ImmutableList<ShortExperimentFileItem> files = from(experiment.getRawFiles().data).transform(new Function<RawFile, ShortExperimentFileItem>() {
            @Override
            public ShortExperimentFileItem apply(RawFile input) {
                final ImmutableList<ConditionItem> conditions = from(input.getConditions()).transform(new Function<Condition, ConditionItem>() {
View Full Code Here

    }

    List<Attachment> getAttachments(AttachmentType type, long actor, long item) {
           switch (type){
               case PROJECT:
                   if (!ruleValidator.hasReadAccessOnProject(actor, item)) throw new AccessDenied("Project read restricted");
                   return attachmentRepository.findByProject(item);
               case EXPERIMENT:
                   final Experiment experiment = checkPresence(experimentRepository.findOne(item));
                   if(!ruleValidator.isUserCanReadExperiment(actor).apply(experiment)) throw new AccessDenied("Can't read experiment");
                   return attachmentRepository.findByExperiment(experiment.getId());
               default:
                   throw new AssertionError(type);
           }
    }
View Full Code Here

    @Override
    public InstrumentItem readInstrument(long actor, long instrumentId) {
        final Instrument instrument = instrumentRepository.findOne(instrumentId);
        if(instrument == null) throw new ObjectNotFoundException("Instrument not found");
        if(!ruleValidator.isUserCanReadInstrument(actor).apply(instrument)) throw new AccessDenied("Can't read instrument");

        final String vendor = instrument.getModel().vendor.getName();
        final String type = instrument.getModel().type.getName();
        final User user = Util.USER_FROM_ID.apply(actor);
        final InstrumentAccess access = instrument.isOperator(user) ? InstrumentAccess.OPERATOR
View Full Code Here

    @Override
    public GroupItem readGroupDetails(long actor, long group) {
        final Group orig = groupRepository.findOne(group);

        if(orig == null) throw new ObjectNotFoundException("Group not found");
        if (!ruleValidator.canReadGroupDetails(actor, group)) throw new AccessDenied("Can't read group");

        return new GroupItem(orig.getId(), orig.getName(), orig.getLastModification(),
                from(orig.getCollaborators()).transform(MEMBER).toImmutableSortedSet(new Comparator<MemberItem>() {
                    @Override
                    public int compare(MemberItem o1, MemberItem o2) {
View Full Code Here

        return saveProject(entity).getId();
    }

    @Override
    public void updateProjectDetails(long actor, long projectId, ProjectInfo projectInfo) {
        if (!validator.hasWriteAccessOnProject(actor, projectId)) throw new AccessDenied("Couldn't update");
        if (!validator.canUserUpdateProjectWithTitle(actor, projectId, projectInfo.name)) {
            throw new IllegalArgumentException("User already has project with this name: \"" + projectInfo.name + "\"");
        }
        if(isEmpty(projectInfo.areaOfResearch.trim())) {
            throw new IllegalArgumentException("Project's area of research must be specified") ;
View Full Code Here

        saveProject(project);
    }

    @Override
    public void removeProject(long actor, long projectId) {
        if (!validator.canRemoveProject(actor, projectId)) throw new AccessDenied("Couldn't remove project");
        final Project project = projectRepository.findOne(projectId);
        for (Experiment e : experimentRepository.findByProject(project)) {
            for (ExperimentSearch r : experimentSearchRepository.findByExperimentId(e.getId())) {
                removeExperimentSearch(r.getId());
            }
View Full Code Here

        projectRepository.delete(projectId);
    }

    @Override
    public void removeExperiment(long actor, long experimentId) {
        if (!validator.canRemoveExperiment(actor, experimentId)) throw new AccessDenied("Couldn't remove experiment");
        for (ExperimentSearch r : experimentSearchRepository.findByExperimentId(experimentId)) {
            removeExperimentSearch(r.getId());
        }
        experimentRepository.delete(experimentId);
    }
View Full Code Here

            public Long doInTransaction(TransactionStatus status) {
                ImmutableCollection<FileItem> immutableFiles = ImmutableList.copyOf(files);
                checkArgument(files != null && !files.isEmpty(), "Can't save experiment without files");
                if (!validator.userHasEditPermissionsOnExperiment(actor, experimentId)
                        || !validator.userHasReadPermissionsOnFiles(actor, toFileMetaData(immutableFiles))) {
                    throw new AccessDenied("User isn't permitted to edit experiment");
                }
                checkArgument(validator.canUserUpdateExperimentWithTitle(actor, experimentId, info.name), "User already has experiment with this name: \"" + info.name + "\"");
                checkArgument(validator.canCreateExperimentWithFiles(transform(files, new Function<FileItem, Long>() {
                    @Override
                    public Long apply(FileItem input) {
View Full Code Here

TOP

Related Classes of com.infoclinika.mssharing.model.AccessDenied

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.