Package com.sparc.knappsack.components.entities

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


    @RequestMapping(value = "/manager/addVersion/{parentId}", method = RequestMethod.GET)
    public String addApplicationVersion(final HttpServletRequest request, Model model, @PathVariable Long parentId) {

        checkRequiredEntity(applicationService, parentId);

        Application application = applicationService.get(parentId);

        Group group = application.getOwnedGroup();

        model.addAttribute("parentApplicationId", application.getId());
        model.addAttribute("parentApplicationName", application.getName());

        if (!model.containsAttribute("version")) {
            ApplicationVersionForm version = new ApplicationVersionForm();
            version.setParentId(parentId);
            version.setEditing(false);

            model.addAttribute("version", version);
        }

        model.addAttribute("currentGuestGroupIds", new ArrayList<Group>());
        List<Group> groups = new ArrayList<Group>(group.getOrganization().getGroups());
        groups.remove(group);
        model.addAttribute("groups", groups);
        model.addAttribute("isEdit", false);

        // Create a List of all KeyVaultEntries which are available for the given application.
        List<KeyVaultEntryModel> keyVaultEntryModels = new ArrayList<KeyVaultEntryModel>();
        for (KeyVaultEntry keyVaultEntry : keyVaultEntryService.getAllForDomainAndApplicationType(group, application.getApplicationType())) {
            KeyVaultEntryModel keyVaultEntryModel = keyVaultEntryService.convertToModel(keyVaultEntry);
            if (keyVaultEntry != null) {
                keyVaultEntryModels.add(keyVaultEntryModel);
            }
        }
View Full Code Here


    public String editApplicationVersion(final HttpServletRequest request, Model model, @PathVariable Long parentId, @PathVariable Long versionId) {
        checkRequiredEntity(applicationVersionService, versionId);
        checkRequiredEntity(applicationService, parentId);

        ApplicationVersion version = applicationVersionService.get(versionId);
        Application application = applicationService.get(parentId);
        Group group = application.getOwnedGroup();
        if (group != null) {
            model.addAttribute("parentApplicationId", application.getId());
            model.addAttribute("parentApplicationName", application.getName());

            ApplicationVersionForm applicationVersionForm;
            if (model.containsAttribute("version")) {
                applicationVersionForm = (ApplicationVersionForm) model.asMap().get("version");
            } else {
                applicationVersionForm = new ApplicationVersionForm();
            }

            applicationVersionForm.setId(version.getId());
            applicationVersionForm.setRecentChanges(version.getRecentChanges());
            applicationVersionForm.setVersionName(version.getVersionName());
            applicationVersionForm.setParentId(parentId);
            applicationVersionForm.setAppState(version.getAppState());

            if (version.getInstallationFile() != null) {
                MockMultipartFile multipartFile = new MockMultipartFile(version.getInstallationFile().getName(), version.getInstallationFile().getName(), version.getInstallationFile().getType(), new byte[0]);
                applicationVersionForm.setAppFile(multipartFile);
            }

            if (version.getProvisioningProfile() != null) {
                MockMultipartFile multipartFile = new MockMultipartFile(version.getProvisioningProfile().getName(), version.getProvisioningProfile().getName(), version.getProvisioningProfile().getType(), new byte[0]);
                applicationVersionForm.setProvisioningProfile(multipartFile);
            }

            model.addAttribute("version", applicationVersionForm);

            //Put this app versions guest groups on the model so we can highlight them in the multi-select box
            List<Group> currentGuestGroups = version.getGuestGroups();
            Set<Long> currentGuestGroupIds = new HashSet<Long>();
            if (currentGuestGroups != null) {
                for (Group guestGroup : currentGuestGroups) {
                    currentGuestGroupIds.add(guestGroup.getId());
                }
            }
            applicationVersionForm.setGuestGroupIds(new ArrayList<Long>(currentGuestGroupIds));
            model.addAttribute("currentGuestGroupIds", currentGuestGroupIds);
            //We don't want the group that owns the application in the list of guest groups
            List<Group> groups = new ArrayList<Group>(group.getOrganization().getGroups());
            groups.remove(group);
            model.addAttribute("groups", groups);
            model.addAttribute("isEdit", true);

            // Create a List of all KeyVaultEntries which are available for the given application.
            List<KeyVaultEntryModel> keyVaultEntryModels = new ArrayList<KeyVaultEntryModel>();
            for (KeyVaultEntry keyVaultEntry : keyVaultEntryService.getAllForDomainAndApplicationType(group, application.getApplicationType())) {
                KeyVaultEntryModel keyVaultEntryModel = keyVaultEntryService.convertToModel(keyVaultEntry);
                if (keyVaultEntry != null) {
                    keyVaultEntryModels.add(keyVaultEntryModel);
                }
            }
            model.addAttribute("keyVaultEntries", keyVaultEntryModels);

            List<InternationalizedObject> appStates = new ArrayList<InternationalizedObject>();
            for (AppState appState : AppState.values()) {
                try {
                    appStates.add(new InternationalizedObject(appState, messageSource.getMessage(appState.getMessageKey(), null, request.getLocale())));
                } catch (NoSuchMessageException ex) {
                    log.error(String.format("No message for appState: %s", appState.name()), ex);

                    // Put the applicationType name so that the application doesn't error out.
                    appStates.add(new InternationalizedObject(appState, appState.name()));
                }
            }
            model.addAttribute("appStates", appStates);

            return "manager/manageApplicationVersionTH";
        } else {
            throw new EntityNotFoundException(String.format("Group Entity not found for Application: %s", application.getId()));
        }
    }
View Full Code Here

    @PreAuthorize("hasAccessToApplication(#id) or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
    public String loadDetailPage(HttpServletRequest request, Model model,  @PathVariable Long id, UserAgentInfo userAgentInfo) {
        checkRequiredEntity(applicationService, id);
        User user = userService.getUserFromSecurityContext();
        Application application = applicationService.get(id);

        ApplicationModel applicationModel = applicationService.createApplicationModel(application, true);
        if (applicationModel != null) {
            applicationModel.setCanUserEdit(userService.canUserEditApplication(user, application));
        }
View Full Code Here

    @ResponseBody Result unsubscribe(@PathVariable Long applicationId) {
        Result result = new Result();

        User principal = userService.getUserFromSecurityContext();
        if (principal != null) {
            Application application = applicationService.get(applicationId);
            boolean isSubscribed = eventWatchService.doesEventWatchExist(principal, application);
            if(isSubscribed) {
                result.setResult(eventWatchService.delete(principal, applicationService.get(applicationId)));
            }
        } else {
View Full Code Here

    Result subscribe(@PathVariable Long applicationId) {
        Result result = new Result();

        User principal = userService.getUserFromSecurityContext();
        if (principal != null) {
            Application application = applicationService.get(applicationId);
            boolean isSubscribed = eventWatchService.doesEventWatchExist(principal, application);
            if (!isSubscribed) {
                result.setResult(eventWatchService.createEventWatch(principal, application, EventType.APPLICATION_VERSION_BECOMES_AVAILABLE));
            }
        } else {
View Full Code Here

            User user = userService.getUserFromSecurityContext();
            if(user == null) {
                return false;
            }

            Application application = applicationService.get((Long) value);
            if (application != null) {
                return userService.canUserEditApplication(user, application);
            }
        }
View Full Code Here

    private Application application1;
    private Application application2;

    @Before
    public void before() throws Exception {
        application1 = new Application();
        application2 = new Application();

        application1.setDescription("ABC");
        application2.setDescription("ZYX");
    }
View Full Code Here

    private Application application1;
    private Application application2;

    @Before
    public void before() throws Exception {
        application1 = new Application();
        application2 = new Application();

        application1.setName("ABC");
        application2.setName("ZYX");
    }
View Full Code Here

    @Override
    public ApplicationVersion saveApplicationVersion(ApplicationVersionForm applicationVersionForm, boolean sendNotifications) throws ApplicationVersionResignException{

        if (applicationVersionForm != null && applicationVersionForm.getParentId() != null) {

            Application parentApplication = applicationService.get(applicationVersionForm.getParentId());
            if (parentApplication != null) {
                ApplicationVersion currentApplicationVersion = applicationVersionService.get(applicationVersionForm.getId());

                // Check whether we are editing or not.
                boolean editing = false;
                if (currentApplicationVersion != null) {
                    editing = true;
                }

                // Check what the current AppState of the applicationVersion is if the version already exists and is being edited.
                AppState currentAppState = determineCurrentAppState(currentApplicationVersion);

                // Make a copy of the original requested AppState in case the application version is to be resigned.
                AppState requestedAppState = applicationVersionForm.getAppState();

                Domain parentDomain = parentApplication.getOwnedGroup();

                // Only continue if the parent domain exists.
                if (parentDomain != null) {

                    // Set the application version AppState to Resigning if requested.
View Full Code Here

        Long organizationInvitationCount = invitationService.countAll(organizationId);
        boolean hasOrganizationUsers = organizationUserCount > 1 || organizationInvitationCount > 0;
        managerChecklist.setHasOrganizationUsers(hasOrganizationUsers);

        if (appCount == 1) {
            Application application = organizationService.getAllOrganizationApplications(organizationId).get(0);
            managerChecklist.setApplicationId(application.getId());
        }

        if (groupCount == 1) {
            Group group = organizationService.get(organizationId).getGroups().get(0);
            managerChecklist.setGroupId(group.getId());
View Full Code Here

TOP

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

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.