Skip to content

Commit

Permalink
added possible states when getting AIPs from ingest sip ids on ingest #…
Browse files Browse the repository at this point in the history
…1034; solved report id issue when moving transferred resources #1035
  • Loading branch information
nunovieira220 committed Jul 21, 2017
1 parent 1574dd3 commit f13ff87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
Expand All @@ -28,10 +29,13 @@
import org.roda.core.data.v2.LiteOptionalWithCause;
import org.roda.core.data.v2.index.IndexResult;
import org.roda.core.data.v2.index.filter.Filter;
import org.roda.core.data.v2.index.filter.FilterParameter;
import org.roda.core.data.v2.index.filter.OrFiltersParameters;
import org.roda.core.data.v2.index.filter.SimpleFilterParameter;
import org.roda.core.data.v2.index.sort.Sorter;
import org.roda.core.data.v2.index.sublist.Sublist;
import org.roda.core.data.v2.ip.AIP;
import org.roda.core.data.v2.ip.AIPState;
import org.roda.core.data.v2.ip.IndexedAIP;
import org.roda.core.data.v2.ip.Permissions;
import org.roda.core.data.v2.ip.TransferredResource;
Expand Down Expand Up @@ -209,7 +213,13 @@ private AIP processUpdateSIP(IndexService index, ModelService model, StorageServ
Optional<String> searchScope, boolean forceSearchScope) throws GenericException, RequestNotValidException,
NotFoundException, AuthorizationDeniedException, AlreadyExistsException, ValidationException {
String searchScopeString = searchScope.orElse(null);
Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.INGEST_SIP_IDS, sip.getId()));

List<FilterParameter> possibleStates = new ArrayList<>();
possibleStates.add(new SimpleFilterParameter(RodaConstants.AIP_STATE, AIPState.ACTIVE.toString()));
possibleStates.add(new SimpleFilterParameter(RodaConstants.AIP_STATE, AIPState.UNDER_APPRAISAL.toString()));

Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.INGEST_SIP_IDS, sip.getId()),
new OrFiltersParameters(possibleStates));
if (searchScopeString != null && !forceSearchScope) {
filter.add(new SimpleFilterParameter(RodaConstants.AIP_ANCESTORS, searchScopeString));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ private void processFile(IndexService index, ModelService model, Report report,
EVENT_DESCRIPTION, state, outcomeText.toString(), details, job.getUsername(), true);
}

@SuppressWarnings("unchecked")
private void processTransferredResource(ModelService model, Report report, SimpleJobPluginInfo jobPluginInfo, Job job,
List<TransferredResource> resources) {
if (destinationId == null) {
Expand All @@ -267,7 +268,7 @@ private void processTransferredResource(ModelService model, Report report, Simpl

for (TransferredResource resource : resources) {
if (!moveResult.containsKey(resource.getUUID())) {
addFailedReport(model, report, jobPluginInfo, job, resource.getId());
addFailedReport(model, report, jobPluginInfo, job, resource.getUUID(), (Class<T>) TransferredResource.class);
} else {
jobPluginInfo.incrementObjectsProcessedWithSuccess();
}
Expand All @@ -277,15 +278,15 @@ private void processTransferredResource(ModelService model, Report report, Simpl
LOGGER.error("Could not move transferred resource list", e);

for (TransferredResource resource : resources) {
addFailedReport(model, report, jobPluginInfo, job, resource.getId());
addFailedReport(model, report, jobPluginInfo, job, resource.getId(), (Class<T>) TransferredResource.class);
}
}
}

private void addFailedReport(ModelService model, Report report, SimpleJobPluginInfo jobPluginInfo, Job job,
String resourceId) {
String resourceId, Class<T> objectClass) {
jobPluginInfo.incrementObjectsProcessedWithFailure();
Report reportItem = PluginHelper.initPluginReportItem(this, resourceId, File.class);
Report reportItem = PluginHelper.initPluginReportItem(this, resourceId, objectClass);
reportItem
.addPluginDetails("Could not move transferred resource " + resourceId
+ " due to inapropriate move operation. A likely scenario is a move operation of a parent to a child.")
Expand Down

0 comments on commit f13ff87

Please sign in to comment.