Package com.sparc.knappsack.components.entities

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


    @RequestMapping(value = "/manager/editVersion/{parentId}/{versionId}", method = RequestMethod.GET)
    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());
                }
View Full Code Here


            } else {
                return String.format("redirect:/manager/editVersion/%s/%s", parentId, applicationVersionForm.getId());
            }
        }

        ApplicationVersion savedApplicationVersion = null;
        try {
            savedApplicationVersion = applicationVersionControllerService.saveApplicationVersion(applicationVersionForm, true);
        } catch (ApplicationVersionResignException e) {
            log.error(e.getMessage());
            String[] codes = {"desktop.manageApplicationVersion.resignError.generic"};
            ObjectError error = new ObjectError("version", codes, null, null);
            bindingResult.addError(error);

            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.version", bindingResult);
            redirectAttributes.addFlashAttribute("version", applicationVersionForm);

            if (applicationVersionForm.getId() == null || applicationVersionForm.getId() <= 0) {
                return String.format("redirect:/manager/addVersion/%s", parentId, applicationVersionForm.getId());
            } else {
                return String.format("redirect:/manager/editVersion/%s/%s", parentId, applicationVersionForm.getId());
            }
        }

        if (savedApplicationVersion == null || savedApplicationVersion.getId() == null && savedApplicationVersion.getId() <= 0) {
            bindingResult.reject("desktop.manageApplicationVersion.error.generic");
            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.version", bindingResult);
            redirectAttributes.addFlashAttribute("version", applicationVersionForm);

            if (applicationVersionForm.getId() == null || applicationVersionForm.getId() <= 0) {
                return String.format("redirect:/manager/addVersion/%s", parentId, applicationVersionForm.getId());
            } else {
                return String.format("redirect:/manager/editVersion/%s/%s", parentId, applicationVersionForm.getId());
            }
        }

        redirectAttributes.addFlashAttribute("updateSuccess", true);
        return String.format("redirect:/manager/editVersion/%s/%s", parentId, savedApplicationVersion.getId());
    }
View Full Code Here

    @RequestMapping(value = "/webhook/{id}", method = RequestMethod.POST)
    @ResponseStatus(value = HttpStatus.OK)
    public void handleEvent(@PathVariable Long id, @RequestParam(value = "success", required = true) boolean success, @RequestParam(value = "appState", required = true) AppState requestedAppState, @RequestParam(value = "user", required = true) String user, @RequestParam(value = "errorType", required = false) ResignErrorType resignErrorType) {

        ApplicationVersion applicationVersion = applicationVersionService.get(id);
        User initiationUser = userService.getByEmail(user);

        if (applicationVersion != null) {
            EventDeliveryWithComposite deliveryMechanism = eventDeliveryWithCompositeFactory.getEventDelivery(EventType.APPLICATION_VERSION_RESIGN_COMPLETE);
            if (deliveryMechanism != null) {
View Full Code Here

    private ApplicationVersion appVersion1;
    private ApplicationVersion appVersion2;

    @Before
    public void before() throws Exception {
        appVersion1 = new ApplicationVersion();
        appVersion2 = new ApplicationVersion();

        appVersion1.setVersionName("1.0.0");
        appVersion2.setVersionName("2.0.0");
    }
View Full Code Here

        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.
                    if (currentAppState != AppState.RESIGNING && applicationVersionForm.getKeyVaultEntryId() != null && applicationVersionForm.getKeyVaultEntryId() > 0 && domainService.isApplicationResignerEnabled(parentDomain)) {
                        applicationVersionForm.setAppState(AppState.RESIGNING);
                    }

                    // Save the applicationVersion
                    ApplicationVersion savedApplicationVersion = applicationVersionService.saveApplicationVersion(applicationVersionForm);

                    if (savedApplicationVersion != null && savedApplicationVersion.getId() != null && savedApplicationVersion.getId() > 0) {

                        // Update the application version form so that the user can be notified if an error occurs during the resigning staging process.
                        applicationVersionForm.setId(savedApplicationVersion.getId());
                        applicationVersionForm.setEditing(true);

                        // Resign the application if it was requested to be resigned and is not already being resigned
                        if (AppState.RESIGNING.equals(savedApplicationVersion.getAppState()) && !AppState.RESIGNING.equals(requestedAppState)) {
                            boolean resignSuccess = false;
                            KeyVaultEntry keyVaultEntry = keyVaultEntryService.get(applicationVersionForm.getKeyVaultEntryId());

                            resignSuccess = applicationVersionService.resign(savedApplicationVersion, requestedAppState, keyVaultEntry);

                            // Check if application version was successfully staged to be resigned and if not the the application version in an error state.
                            if (!resignSuccess) {

                                // TODO: refactor to send notifications whenever proper audit trail is in place so that admins being notified know why the application version is in the error state.
                                updateApplicationVersionState(savedApplicationVersion, AppState.ERROR, false);
                                throw new ApplicationVersionResignException(ResignErrorType.GENERIC);
                            }
                        }

                        // Send notifications only if the application version is newly persisted or it was being edited and the AppState changed
                        if (sendNotifications && ((currentAppState != null && !currentAppState.equals(savedApplicationVersion.getAppState()))
                                || (EntityState.NEWLY_PERSISTED.equals(savedApplicationVersion.getState()) || !editing))) {
                            sendNotifications(savedApplicationVersion, EventType.APPLICATION_VERSION_STATE_CHANGED);
                        }

                        return savedApplicationVersion;
                    }
View Full Code Here

        return null;
    }

    @Override
    public boolean updateApplicationVersionState(Long applicationVersionId, AppState appState, boolean sendNotifications) {
        ApplicationVersion applicationVersion = applicationVersionService.get(applicationVersionId);

        return updateApplicationVersionState(applicationVersion, appState, sendNotifications);
    }
View Full Code Here

        boolean success = false;

        if (applicationVersion != null && appState != null && !appState.equals(applicationVersion.getAppState())) {
            applicationVersionService.updateAppState(applicationVersion, appState);

            ApplicationVersion updatedApplicationVersion = applicationVersionService.get(applicationVersion.getId());
            if (updatedApplicationVersion != null && appState.equals(updatedApplicationVersion.getAppState())) {
                success = true;

                if (sendNotifications && !AppState.DISABLED.equals(updatedApplicationVersion.getAppState())) {
                    sendNotifications(updatedApplicationVersion, EventType.APPLICATION_VERSION_STATE_CHANGED);
                }
            }
        }
View Full Code Here

    @Autowired(required = true)
    private StorageServiceFactory storageServiceFactory;

    @Override
    public String createIOSPlistXML(Long applicationVersionId, WebRequest webRequest, String token) {
        ApplicationVersion applicationVersion = applicationVersionService.get(applicationVersionId);

        if (applicationVersion == null) {
            return null;
        }

        String downloadUrl = createIOSDownloadIPAUrl(applicationVersion, webRequest, token);
//        String iconUrl = createIOSIconUrl(applicationVersion);

        NSDictionary nsDictionary = createIOSPlistNSDictionary(applicationVersion.getCfBundleIdentifier(), applicationVersion.getCfBundleVersion(), applicationVersion.getCfBundleName(), downloadUrl, null);

        String xmlPlist = null;
        if (nsDictionary != null) {
            xmlPlist = nsDictionary.toXMLPropertyList();
        }
View Full Code Here

TOP

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

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.