Package com.sparc.knappsack.components.entities

Examples of com.sparc.knappsack.components.entities.User


    @Test
    public void testValid() {
        groupForm.setName("name");

        User user = new User();
        Organization organization = new Organization();
        organization.setId(1L);
        user.setActiveOrganization(organization);

        Mockito.when(mockUserService.getUserFromSecurityContext()).thenReturn(user);
        Mockito.when(mockGroupService.get(groupForm.getName(), user.getActiveOrganization().getId())).thenReturn(null);

        validator.validate(groupForm, errors);

        assertFalse(errors.hasErrors());
    }
View Full Code Here


    @Test
    public void testGroupNameAlreadyExists() {
        groupForm.setName("name");

        User user = new User();
        Organization organization = new Organization();
        organization.setId(1L);
        user.setActiveOrganization(organization);

        Mockito.when(mockUserService.getUserFromSecurityContext()).thenReturn(user);
        Mockito.when(mockGroupService.get(groupForm.getName(), user.getActiveOrganization().getId())).thenReturn(new Group());

        validator.validate(groupForm, errors);

        assertTrue(errors.hasErrors());
        Assert.assertEquals(errors.getErrorCount(), 1);
View Full Code Here

    @RequestMapping(value = "/domain/requestAccess/{accessCode}", method = RequestMethod.POST)
    public String requestAccess(Model model, @PathVariable String accessCode) {
        boolean success = false;

        User user = userService.getUserFromSecurityContext();
        DomainUserRequest domainUserRequest = domainUserRequestService.createDomainUserRequest(user, accessCode);

        if (domainUserRequest != null && domainUserRequest.getId() != null && domainUserRequest.getId() > 0) {
            EventDelivery deliveryMechanism = eventDeliveryFactory.getEventDelivery(EventType.DOMAIN_USER_ACCESS_REQUEST);
            if (deliveryMechanism != null) {
View Full Code Here

        Result result = new Result();
        result.setResult(false);

        boolean success = false;
        DomainUserRequest domainUserRequest = requestService.get(requestId);
        User user = userService.getUserFromSecurityContext();

        if (domainUserRequest != null && domainUserRequest.getDomain() != null
                && (user.isSystemAdmin()
                || userDomainService.get(user, domainUserRequest.getDomain().getId(), UserRole.ROLE_GROUP_ADMIN) != null
                || userDomainService.get(user, domainUserRequest.getDomain().getId(), UserRole.ROLE_ORG_ADMIN) != null)) {

            if (status) {
                success = requestService.acceptRequest(domainUserRequest, userRole);
View Full Code Here

    }

    @RequestMapping(value = "/contacts", method = RequestMethod.GET)
    public @ResponseBody
    List<Contacts> getContacts() {
        User user = userService.getUserFromSecurityContext();

        if(user == null) {
            return new ArrayList<Contacts>();
        }
        return userService.getContacts(user);
View Full Code Here

        Long orgId = organizationForm.getId();
        if(organizationForm.getId() != null && organizationForm.getId() > 0) {
            organizationService.editOrganization(organizationForm);
        } else {
            //Only create organization if user is System Admin
            User user = userService.getUserFromSecurityContext();
            if (!user.isSystemAdmin()) {
                String[] codes = {"desktop.manager.organization.generic.error"};
                ObjectError error = new ObjectError("organizationForm", codes, null, null);
                bindingResult.addError(error);
                return addOrganization(model);
            }
View Full Code Here

            log.info(String.format("Attempted to update organization member role for non-existent user: %s", userId));
            result.setResult(false);
            return result;
        }

        User user = userService.getUserFromSecurityContext();
        if (user != null && !userId.equals(user.getId())) {
            userDomainService.updateUserDomainRole(userId, orgId, userRole);
            result.setResult(true);
        } else {
            result.setResult(false);
        }
View Full Code Here

            log.info(String.format("Attempted to update member role for non-existent organization: %s", organizationId));
            result.setResult(false);
            return result;
        }

        User user = userService.getUserFromSecurityContext();

        if (organizationId != null && organizationId > 0 && userIds != null) {
            for (Long userId : userIds) {
                if (user != null && !userId.equals(user.getId())) {
                    organizationService.removeUserFromOrganization(organizationId, userId);
                    userIdsRemoved.add(userId);
                }
            }
        }
View Full Code Here

    }

    @PreAuthorize("isOrganizationAdmin() or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/getOrganizationsForUser", method = RequestMethod.GET)
    public @ResponseBody List<OrganizationModel> getOrganizationsForUser() {
        User user = userService.getUserFromSecurityContext();

        return organizationService.createOrganizationModelsWithoutStorageConfiguration(userService.getAdministeredOrganizations(user, SortOrder.ASCENDING), false, SortOrder.ASCENDING);
    }
View Full Code Here

    }

    @PreAuthorize("hasRole('ROLE_USER')")
    @RequestMapping(value = "/activeOrganizations", method = RequestMethod.GET)
    public @ResponseBody List<OrganizationModel> getOrganizations() {
        User user = userService.getUserFromSecurityContext();

        return organizationService.createOrganizationModelsWithoutStorageConfiguration(userService.getOrganizations(user, SortOrder.ASCENDING), false, SortOrder.ASCENDING);
    }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.components.entities.User

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.