public Context withSet(Set set) { if (!set.hasCondition()) throw new InternalOAIException("Context sets must have a condition"); this.sets.add(set); return this; }
public IdentifyHandler(Context context, Repository repository) { super(context, repository); // Static validation RepositoryConfiguration configuration = getRepository().getConfiguration(); if (configuration == null) throw new InternalOAIException("No repository configuration provided"); if (configuration.getMaxListSets() <= 0) throw new InternalOAIException("The repository configuration must return maxListSets greater then 0"); if (configuration.getMaxListIdentifiers() <= 0) throw new InternalOAIException("The repository configuration must return maxListIdentifiers greater then 0"); if (configuration.getMaxListRecords() <= 0) throw new InternalOAIException("The repository configuration must return maxListRecords greater then 0"); if (configuration.getAdminEmails() == null || configuration.getAdminEmails().isEmpty()) throw new InternalOAIException("The repository configuration must return at least one admin email"); try { if (configuration.getBaseUrl() == null) throw new InternalOAIException("The repository configuration must return a valid base url (absolute)"); new URL(configuration.getBaseUrl()); } catch (MalformedURLException e) { throw new InternalOAIException("The repository configuration must return a valid base url (absolute)", e); } if (configuration.getDeleteMethod() == null) throw new InternalOAIException("The repository configuration must return a valid delete method"); if (configuration.getEarliestDate() == null) throw new InternalOAIException("The repository configuration must return a valid earliest date. That's the date of the first inserted item"); if (configuration.getRepositoryName() == null) throw new InternalOAIException("The repository configuration must return a valid repository name"); }
public ListMetadataFormatsHandler(Context context, Repository repository) { super(context, repository); itemRepositoryHelper = new ItemRepositoryHelper(repository.getItemRepository()); // Static validation if (getContext().getMetadataFormats() == null || getContext().getMetadataFormats().isEmpty()) throw new InternalOAIException("The context must expose at least one metadata format"); }
private Header createHeader(OAICompiledRequest parameters, ItemIdentifier itemIdentifier) throws BadArgumentException, OAIException, NoMetadataFormatsException { MetadataFormat format = getContext().formatForPrefix(parameters .getMetadataPrefix()); if (!itemIdentifier.isDeleted() && !canDisseminate(itemIdentifier, format)) throw new InternalOAIException("The item repository is currently providing items which cannot be disseminated with format "+format.getPrefix()); Header header = new Header(); header.withDatestamp(itemIdentifier.getDatestamp()); header.withIdentifier(itemIdentifier.getIdentifier()); if (itemIdentifier.isDeleted()) header.withStatus(Header.Status.DELETED); for (Set set : getContext().getSets()) if (set.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(itemIdentifier)) header.withSetSpec(set.getSpec()); for (Set set : itemIdentifier.getSets()) header.withSetSpec(set.getSpec()); return header; }