public Application uploadFile( String fileName, InputStream uploadedInputStream, Category category, Application application) throws InvalidAttribute { logger.debug( "File being upload: " + fileName + " category: " + category + " application: " + application.getAppName()); String categType = null; if (category != null) categType = category.getCategType(); if (StringUtils.isEmpty(categType)) { categType = "Default"; } // save it try { // util.createUserDir(uploadedFileLocation, category); return util.uploadFile(uploadedInputStream, storeAppPath, fileName, categType, application); } catch (IOException e) { logger.error("Error occurred while uploading file", e); } return null; }
private AppDetails convertToAppDetails(Application application) { AppDetails appDetails = new AppDetails(); logger.debug("Convert Application: " + application + " to AppDetails"); Category category = categoryDao.getCategory(application.getAppCategId()); logger.debug("Category :" + category); appDetails.setId(application.getAppId()); appDetails.setCategoryName(category.getCategType()); appDetails.setDescription(application.getDescription()); appDetails.setName(application.getAppName()); appDetails.setUrl(application.getUrl()); appDetails.setIconUrl(application.getIconUrl()); appDetails.setDeveloper(application.getDeveloprName()); appDetails.setSize(application.getAppSize()); logger.debug("AppDetails : " + appDetails); return appDetails; }
public Application storeFile( String fileName, InputStream uploadedInputStream, Application application) throws InvalidAttribute { Category category = categoryDao.getCategory(application.getAppCategId()); // save to file system Application app = uploadFile(fileName, uploadedInputStream, category, application); // save to database logger.debug("Inserting new app's details to database: " + app); appDao.createApplication(app); return app; }