BagitProfile.java

  1. /*
  2.  * Copyright (C) 2023 DANS - Data Archiving and Networked Services (info@dans.knaw.nl)
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package nl.knaw.dans.bagit.conformance.profile;

  17. import java.util.ArrayList;
  18. import java.util.HashMap;
  19. import java.util.List;
  20. import java.util.Map;
  21. import java.util.Objects;

  22. /**
  23.  * POJO for all the bagit profile fields.
  24.  * A bagit profile is used to ensure the bag metadata contains all required elements and optional elements follow allowed values
  25.  */
  26. public class BagitProfile {
  27.   private String bagitProfileIdentifier = "";
  28.   private String sourceOrganization = "";
  29.   private String externalDescription = "";
  30.   private String contactName = "";
  31.   private String contactEmail = "";
  32.   private String contactPhone = "";
  33.   private String version = "";
  34.  
  35.   private Map<String, BagInfoRequirement> bagInfoRequirements = new HashMap<>();
  36.   private List<String> manifestTypesRequired = new ArrayList<>();
  37.   private boolean fetchFileAllowed; //defaults to false
  38.   private Serialization serialization = Serialization.optional;
  39.   private List<String> acceptableMIMESerializationTypes = new ArrayList<>();
  40.   private List<String> acceptableBagitVersions = new ArrayList<>();
  41.   private List<String> tagManifestTypesRequired = new ArrayList<>();
  42.   private List<String> tagFilesRequired = new ArrayList<>();
  43.  
  44.  
  45.   @Override
  46.   public boolean equals(final Object other) {
  47.     if (!(other instanceof BagitProfile)) {
  48.       return false;
  49.     }
  50.     final BagitProfile castOther = (BagitProfile) other;
  51.     return Objects.equals(bagitProfileIdentifier, castOther.bagitProfileIdentifier)
  52.         && Objects.equals(sourceOrganization, castOther.sourceOrganization)
  53.         && Objects.equals(externalDescription, castOther.externalDescription)
  54.         && Objects.equals(contactName, castOther.contactName) && Objects.equals(contactEmail, castOther.contactEmail)
  55.         && Objects.equals(contactPhone, castOther.contactPhone)
  56.         && Objects.equals(version, castOther.version)
  57.         && Objects.equals(bagInfoRequirements, castOther.bagInfoRequirements)
  58.         && Objects.equals(manifestTypesRequired, castOther.manifestTypesRequired)
  59.         && Objects.equals(fetchFileAllowed, castOther.fetchFileAllowed)
  60.         && Objects.equals(serialization, castOther.serialization)
  61.         && Objects.equals(acceptableMIMESerializationTypes, castOther.acceptableMIMESerializationTypes)
  62.         && Objects.equals(acceptableBagitVersions, castOther.acceptableBagitVersions)
  63.         && Objects.equals(tagManifestTypesRequired, castOther.tagManifestTypesRequired)
  64.         && Objects.equals(tagFilesRequired, castOther.tagFilesRequired);
  65.   }
  66.   @Override
  67.   public int hashCode() {
  68.     return Objects.hash(bagitProfileIdentifier, sourceOrganization, externalDescription, contactName, contactEmail, contactPhone, version, bagInfoRequirements, manifestTypesRequired, fetchFileAllowed, serialization,
  69.         acceptableMIMESerializationTypes, acceptableBagitVersions, tagManifestTypesRequired, tagFilesRequired);
  70.   }
  71.   @Override
  72.   public String toString() {
  73.     return "BagitProfile [bagitProfileIdentifier=" + bagitProfileIdentifier + ", sourceOrganization="
  74.         + sourceOrganization + ", externalDescription=" + externalDescription + ", contactName=" + contactName
  75.         + ", contactEmail=" + contactEmail + ", contactPhone=" + contactPhone + ", version=" + version + ", bagInfoRequirements=" + bagInfoRequirements
  76.         + ", manifestTypesRequired=" + manifestTypesRequired + ", fetchFileAllowed=" + fetchFileAllowed
  77.         + ", serialization=" + serialization + ", acceptableMIMESerializationTypes=" + acceptableMIMESerializationTypes
  78.         + ", acceptableBagitVersions=" + acceptableBagitVersions + ", tagManifestTypesRequired="
  79.         + tagManifestTypesRequired + ", tagFilesRequired=" + tagFilesRequired + "]";
  80.   }
  81.  
  82.   public Map<String,BagInfoRequirement> getBagInfoRequirements() {
  83.     return bagInfoRequirements;
  84.   }
  85.   public void setBagInfoRequirements(final Map<String, BagInfoRequirement> bagInfo) {
  86.     this.bagInfoRequirements = bagInfo;
  87.   }
  88.   public List<String> getManifestTypesRequired() {
  89.     return manifestTypesRequired;
  90.   }
  91.   public void setManifestTypesRequired(final List<String> manifestsRequired) {
  92.     this.manifestTypesRequired = manifestsRequired;
  93.   }
  94.   public boolean isFetchFileAllowed() {
  95.     return fetchFileAllowed;
  96.   }
  97.   public void setFetchFileAllowed(final boolean allowFetchFile) {
  98.     this.fetchFileAllowed = allowFetchFile;
  99.   }
  100.   public Serialization getSerialization() {
  101.     return serialization;
  102.   }
  103.   public void setSerialization(final Serialization serialization) {
  104.     this.serialization = serialization;
  105.   }
  106.   public List<String> getAcceptableMIMESerializationTypes() {
  107.     return acceptableMIMESerializationTypes;
  108.   }
  109.   public void setAcceptableMIMESerializationTypes(final List<String> acceptSerialization) {
  110.     this.acceptableMIMESerializationTypes = acceptSerialization;
  111.   }
  112.   public List<String> getAcceptableBagitVersions() {
  113.     return acceptableBagitVersions;
  114.   }
  115.   public void setAcceptableBagitVersions(final List<String> acceptBagitVersion) {
  116.     this.acceptableBagitVersions = acceptBagitVersion;
  117.   }
  118.   public List<String> getTagManifestTypesRequired() {
  119.     return tagManifestTypesRequired;
  120.   }
  121.   public void setTagManifestTypesRequired(final List<String> tagManifestsRequired) {
  122.     this.tagManifestTypesRequired = tagManifestsRequired;
  123.   }
  124.   public List<String> getTagFilesRequired() {
  125.     return tagFilesRequired;
  126.   }
  127.   public void setTagFilesRequired(final List<String> tagFilesRequired) {
  128.     this.tagFilesRequired = tagFilesRequired;
  129.   }
  130.   public String getBagitProfileIdentifier() {
  131.     return bagitProfileIdentifier;
  132.   }
  133.   public void setBagitProfileIdentifier(final String bagitProfileIdentifier) {
  134.     this.bagitProfileIdentifier = bagitProfileIdentifier;
  135.   }
  136.   public String getSourceOrganization() {
  137.     return sourceOrganization;
  138.   }
  139.   public void setSourceOrganization(final String sourceOrganization) {
  140.     this.sourceOrganization = sourceOrganization;
  141.   }
  142.   public String getExternalDescription() {
  143.     return externalDescription;
  144.   }
  145.   public void setExternalDescription(final String externalDescription) {
  146.     this.externalDescription = externalDescription;
  147.   }
  148.   public String getContactName() {
  149.     return contactName;
  150.   }
  151.   public void setContactName(final String contactName) {
  152.     this.contactName = contactName;
  153.   }
  154.   public String getContactEmail() {
  155.     return contactEmail;
  156.   }
  157.   public void setContactEmail(final String contactEmail) {
  158.     this.contactEmail = contactEmail;
  159.   }
  160.   public String getContactPhone() {
  161.     return contactPhone;
  162.   }
  163.   public void setContactPhone(final String contactPhone) {
  164.     this.contactPhone = contactPhone;
  165.   }
  166.   public String getVersion() {
  167.     return version;
  168.   }
  169.   public void setVersion(final String version) {
  170.     this.version = version;
  171.   }
  172. }