Examples of ApplicationForm


Examples of com.sparc.knappsack.forms.ApplicationForm

    private ApplicationForm applicationForm;
    private User user = mock(User.class);

    @Before
    public void setup() {
        applicationForm = new ApplicationForm();
        errors = new BeanPropertyBindingResult(applicationForm, "applicationForm");
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.ApplicationForm

                                       @ApiParam(name = "description", value = "The description of the application", required = true, internalDescription = "java.lang.String") @RequestParam(value = "description", required = true) String description,
                                       @ApiParam(name = "groupId", value = "The group that this application belongs to", required = true, internalDescription = "java.lang.Long") @RequestParam(value = "groupId", required = true) Long groupId,
                                       @ApiParam(name = "name", value = "The name of the application", required = true, internalDescription = "java.lang.String") @RequestParam(value = "name", required = true) String name,
                                       @ApiParam(name = "icon", value = "The icon image file", required = false, internalDescription = "org.springframework.web.multipart.MultipartFile") @RequestParam(value = "icon", required = false) MultipartFile icon) {

        ApplicationForm applicationForm = new ApplicationForm();
        applicationForm.setApplicationType(ApplicationType.valueOf(applicationType));
        applicationForm.setCategoryId(categoryId);
        applicationForm.setDescription(description);
        applicationForm.setGroupId(groupId);
        applicationForm.setName(name);
        if(icon != null) {
            applicationForm.setIcon(icon);
        }

        applicationForm.setContextPath(request.getHeader("origin") + request.getContextPath());

        return applicationService.getApplicationModel(applicationService.saveApplication(applicationForm).getId(), Application.class);
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.ApplicationForm

    @PreAuthorize("isDomainAdmin() or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/addApplication", method = RequestMethod.GET)
    public String addApplication(Model model, @RequestParam(required = false) Long grp) {

        if (!model.containsAttribute("applicationForm")) {
            ApplicationForm applicationForm = new ApplicationForm();
            applicationForm.setApplicationVersion(new ApplicationVersionForm());
            applicationForm.setGroupId(grp);
            model.addAttribute("applicationForm", applicationForm);
        }

        User user = userService.getUserFromSecurityContext();
        Organization organization = user.getActiveOrganization();
View Full Code Here

Examples of com.sparc.knappsack.forms.ApplicationForm

        Application application = applicationService.get(id);

        if (!model.containsAttribute("applicationForm")) {

            ApplicationForm applicationForm = new ApplicationForm();
            applicationForm.setId(application.getId());
            applicationForm.setGroupId(application.getOwnedGroup().getId());
            applicationForm.setApplicationType(application.getApplicationType());
            applicationForm.setDescription(application.getDescription());
            applicationForm.setName(application.getName());
            applicationForm.setCategoryId(application.getCategory().getId());

            StorageService storageService = storageServiceFactory.getStorageService(application.getStorageConfiguration().getStorageType());

            AppFile icon = application.getIcon();
            if (icon != null) {
                MockMultipartFile iconMultipartFile = new MockMultipartFile(application.getIcon().getName(), application.getIcon().getName(), application.getIcon().getType(), new byte[0]);
                applicationForm.setIcon(iconMultipartFile);
                model.addAttribute("icon", appFileService.createImageModel(icon));
            }

            List<AppFile> screenShots = application.getScreenshots();
            List<MultipartFile> screenShotMultipartFiles = new ArrayList<MultipartFile>();
            List<ImageModel> screenshotImageModels = new ArrayList<ImageModel>();
            for (AppFile screenShot : screenShots) {
                MockMultipartFile screenShotMultipartFile = new MockMultipartFile(screenShot.getName(), screenShot.getName(), screenShot.getType(), storageService.getInputStream(screenShot));
                screenShotMultipartFiles.add(screenShotMultipartFile);
                screenshotImageModels.add(appFileService.createImageModel(screenShot));
            }
            applicationForm.setScreenshots(screenShotMultipartFiles);
            model.addAttribute("screenshots", screenshotImageModels);

            model.addAttribute("applicationForm", applicationForm);
        }
View Full Code Here

Examples of com.sparc.knappsack.forms.ApplicationForm

        return ApplicationForm.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        ApplicationForm applicationForm = (ApplicationForm) target;

        validateApplicationLimit(applicationForm, errors);

        if (applicationForm.getApplicationType() == null) {
            errors.rejectValue(APPLICATION_TYPE_FIELD, "applicationValidator.emptyApplicationType");
        }

        if (applicationForm.getName() == null || !StringUtils.hasText(applicationForm.getName())) {
            errors.rejectValue(NAME_FIELD, "applicationValidator.emptyName");
        }

        if (applicationForm.getDescription() == null || !StringUtils.hasText(applicationForm.getDescription())) {
            errors.rejectValue(DESCRIPTION_FIELD, "applicationValidator.emptyDescription");
        }

        if (applicationForm.getCategoryId() == null) {
            errors.rejectValue(CATEGORY_ID_FIELD, "applicationValidator.categoryId");
        }

        BufferedImage bufferedImage = imageValidator.createBufferedImage(applicationForm.getIcon());

        if (applicationForm.getIcon() != null && !imageValidator.isValidImageSize(applicationForm.getIcon(), 819200 /*Bytes: 800 KB*/)) {
            errors.rejectValue(ICON_FIELD, "validator.invalidIconSize");
        }

        if (applicationForm.getIcon() != null && !imageValidator.isValidImageType(applicationForm.getIcon())) {
            errors.rejectValue(ICON_FIELD, "validator.invalidIconType");
        }

        if (applicationForm.getIcon() != null && (!imageValidator.isValidMinDimensions(bufferedImage, 72, 72) || !imageValidator.isSquare(bufferedImage))) {
            errors.rejectValue(ICON_FIELD, "validator.invalidIconDimension");
        }

        validateScreenShots(applicationForm, errors);

View Full Code Here

Examples of com.sparc.knappsack.forms.ApplicationForm

    }

    @Test
    public void saveApplicationTest() {
        Application application = getApplication();
        ApplicationForm applicationForm = new ApplicationForm();
        applicationForm.setApplicationType(application.getApplicationType());
        applicationForm.setCategoryId(application.getCategory().getId());
        applicationForm.setName("New Application");
        applicationForm.setDescription(application.getDescription());
        applicationForm.setGroupId(application.getCategory().getOrganization().getGroups().get(0).getId());
        Application newApplication = applicationService.saveApplication(applicationForm);
        Assert.assertNotNull(newApplication);
    }
View Full Code Here

Examples of org.jmanage.webui.forms.ApplicationForm

                                 HttpServletResponse response)
            throws Exception{
        AccessController.checkAccess(context.getServiceContext(),
                ACL_EDIT_APPLICATIONS);
        ApplicationConfig config = context.getApplicationConfig();
        ApplicationForm appForm = (ApplicationForm)actionForm;
        ApplicationType appType = config.getApplicationType();
        MetaApplicationConfig metaAppConfig =
                appType.getModule().getMetaApplicationConfig();

        /* populate the form */
        appForm.setApplicationId(config.getApplicationId());
        appForm.setName(config.getName());
        appForm.setType(config.getType());
        if(metaAppConfig.isDisplayHost())
            appForm.setHost(config.getHost());
        if(metaAppConfig.isDisplayPort())
            appForm.setPort(String.valueOf(config.getPort()));
        if(metaAppConfig.isDisplayURL())
            appForm.setURL(config.getURL());
        if(metaAppConfig.isDisplayUsername())
            appForm.setUsername(config.getUsername());
        if(metaAppConfig.isDisplayPassword() && config.getPassword() != null
                && config.getPassword().length()>0)
            appForm.setPassword(ApplicationForm.FORM_PASSWORD);

        // for jsr160
        Map paramValues = config.getParamValues();
        appForm.setJndiFactory((String)paramValues.get(ApplicationConfig.JNDI_FACTORY));
        appForm.setJndiURL((String)paramValues.get(ApplicationConfig.JNDI_URL));

        request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig);

        /*set current page for navigation*/
        request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Edit Application");
View Full Code Here

Examples of org.jmanage.webui.forms.ApplicationForm

                                 HttpServletResponse response)
            throws Exception {
        AccessController.checkAccess(context.getServiceContext(),
                ACL_ADD_APPLICATIONS);

        ApplicationForm appForm = (ApplicationForm)actionForm;
        ApplicationType appType =
                ApplicationTypes.getApplicationType(appForm.getType());
        assert appType != null: "Invalid app type: " + appForm.getType();

        if(appForm.getType().equals("connector"))  {
            return mapping.findForward("connector");
        }

        ModuleConfig moduleConfig = appType.getModule();
        MetaApplicationConfig metaAppConfig = moduleConfig.getMetaApplicationConfig();
        request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig);

        appForm.setHost(appType.getDefaultHost());
        appForm.setPort(appType.getDefaultPort());
        appForm.setURL(appType.getDefaultURL());

        /*set current page for navigation*/
        request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Add Application");
        return mapping.findForward(Forwards.SUCCESS);

View Full Code Here

Examples of org.jmanage.webui.forms.ApplicationForm

                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception {
        AccessController.checkAccess(context.getServiceContext(),
                ACL_EDIT_APPLICATIONS);
        ApplicationForm appForm = (ApplicationForm)actionForm;
        ApplicationConfig config=ApplicationConfigManager.deleteApplication
                (appForm.getApplicationId());

        String appType = config.getType();
        if ("connector".equals(appType)) {
            ConnectorRegistry.remove(config);
        }
View Full Code Here

Examples of org.jmanage.webui.forms.ApplicationForm

                                 ActionMapping mapping,
                                 ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception{
        ApplicationForm appForm = (ApplicationForm)actionForm;

        /* create ApplicationConfigData from this form */
        ApplicationConfigData appConfigData = new ApplicationConfigData();
        CoreUtils.copyProperties(appConfigData, appForm);
        Map<String, String> paramValues = new HashMap<String, String>();
        if(appForm.getJndiFactory() != null)
            paramValues.put(ApplicationConfig.JNDI_FACTORY, appForm.getJndiFactory());
        if(appForm.getJndiURL() != null)
            paramValues.put(ApplicationConfig.JNDI_URL, appForm.getJndiURL());
        appConfigData.setParamValues(paramValues);

        ConfigurationService service = ServiceFactory.getConfigurationService();
        appConfigData = service.addApplication(Utils.getServiceContext(context), appConfigData);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.