Beispiel #1
0
  public List<TransferredResource> createCorpora()
      throws InterruptedException, IOException, FileAlreadyExistsException, NotFoundException,
          GenericException, AlreadyExistsException, SolrServerException, IsStillUpdatingException {
    TransferredResourcesScanner f = RodaCoreFactory.getTransferredResourcesScanner();

    List<TransferredResource> resources = new ArrayList<TransferredResource>();

    Path corpora =
        corporaPath
            .resolve(RodaConstants.STORAGE_CONTAINER_AIP)
            .resolve(CorporaConstants.SOURCE_AIP_CONVERTER_3)
            .resolve(RodaConstants.STORAGE_DIRECTORY_REPRESENTATIONS)
            .resolve(CorporaConstants.REPRESENTATION_CONVERTER_ID_3)
            .resolve(RodaConstants.STORAGE_DIRECTORY_DATA);

    String transferredResourceId = "testt";
    FSUtils.copy(corpora, f.getBasePath().resolve(transferredResourceId), true);

    f.updateTransferredResources(Optional.empty(), true);
    index.commit(TransferredResource.class);

    resources.add(
        index.retrieve(
            TransferredResource.class,
            UUID.nameUUIDFromBytes(transferredResourceId.getBytes()).toString()));
    return resources;
  }
Beispiel #2
0
  public AIP ingestCorpora()
      throws RequestNotValidException, NotFoundException, GenericException, AlreadyExistsException,
          AuthorizationDeniedException, InvalidParameterException, InterruptedException,
          IOException, FileAlreadyExistsException, SolrServerException, IsStillUpdatingException {
    String parentId = null;
    String aipType = RodaConstants.AIP_TYPE_MIXED;
    AIP root = model.createAIP(parentId, aipType, new Permissions(), aipCreator);

    Map<String, String> parameters = new HashMap<>();
    parameters.put(RodaConstants.PLUGIN_PARAMS_PARENT_ID, root.getId());

    List<TransferredResource> transferredResources = new ArrayList<TransferredResource>();
    transferredResources = createCorpora();

    AssertJUnit.assertEquals(1, transferredResources.size());

    Job job =
        TestsHelper.executeJob(
            TransferredResourceToAIPPlugin.class,
            parameters,
            PluginType.SIP_TO_AIP,
            SelectedItemsList.create(
                TransferredResource.class,
                transferredResources
                    .stream()
                    .map(tr -> tr.getUUID())
                    .collect(Collectors.toList())));

    TestsHelper.getJobReports(index, job, true);

    index.commitAIPs();

    IndexResult<IndexedAIP> find =
        index.find(
            IndexedAIP.class,
            new Filter(new SimpleFilterParameter(RodaConstants.AIP_PARENT_ID, root.getId())),
            null,
            new Sublist(0, 10));

    AssertJUnit.assertEquals(1L, find.getTotalCount());
    IndexedAIP indexedAIP = find.getResults().get(0);

    return model.retrieveAIP(indexedAIP.getId());
  }
Beispiel #3
0
  @Override
  public Report execute(
      IndexService index, ModelService model, StorageService storage, List<Void> list)
      throws PluginException {
    try {
      int counter =
          index
              .count(
                  IndexedAIP.class,
                  new Filter(
                      new SimpleFilterParameter(RodaConstants.AIP_GHOST, Boolean.TRUE.toString())))
              .intValue();

      // XXX 20160929 Is it really needed? (it is there to be possible to get
      // 100% done reports)
      if (counter == 0) {
        counter = index.count(IndexedAIP.class, Filter.ALL).intValue();
      }

      SimpleJobPluginInfo jobPluginInfo = PluginHelper.getInitialJobInformation(this, counter);
      jobPluginInfo.setSourceObjectsCount(counter);
      PluginHelper.updateJobInformation(this, jobPluginInfo);

      Optional<String> computedSearchScope = PluginHelper.getSearchScopeFromParameters(this, model);
      Job originalJob = PluginHelper.getJob(originalJobId, model);
      PluginHelper.fixParents(
          index, model, Optional.ofNullable(originalJob.getId()), computedSearchScope);

      jobPluginInfo.incrementObjectsProcessedWithSuccess(counter);
      jobPluginInfo.finalizeInfo();
      PluginHelper.updateJobInformation(this, jobPluginInfo);
    } catch (GenericException
        | RequestNotValidException
        | AuthorizationDeniedException
        | JobException
        | NotFoundException e) {
      LOGGER.error("Error while fixing the ancestors.", e);
    }

    return PluginHelper.initPluginReport(this);
  }