/** * Upload a file from the web * * @return */ public String uploadFromLink() { try { externalUrl = URLDecoder.decode(externalUrl, "UTF-8"); URL url = new URL(externalUrl); title = findFileName(url); File tmp = createTmpFile(); try { StorageController externalController = new StorageController("external"); FileOutputStream fos = new FileOutputStream(tmp); externalController.read(url.toString(), fos, true); Item item = uploadFile(tmp); if (item != null) { UserController uc = new UserController(null); user = uc.retrieve(getUser().getEmail()); ItemController ic = new ItemController(user); ic.create(item, collection.getId()); } externalUrl = ""; } finally { FileUtils.deleteQuietly(tmp); } } catch (Exception e) { logger.error("Error uploading file from link: " + externalUrl, e); fFiles.add(e.getMessage() + ": " + title); } return ""; }
/** Update the {@link Item} for the files which have been uploaded */ private void updateItemForFiles() { ItemController ic = new ItemController(user); try { ic.update(itemList, user); itemList = new ArrayList<Item>(); } catch (Exception e) { logger.error("Error creating files for upload", e); } }
/** Load the collection */ public void loadCollection() { if (id != null) { collection = ObjectLoader.loadCollectionLazy( ObjectHelper.getURI(CollectionImeji.class, id), sessionBean.getUser()); if (collection != null && getCollection().getId() != null) { ItemController ic = new ItemController(sessionBean.getUser()); collectionSize = ic.countContainerSize(collection.getId()); } } else { BeanHelper.error(sessionBean.getLabel("error") + "No ID in URL"); } }
@Override public SearchResult search(SearchQuery searchQuery, SortCriterion sortCriterion) { ItemController controller = new ItemController(sb.getUser()); return controller.search(uri, searchQuery, sortCriterion, null); }