Package com.sparc.knappsack.components.entities

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


    private static final SimpleDateFormat httpDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");

    @RequestMapping(value = "/image/{id}", method = RequestMethod.GET)
    public ResponseEntity<byte[]> getImage(@PathVariable long id, HttpServletRequest request, HttpServletResponse response) {
        checkRequiredEntity(appFileService, id);
        AppFile appFile = appFileService.get(id);

        if (!ContentType.IMAGE.equals(MimeType.getForFilename(appFile.getName()).getContentType())) {
            throw new RuntimeException(String.format("Attempted to pull file which wasn't an image: %s", id));
        }

        response.setHeader("Cache-Control", String.format("public, max-age=%s", 31556900 /*Seconds in a year*/));
        response.setDateHeader("Last-Modified", appFile.getLastUpdate().getTime());

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(appFile.getLastUpdate());
        calendar.add(Calendar.YEAR, 1);
        response.setHeader("Expires", httpDateFormat.format(calendar.getTime()));

        final HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.parseMediaType(appFile.getType()));

        StorageService storageService = storageServiceFactory.getStorageService(appFile.getStorageType());

        long requestIfModifiedSince = request.getDateHeader("If-Modified-Since");
        if (requestIfModifiedSince >= appFile.getLastUpdate().getTime()) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return null;
        }

        if (storageService instanceof RemoteStorageService) {
View Full Code Here


                orgForm.setId(existingOrg.getId());
                orgForm.setStorageConfigurationId(existingOrg.getOrgStorageConfig().getStorageConfigurations().get(0).getId());
                orgForm.setStoragePrefix(existingOrg.getOrgStorageConfig().getPrefix());

                if (existingOrg.getCustomBranding() != null) {
                    AppFile logo = existingOrg.getCustomBranding().getLogo();
                    if (logo != null) {
                        MockMultipartFile logoMultipartFile = new MockMultipartFile(logo.getName(), logo.getName(), logo.getType(), new byte[0]);
                        orgForm.setLogo(logoMultipartFile);
                    }
                    orgForm.setEmailHeader(existingOrg.getCustomBranding().getEmailHeader());
                    orgForm.setEmailFooter(existingOrg.getCustomBranding().getEmailFooter());
                    orgForm.setSubdomain(existingOrg.getCustomBranding().getSubdomain());
View Full Code Here

                categoryForm.setDescription(category.getDescription());
                categoryForm.setId(category.getId());
                categoryForm.setName(category.getName());
                categoryForm.setStorageConfigurationId(category.getStorageConfiguration().getId());

                AppFile icon = category.getIcon();
                if (icon != null) {
                    MockMultipartFile iconMultipartFile = new MockMultipartFile(category.getIcon().getName(), category.getIcon().getName(), category.getIcon().getType(), new byte[0]);
                    categoryForm.setIcon(iconMultipartFile);
                }
View Full Code Here

    }

    @Override
    public AppFileModel createAppFileModel(Long appFileId) {
        AppFileModel model = null;
        AppFile appFile = get(appFileId);
        if (appFile != null) {
            model = new AppFileModel();
            model.setId(appFile.getId());
            model.setName(appFile.getName());
            model.setRelativePath(appFile.getRelativePath());
            model.setSize(appFile.getSize());
            model.setStorageType(appFile.getStorageType());
            model.setType(appFile.getType());
        }
        return model;
    }
View Full Code Here

                        modelAndView.getModel().put("orgName", organization.getName());
                        CustomBranding customBranding = organization.getCustomBranding();
                        if (customBranding != null) {

                            // Add logo URL to model is exists
                            AppFile logo = customBranding.getLogo();
                            if (logo != null) {
                                modelAndView.getModel().put("customLogoURL", appFileService.getImageUrl(logo));
                                modelAndView.getModel().put("customLogoOrganizationName", StringUtils.trimTrailingWhitespace(organization.getName()));
                            }
View Full Code Here

    protected OrgStorageConfigService orgStorageConfigService;

    protected abstract StorageType getStorageType();

    protected final AppFile createAppFile(String path, MultipartFile multipartFile) {
        AppFile file = new AppFile();
        file.setName(multipartFile.getOriginalFilename());

        String contentType = multipartFile.getContentType();
        MimeType mimeType = MimeType.getForFilename(multipartFile.getOriginalFilename());
        if (mimeType != null) {
            contentType = mimeType.getMimeType();
        }
        file.setType(contentType);

        double megabyteSize = multipartFile.getSize() / MEGABYTE_CONVERSION;
        file.setSize(megabyteSize);
        file.setRelativePath(path + multipartFile.getOriginalFilename());
        file.setStorageType(getStorageType());

        return file;
    }
View Full Code Here

        if (storageConfigurationId == null) {
            storageConfigurationId = category.getStorageConfiguration().getId();
        }

        category.setStorageConfiguration(storageConfigurationService.get(storageConfigurationId));
        AppFile icon = createIcon(categoryForm.getIcon(), orgStorageConfigId, storageConfigurationId, category.getUuid());
        if (icon != null) {
            icon.setStorable(category);
            category.setIcon(icon);
        }

        save(category);
    }
View Full Code Here

    }

    @Override
    public void deleteIcon(Category category) {
        if (category != null) {
            AppFile appFile = category.getIcon();
            category.setIcon(null);
            appFileService.delete(appFile);
        }
    }
View Full Code Here

        entertainmentCategory.setStorageConfiguration(storageConfiguration);
        entertainmentCategory.setOrganization(organization);
        organization.getCategories().add(entertainmentCategory);
        add(entertainmentCategory);

        AppFile icon = createIcon(entertainmentIcon, orgStorageConfigId, storageConfigId, entertainmentCategory.getUuid());
        if (icon != null) {
            icon.setStorable(entertainmentCategory);
            entertainmentCategory.setIcon(icon);
        }
        defaultCategories.add(entertainmentCategory);

        /**
         * Create productivity category
         */
        Category productivityCategory = new Category();
        productivityCategory.setName("Productivity");
        productivityCategory.setDescription("Applications to make your day to day more efficient.");
        productivityCategory.setStorageConfiguration(storageConfiguration);
        productivityCategory.setOrganization(organization);
        organization.getCategories().add(productivityCategory);
        add(productivityCategory);

        icon = createIcon(productivityIcon, orgStorageConfigId, storageConfigId, productivityCategory.getUuid());
        if (icon != null) {
            icon.setStorable(productivityCategory);
            productivityCategory.setIcon(icon);
        }
        defaultCategories.add(productivityCategory);

        /**
         * Create utilities category
         */
        Category utilitiesCategory = new Category();
        utilitiesCategory.setName("Utilities");
        utilitiesCategory.setDescription("Applications with a specific skill set.");
        utilitiesCategory.setStorageConfiguration(storageConfiguration);
        utilitiesCategory.setOrganization(organization);
        organization.getCategories().add(utilitiesCategory);
        add(utilitiesCategory);

        icon = createIcon(utilitiesIcon, orgStorageConfigId, storageConfigId, utilitiesCategory.getUuid());
        if (icon != null) {
            icon.setStorable(utilitiesCategory);
            utilitiesCategory.setIcon(icon);
        }
        defaultCategories.add(utilitiesCategory);

        return defaultCategories;
View Full Code Here

        }
        return xmlPlist;
    }

    private String createIOSDownloadIPAUrl(ApplicationVersion version, WebRequest request, String token) {
        AppFile appFile = version.getInstallationFile();

        StorageService storageService = storageServiceFactory.getStorageService(appFile.getStorageType());
        if (storageService instanceof RemoteStorageService) {
            return ((RemoteStorageService) storageService).getUrl(appFile, 14400 /*4 hours*/);
        }

        NameValuePair tokenParam = new BasicNameValuePair("token", token);
View Full Code Here

TOP

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

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.