Example #1
0
 // returns absolute URL to download content of bitstream (which might not belong to any Item)
 protected String urlOfBitstream(HttpServletRequest request, Bitstream logo) {
   String name = logo.getName();
   return resolveURL(request, null)
       + (uiType.equalsIgnoreCase(UITYPE_XMLUI) ? "/bitstream/id/" : "/retrieve/")
       + logo.getID()
       + "/"
       + (name == null ? "" : name);
 }
Example #2
0
 /**
  * Returns canonical link to a bitstream in the item.
  *
  * @param item The DSpace Item that the bitstream is part of
  * @param bitstream The bitstream to link to
  * @returns a String link to the bitstream
  */
 private String makeBitstreamLink(Item item, Bitstream bitstream) {
   String name = bitstream.getName();
   StringBuilder result = new StringBuilder(contextPath);
   result.append("/bitstream/item/").append(String.valueOf(item.getID()));
   // append name although it isn't strictly necessary
   try {
     if (name != null) {
       result.append("/").append(Util.encodeBitstreamName(name, "UTF-8"));
     }
   } catch (UnsupportedEncodingException uee) {
     // just ignore it, we don't have to have a pretty
     // name on the end of the url because the sequence id will
     // locate it. However it means that links in this file might
     // not work....
   }
   result.append("?sequence=").append(String.valueOf(bitstream.getSequenceID()));
   return result.toString();
 }
Example #3
0
  /**
   * Store a copy of the license a user granted in the item.
   *
   * @param context the dspace context
   * @param item the item object of the license
   * @param licenseText the license the user granted
   * @throws SQLException
   * @throws IOException
   * @throws AuthorizeException
   */
  public static void grantLicense(Context context, Item item, String licenseText)
      throws SQLException, IOException, AuthorizeException {
    // Put together text to store
    // String licenseText = "License granted by " + eperson.getFullName()
    // + " (" + eperson.getEmail() + ") on "
    // + DCDate.getCurrent().toString() + " (GMT):\n\n" + license;

    // Store text as a bitstream
    byte[] licenseBytes = licenseText.getBytes();
    ByteArrayInputStream bais = new ByteArrayInputStream(licenseBytes);
    Bitstream b = item.createSingleBitstream(bais, "LICENSE");

    // Now set the format and name of the bitstream
    b.setName("license.txt");
    b.setSource("Written by org.dspace.content.LicenseUtils");

    // Find the License format
    BitstreamFormat bf = BitstreamFormat.findByShortDescription(context, "License");
    b.setFormat(bf);

    b.update();
  }
  /**
   * Attempt to identify the format of a particular bitstream. If the format is unknown, null is
   * returned.
   *
   * @param bitstream the bitstream to identify the format of
   * @return a format from the bitstream format registry, or null
   */
  public static BitstreamFormat guessFormat(Context context, Bitstream bitstream)
      throws SQLException {
    // FIXME: Just setting format to first guess
    // For now just get the file name
    String filename = bitstream.getName().toLowerCase();

    // Gracefully handle the null case
    if (filename == null) {
      return null;
    }

    // This isn't rocket science. We just get the name of the
    // bitstream, get the extension, and see if we know the type.
    String extension = filename;
    int lastDot = filename.lastIndexOf('.');

    if (lastDot != -1) {
      extension = filename.substring(lastDot + 1);
    }

    // If the last character was a dot, then extension will now be
    // an empty string. If this is the case, we don't know what
    // file type it is.
    if (extension.equals("")) {
      return null;
    }

    // See if the extension is in the fileextension table
    TableRowIterator tri =
        DatabaseManager.query(
            context,
            "SELECT bitstreamformatregistry.* FROM bitstreamformatregistry, "
                + "fileextension WHERE fileextension.extension LIKE ? "
                + "AND bitstreamformatregistry.bitstream_format_id="
                + "fileextension.bitstream_format_id",
            extension);

    BitstreamFormat retFormat = null;
    try {
      if (tri.hasNext()) {
        // Return first match
        retFormat = new BitstreamFormat(context, tri.next());
      } else {
        retFormat = null;
      }
    } finally {
      // close the TableRowIterator to free up resources
      if (tri != null) tri.close();
    }
    return retFormat;
  }
Example #5
0
  @Override
  public Bitstream setLogo(Context context, Community community, InputStream is)
      throws AuthorizeException, IOException, SQLException {
    // Check authorisation
    // authorized to remove the logo when DELETE rights
    // authorized when canEdit
    if (!((is == null)
        && authorizeService.authorizeActionBoolean(context, community, Constants.DELETE))) {
      canEdit(context, community);
    }

    // First, delete any existing logo
    Bitstream oldLogo = community.getLogo();
    if (oldLogo != null) {
      log.info(LogManager.getHeader(context, "remove_logo", "community_id=" + community.getID()));
      community.setLogo(null);
      bitstreamService.delete(context, oldLogo);
    }

    if (is != null) {
      Bitstream newLogo = bitstreamService.create(context, is);
      community.setLogo(newLogo);

      // now create policy for logo bitstream
      // to match our READ policy
      List<ResourcePolicy> policies =
          authorizeService.getPoliciesActionFilter(context, community, Constants.READ);
      authorizeService.addPolicies(context, policies, newLogo);

      log.info(
          LogManager.getHeader(
              context,
              "set_logo",
              "community_id=" + community.getID() + "logo_bitstream_id=" + newLogo.getID()));
    }

    return community.getLogo();
  }
Example #6
0
  /**
   * Each submission step must define its own information to be reviewed during the final
   * Review/Verify Step in the submission process.
   *
   * <p>The information to review should be tacked onto the passed in List object.
   *
   * <p>NOTE: To remain consistent across all Steps, you should first add a sub-List object (with
   * this step's name as the heading), by using a call to reviewList.addList(). This sublist is the
   * list you return from this method!
   *
   * @param reviewList The List to which all reviewable information should be added
   * @return The new sub-List object created by this step, which contains all the reviewable
   *     information. If this step has nothing to review, then return null!
   */
  public List addReviewSection(List reviewList)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // Create a new list section for this step (and set its heading)
    List uploadSection = reviewList.addList("submit-review-" + this.stepAndPage, List.TYPE_FORM);
    uploadSection.setHead(T_head);

    // Review all uploaded files
    Item item = submission.getItem();
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    for (Bitstream bitstream : bitstreams) {
      BitstreamFormat bitstreamFormat = bitstream.getFormat();

      String name = bitstream.getName();
      String url = makeBitstreamLink(item, bitstream);
      String format = bitstreamFormat.getShortDescription();
      Message support = ReviewStep.T_unknown;
      if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN) {
        support = T_known;
      } else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED) {
        support = T_supported;
      }

      org.dspace.app.xmlui.wing.element.Item file = uploadSection.addItem();
      file.addXref(url, name);
      file.addContent(" - " + format + " ");
      file.addContent(support);
    }

    // return this new "upload" section
    return uploadSection;
  }
Example #7
0
 /**
  * Generic find for when the precise type of a DSO is not known, just the a pair of type number
  * and database ID.
  *
  * @param context - the context
  * @param type - type number
  * @param id - id within table of type'd objects
  * @return the object found, or null if it does not exist.
  * @throws SQLException only upon failure accessing the database.
  */
 public static DSpaceObject find(Context context, int type, int id) throws SQLException {
   switch (type) {
     case Constants.BITSTREAM:
       return Bitstream.find(context, id);
     case Constants.BUNDLE:
       return Bundle.find(context, id);
     case Constants.ITEM:
       return Item.find(context, id);
     case Constants.COLLECTION:
       return Collection.find(context, id);
     case Constants.COMMUNITY:
       return Community.find(context, id);
     case Constants.GROUP:
       return Group.find(context, id);
     case Constants.EPERSON:
       return EPerson.find(context, id);
     case Constants.SITE:
       return Site.find(context, id);
   }
   return null;
 }
Example #8
0
  /**
   * Check to see if the given user can perform the given action on the given object. Always returns
   * true if the ignore authorization flat is set in the current context.
   *
   * @param c current context. User is irrelevant; "ignore authorization" flag is relevant
   * @param o object action is being attempted on
   * @param action ID of action being attempted, from <code>org.dspace.core.Constants</code>
   * @param e user attempting action
   * @param useInheritance flag to say if ADMIN action on the current object or parent object can be
   *     used
   * @return <code>true</code> if user is authorized to perform the given action, <code>false</code>
   *     otherwise
   * @throws SQLException if database error
   */
  protected boolean authorize(
      Context c, DSpaceObject o, int action, EPerson e, boolean useInheritance)
      throws SQLException {
    // return FALSE if there is no DSpaceObject
    if (o == null) {
      return false;
    }

    // is authorization disabled for this context?
    if (c.ignoreAuthorization()) {
      return true;
    }

    // is eperson set? if not, userToCheck = null (anonymous)
    EPerson userToCheck = null;
    if (e != null) {
      userToCheck = e;

      // perform isAdmin check to see
      // if user is an Admin on this object
      DSpaceObject adminObject =
          useInheritance
              ? serviceFactory.getDSpaceObjectService(o).getAdminObject(c, o, action)
              : null;

      if (isAdmin(c, adminObject)) {
        return true;
      }
    }

    // In case the dso is an bundle or bitstream we must ignore custom
    // policies if it does not belong to at least one installed item (see
    // DS-2614).
    // In case the dso is an item and a corresponding workspace or workflow
    // item exist, we have to ignore custom policies (see DS-2614).
    boolean ignoreCustomPolicies = false;
    if (o instanceof Bitstream) {
      Bitstream b = (Bitstream) o;

      // Ensure that this is not a collection or community logo
      DSpaceObject parent = bitstreamService.getParentObject(c, b);
      if (!(parent instanceof Collection) && !(parent instanceof Community)) {
        ignoreCustomPolicies = !isAnyItemInstalled(c, b.getBundles());
      }
    }
    if (o instanceof Bundle) {
      ignoreCustomPolicies = !isAnyItemInstalled(c, Arrays.asList(((Bundle) o)));
    }
    if (o instanceof Item) {
      if (workspaceItemService.findByItem(c, (Item) o) != null
          || workflowItemService.findByItem(c, (Item) o) != null) {
        ignoreCustomPolicies = true;
      }
    }

    for (ResourcePolicy rp : getPoliciesActionFilter(c, o, action)) {

      if (ignoreCustomPolicies && ResourcePolicy.TYPE_CUSTOM.equals(rp.getRpType())) {
        continue;
      }

      // check policies for date validity
      if (resourcePolicyService.isDateValid(rp)) {
        if (rp.getEPerson() != null && rp.getEPerson().equals(userToCheck)) {
          return true; // match
        }

        if ((rp.getGroup() != null) && (groupService.isMember(c, rp.getGroup()))) {
          // group was set, and eperson is a member
          // of that group
          return true;
        }
      }
    }

    // default authorization is denial
    return false;
  }
Example #9
0
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // If we are actually editing information of an uploaded file,
    // then display that body instead!
    if (this.editFile != null) {
      editFile.addBody(body);
      return;
    }

    // Get a list of all files in the original bundle
    Item item = submission.getItem();
    Collection collection = submission.getCollection();
    String actionURL =
        contextPath + "/handle/" + collection.getHandle() + "/submit/" + knot.getId() + ".continue";
    boolean disableFileEditing =
        (submissionInfo.isInWorkflow())
            && !ConfigurationManager.getBooleanProperty("workflow", "reviewer.file-edit");
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    // Part A:
    //  First ask the user if they would like to upload a new file (may be the first one)
    Division div =
        body.addInteractiveDivision(
            "submit-upload", actionURL, Division.METHOD_MULTIPART, "primary submission");
    div.setHead(T_submission_head);
    addSubmissionProgressList(div);

    List upload = null;
    if (!disableFileEditing) {
      // Only add the upload capabilities for new item submissions
      upload = div.addList("submit-upload-new", List.TYPE_FORM);
      upload.setHead(T_head);
      addRioxxVersionSection(upload, item);

      File file = upload.addItem().addFile("file");
      file.setLabel(T_file);
      file.setHelp(T_file_help);
      file.setRequired();

      // if no files found error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_NO_FILES_ERROR) {
        file.addError(T_file_error);
      }

      // if an upload error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_UPLOAD_ERROR) {
        file.addError(T_upload_error);
      }

      // if virus checking was attempted and failed in error then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_VIRUS_CHECKER_UNAVAILABLE) {
        file.addError(T_virus_checker_error);
      }

      // if virus checking was attempted and a virus found then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_CONTAINS_VIRUS) {
        file.addError(T_virus_error);
      }

      Text description = upload.addItem().addText("description");
      description.setLabel(T_description);
      description.setHelp(T_description_help);

      Button uploadSubmit = upload.addItem().addButton("submit_upload");
      uploadSubmit.setValue(T_submit_upload);
    }

    make_sherpaRomeo_submission(item, div);

    // Part B:
    //  If the user has already uploaded files provide a list for the user.
    if (bitstreams.length > 0 || disableFileEditing) {
      Table summary = div.addTable("submit-upload-summary", (bitstreams.length * 2) + 2, 7);
      summary.setHead(T_head2);

      Row header = summary.addRow(Row.ROLE_HEADER);
      header.addCellContent(T_column0); // primary bitstream
      header.addCellContent(T_column1); // select checkbox
      header.addCellContent(T_column2); // file name
      header.addCellContent(T_column3); // size
      header.addCellContent(T_column4); // description
      header.addCellContent(T_column5); // format
      header.addCellContent(T_column6); // edit button

      for (Bitstream bitstream : bitstreams) {
        int id = bitstream.getID();
        String name = bitstream.getName();
        String url = makeBitstreamLink(item, bitstream);
        long bytes = bitstream.getSize();
        String desc = bitstream.getDescription();
        String algorithm = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();

        Row row = summary.addRow();

        // Add radio-button to select this as the primary bitstream
        Radio primary = row.addCell().addRadio("primary_bitstream_id");
        primary.addOption(String.valueOf(id));

        // If this bitstream is already marked as the primary bitstream
        // mark it as such.
        if (bundles[0].getPrimaryBitstreamID() == id) {
          primary.setOptionSelected(String.valueOf(id));
        }

        if (!disableFileEditing) {
          // Workflow users can not remove files.
          CheckBox remove = row.addCell().addCheckBox("remove");
          remove.setLabel("remove");
          remove.addOption(id);
        } else {
          row.addCell();
        }

        row.addCell().addXref(url, name);
        row.addCellContent(bytes + " bytes");
        if (desc == null || desc.length() == 0) {
          row.addCellContent(T_unknown_name);
        } else {
          row.addCellContent(desc);
        }

        BitstreamFormat format = bitstream.getFormat();
        if (format == null) {
          row.addCellContent(T_unknown_format);
        } else {
          int support = format.getSupportLevel();
          Cell cell = row.addCell();
          cell.addContent(format.getMIMEType());
          cell.addContent(" ");
          switch (support) {
            case 1:
              cell.addContent(T_supported);
              break;
            case 2:
              cell.addContent(T_known);
              break;
            case 3:
              cell.addContent(T_unsupported);
              break;
          }
        }

        Button edit = row.addCell().addButton("submit_edit_" + id);
        edit.setValue(T_submit_edit);

        Row checksumRow = summary.addRow();
        checksumRow.addCell();
        Cell checksumCell = checksumRow.addCell(null, null, 0, 6, null);
        checksumCell.addHighlight("bold").addContent(T_checksum);
        checksumCell.addContent(" ");
        checksumCell.addContent(algorithm + ":" + checksum);
      }

      if (!disableFileEditing) {
        // Workflow users can not remove files.
        Row actionRow = summary.addRow();
        actionRow.addCell();
        Button removeSeleceted =
            actionRow.addCell(null, null, 0, 6, null).addButton("submit_remove_selected");
        removeSeleceted.setValue(T_submit_remove);
      }

      upload = div.addList("submit-upload-new-part2", List.TYPE_FORM);
    }

    // Part C:
    // add standard control/paging buttons
    addControlButtons(upload);
  }
Example #10
0
  /**
   * Fills in the feed and entry-level metadata from DSpace objects.
   *
   * @param request request
   * @param context context
   * @param dso DSpaceObject
   * @param items array of objects
   * @param labels label map
   */
  public void populate(
      HttpServletRequest request,
      Context context,
      DSpaceObject dso,
      List<? extends DSpaceObject> items,
      Map<String, String> labels) {
    String logoURL = null;
    String objectURL = null;
    String defaultTitle = null;
    boolean podcastFeed = false;
    this.request = request;

    // dso is null for the whole site, or a search without scope
    if (dso == null) {
      defaultTitle = ConfigurationManager.getProperty("dspace.name");
      feed.setDescription(localize(labels, MSG_FEED_DESCRIPTION));
      objectURL = resolveURL(request, null);
      logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
    } else {
      Bitstream logo = null;
      if (dso.getType() == Constants.COLLECTION) {
        Collection col = (Collection) dso;
        defaultTitle = col.getName();
        feed.setDescription(collectionService.getMetadata(col, "short_description"));
        logo = col.getLogo();
        String cols = ConfigurationManager.getProperty("webui.feed.podcast.collections");
        if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
          podcastFeed = true;
        }
      } else if (dso.getType() == Constants.COMMUNITY) {
        Community comm = (Community) dso;
        defaultTitle = comm.getName();
        feed.setDescription(communityService.getMetadata(comm, "short_description"));
        logo = comm.getLogo();
        String comms = ConfigurationManager.getProperty("webui.feed.podcast.communities");
        if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
          podcastFeed = true;
        }
      }
      objectURL = resolveURL(request, dso);
      if (logo != null) {
        logoURL = urlOfBitstream(request, logo);
      }
    }
    feed.setTitle(
        labels.containsKey(MSG_FEED_TITLE) ? localize(labels, MSG_FEED_TITLE) : defaultTitle);
    feed.setLink(objectURL);
    feed.setPublishedDate(new Date());
    feed.setUri(objectURL);

    // add logo if we found one:
    if (logoURL != null) {
      // we use the path to the logo for this, the logo itself cannot
      // be contained in the rdf. Not all RSS-viewers show this logo.
      SyndImage image = new SyndImageImpl();
      image.setLink(objectURL);
      if (StringUtils.isNotBlank(feed.getTitle())) {
        image.setTitle(feed.getTitle());
      } else {
        image.setTitle(localize(labels, MSG_LOGO_TITLE));
      }
      image.setUrl(logoURL);
      feed.setImage(image);
    }

    // add entries for items
    if (items != null) {
      List<SyndEntry> entries = new ArrayList<SyndEntry>();
      for (DSpaceObject itemDSO : items) {
        if (itemDSO.getType() != Constants.ITEM) {
          continue;
        }
        Item item = (Item) itemDSO;
        boolean hasDate = false;
        SyndEntry entry = new SyndEntryImpl();
        entries.add(entry);

        String entryURL = resolveURL(request, item);
        entry.setLink(entryURL);
        entry.setUri(entryURL);

        String title = getOneDC(item, titleField);
        entry.setTitle(title == null ? localize(labels, MSG_UNTITLED) : title);

        // "published" date -- should be dc.date.issued
        String pubDate = getOneDC(item, dateField);
        if (pubDate != null) {
          entry.setPublishedDate((new DCDate(pubDate)).toDate());
          hasDate = true;
        }
        // date of last change to Item
        entry.setUpdatedDate(item.getLastModified());

        StringBuffer db = new StringBuffer();
        for (String df : descriptionFields) {
          // Special Case: "(date)" in field name means render as date
          boolean isDate = df.indexOf("(date)") > 0;
          if (isDate) {
            df = df.replaceAll("\\(date\\)", "");
          }

          List<MetadataValue> dcv = itemService.getMetadataByMetadataString(item, df);
          if (dcv.size() > 0) {
            String fieldLabel = labels.get(MSG_METADATA + df);
            if (fieldLabel != null && fieldLabel.length() > 0) {
              db.append(fieldLabel).append(": ");
            }
            boolean first = true;
            for (MetadataValue v : dcv) {
              if (first) {
                first = false;
              } else {
                db.append("; ");
              }
              db.append(isDate ? new DCDate(v.getValue()).toString() : v.getValue());
            }
            db.append("\n");
          }
        }
        if (db.length() > 0) {
          SyndContent desc = new SyndContentImpl();
          desc.setType("text/plain");
          desc.setValue(db.toString());
          entry.setDescription(desc);
        }

        // This gets the authors into an ATOM feed
        List<MetadataValue> authors = itemService.getMetadataByMetadataString(item, authorField);
        if (authors.size() > 0) {
          List<SyndPerson> creators = new ArrayList<SyndPerson>();
          for (MetadataValue author : authors) {
            SyndPerson sp = new SyndPersonImpl();
            sp.setName(author.getValue());
            creators.add(sp);
          }
          entry.setAuthors(creators);
        }

        // only add DC module if any DC fields are configured
        if (dcCreatorField != null || dcDateField != null || dcDescriptionField != null) {
          DCModule dc = new DCModuleImpl();
          if (dcCreatorField != null) {
            List<MetadataValue> dcAuthors =
                itemService.getMetadataByMetadataString(item, dcCreatorField);
            if (dcAuthors.size() > 0) {
              List<String> creators = new ArrayList<String>();
              for (MetadataValue author : dcAuthors) {
                creators.add(author.getValue());
              }
              dc.setCreators(creators);
            }
          }
          if (dcDateField != null && !hasDate) {
            List<MetadataValue> v = itemService.getMetadataByMetadataString(item, dcDateField);
            if (v.size() > 0) {
              dc.setDate((new DCDate(v.get(0).getValue())).toDate());
            }
          }
          if (dcDescriptionField != null) {
            List<MetadataValue> v =
                itemService.getMetadataByMetadataString(item, dcDescriptionField);
            if (v.size() > 0) {
              StringBuffer descs = new StringBuffer();
              for (MetadataValue d : v) {
                if (descs.length() > 0) {
                  descs.append("\n\n");
                }
                descs.append(d.getValue());
              }
              dc.setDescription(descs.toString());
            }
          }
          entry.getModules().add(dc);
        }

        // iTunes Podcast Support - START
        if (podcastFeed) {
          // Add enclosure(s)
          List<SyndEnclosure> enclosures = new ArrayList();
          try {
            List<Bundle> bunds = itemService.getBundles(item, "ORIGINAL");
            if (bunds.get(0) != null) {
              List<Bitstream> bits = bunds.get(0).getBitstreams();
              for (Bitstream bit : bits) {
                String mime = bit.getFormat(context).getMIMEType();
                if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
                  SyndEnclosure enc = new SyndEnclosureImpl();
                  enc.setType(bit.getFormat(context).getMIMEType());
                  enc.setLength(bit.getSize());
                  enc.setUrl(urlOfBitstream(request, bit));
                  enclosures.add(enc);
                } else {
                  continue;
                }
              }
            }
            // Also try to add an external value from dc.identifier.other
            // We are assuming that if this is set, then it is a media file
            List<MetadataValue> externalMedia =
                itemService.getMetadataByMetadataString(item, externalSourceField);
            if (externalMedia.size() > 0) {
              for (MetadataValue anExternalMedia : externalMedia) {
                SyndEnclosure enc = new SyndEnclosureImpl();
                enc.setType(
                    "audio/x-mpeg"); // We can't determine MIME of external file, so just picking
                                     // one.
                enc.setLength(1);
                enc.setUrl(anExternalMedia.getValue());
                enclosures.add(enc);
              }
            }

          } catch (Exception e) {
            System.out.println(e.getMessage());
          }
          entry.setEnclosures(enclosures);

          // Get iTunes specific fields: author, subtitle, summary, duration, keywords
          EntryInformation itunes = new EntryInformationImpl();

          String author = getOneDC(item, authorField);
          if (author != null && author.length() > 0) {
            itunes.setAuthor(author); // <itunes:author>
          }

          itunes.setSubtitle(
              title == null ? localize(labels, MSG_UNTITLED) : title); // <itunes:subtitle>

          if (db.length() > 0) {
            itunes.setSummary(db.toString()); // <itunes:summary>
          }

          String extent =
              getOneDC(
                  item,
                  "dc.format.extent"); // assumed that user will enter this field with length of
                                       // song in seconds
          if (extent != null && extent.length() > 0) {
            extent = extent.split(" ")[0];
            Integer duration = Integer.parseInt(extent);
            itunes.setDuration(new Duration(duration)); // <itunes:duration>
          }

          String subject = getOneDC(item, "dc.subject");
          if (subject != null && subject.length() > 0) {
            String[] subjects = new String[1];
            subjects[0] = subject;
            itunes.setKeywords(subjects); // <itunes:keywords>
          }

          entry.getModules().add(itunes);
        }
      }
      feed.setEntries(entries);
    }
  }