Beispiel #1
0
 /**
  * True if the filename is already used by an {@link Item} in this {@link CollectionImeji}
  *
  * @param filename
  * @return
  */
 private boolean filenameExistsInCollection(String filename) {
   Search s = new Search(SearchType.ITEM, null);
   return s.searchSimpleForQuery(
               SPARQLQueries.selectContainerItemByFilename(
                   collection.getId(), FilenameUtils.getBaseName(filename)),
               null)
           .size()
       > 0;
 }
Beispiel #2
0
 /**
  * Search for an item in the current collection with the same filename. The filename must be
  * unique!
  *
  * @param filename
  * @return
  */
 private Item findItemByFileName(String filename) {
   Search s = new Search(SearchType.ITEM, null);
   List<String> sr =
       s.searchSimpleForQuery(
           SPARQLQueries.selectContainerItemByFilename(
               collection.getId(), FilenameUtils.getBaseName(filename)),
           null);
   if (sr.size() == 0)
     throw new RuntimeException(
         "No item found with the filename " + FilenameUtils.getBaseName(filename));
   if (sr.size() > 1)
     throw new RuntimeException(
         "Filename "
             + FilenameUtils.getBaseName(filename)
             + " not unique ("
             + sr.size()
             + " found).");
   return ObjectLoader.loadItem(URI.create(sr.get(0)), user);
 }