예제 #1
0
 public void deleteImage(int articleId) throws IOException {
   Article article = em.find(Article.class, articleId);
   if (article == null) {
     throw new RuntimeException("No such article");
   }
   if (!article.getOwner().equals(plAccess.getUser().getLoginName())) {
     throw new RuntimeException("The user has no such article.");
   }
   String oldImageId = article.getImageId();
   if (oldImageId != null) {
     store.delete(store.createUrl(oldImageId));
   }
   article.setImageId(null);
 }
예제 #2
0
  private void markAsUnpublished(ZdoModel model, ZdoModel kdrModel) throws IOException {
    if (ZdoGroup.ZDO.name().equals(model.get(ZdoTerms.group))) {
      model.replaceValueOfProperty(ZdoTerms.group, ZdoGroup.UNPUBLISHED.name());

      // Unlock kdr object
      kdrModel.decreaseLockCount();
      String pdfUrl = kdrModel.get(ZdoTerms.pdfUrl);
      String epubUrl = kdrModel.get(ZdoTerms.epubUrl);
      if (pdfUrl != null) {
        store.delete(pdfUrl);
        kdrModel.removeAllValuesOfProperty(ZdoTerms.pdfUrl);
      }
      if (epubUrl != null) {
        store.delete(epubUrl);
        kdrModel.removeAllValuesOfProperty(ZdoTerms.epubUrl);
      }

      // And unindex original published doc
      if (ZdoType.isRootCategory(model.get(ZdoTerms.zdoType))) {
        rootsToDelete.add(store.getOnlyIdFromUrl(model.getUrl()));
      }
    }
  }
예제 #3
0
  public void uploadImage(int articleId, MultipartFormDataInput input) throws IOException {
    Article article = em.find(Article.class, articleId);
    if (article == null) {
      throw new RuntimeException("No such article");
    }
    if (!article.getOwner().equals(plAccess.getUser().getLoginName())) {
      throw new RuntimeException("The user has no such article.");
    }
    String oldImageId = article.getImageId();
    if (oldImageId != null) {
      store.delete(store.createUrl(oldImageId));
    }

    String uuid = imgUploadTools.uploadedFileToFedora(input, ZdoFileType.articleImage);
    article.setImageId(uuid);
  }