001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.persistence.common; 019 020import java.net.URI; 021import java.time.Instant; 022import java.util.Collection; 023 024import org.fcrepo.kernel.api.identifiers.FedoraId; 025import org.fcrepo.kernel.api.models.ResourceHeaders; 026 027/** 028 * Common implementation of resource headers 029 * 030 * @author bbpennel 031 */ 032public class ResourceHeadersImpl implements ResourceHeaders { 033 034 private FedoraId id; 035 036 private FedoraId parent; 037 038 private FedoraId archivalGroupId; 039 040 private String stateToken; 041 042 private String interactionModel; 043 044 private String mimeType; 045 046 private String filename; 047 048 private long contentSize; 049 050 private Collection<URI> digests; 051 052 private String externalUrl; 053 054 private String externalHandling; 055 056 private Instant createdDate; 057 058 private String createdBy; 059 060 private Instant lastModifiedDate; 061 062 private String lastModifiedBy; 063 064 private Instant mementoCreatedDate; 065 066 private boolean archivalGroup; 067 068 private boolean objectRoot; 069 070 private boolean deleted; 071 072 private String contentPath; 073 074 private String headersVersion; 075 076 @Override 077 public FedoraId getId() { 078 return id; 079 } 080 081 /** 082 * @param id the fedora id to set 083 */ 084 public void setId(final FedoraId id) { 085 this.id = id; 086 } 087 088 @Override 089 public FedoraId getParent() { 090 return parent; 091 } 092 093 /** 094 * @param parent the parent to set 095 */ 096 public void setParent(final FedoraId parent) { 097 this.parent = parent; 098 } 099 100 @Override 101 public FedoraId getArchivalGroupId() { 102 return archivalGroupId; 103 } 104 105 /** 106 * @param archivalGroupId the archivalGroupId to set 107 */ 108 public void setArchivalGroupId(final FedoraId archivalGroupId) { 109 this.archivalGroupId = archivalGroupId; 110 } 111 112 @Override 113 public String getStateToken() { 114 return stateToken; 115 } 116 117 /** 118 * @param stateToken the stateToken to set 119 */ 120 public void setStateToken(final String stateToken) { 121 this.stateToken = stateToken; 122 } 123 124 @Override 125 public String getInteractionModel() { 126 return interactionModel; 127 } 128 129 /** 130 * @param interactionModel the interactionModel to set 131 */ 132 public void setInteractionModel(final String interactionModel) { 133 this.interactionModel = interactionModel; 134 } 135 136 @Override 137 public String getMimeType() { 138 return mimeType; 139 } 140 141 /** 142 * @param mimeType the mimeType to set 143 */ 144 public void setMimeType(final String mimeType) { 145 this.mimeType = mimeType; 146 } 147 148 @Override 149 public String getFilename() { 150 return filename; 151 } 152 153 /** 154 * @param filename the filename to set 155 */ 156 public void setFilename(final String filename) { 157 this.filename = filename; 158 } 159 160 @Override 161 public long getContentSize() { 162 return contentSize; 163 } 164 165 /** 166 * @param contentSize the contentSize to set 167 */ 168 public void setContentSize(final long contentSize) { 169 this.contentSize = contentSize; 170 } 171 172 @Override 173 public Collection<URI> getDigests() { 174 return digests; 175 } 176 177 /** 178 * @param digests the digests to set 179 */ 180 public void setDigests(final Collection<URI> digests) { 181 this.digests = digests; 182 } 183 184 @Override 185 public String getExternalHandling() { 186 return externalHandling; 187 } 188 189 /** 190 * @param externalHandling the externalHandling to set 191 */ 192 public void setExternalHandling(final String externalHandling) { 193 this.externalHandling = externalHandling; 194 } 195 196 @Override 197 public Instant getCreatedDate() { 198 return createdDate; 199 } 200 201 /** 202 * @param createdDate the createdDate to set 203 */ 204 public void setCreatedDate(final Instant createdDate) { 205 this.createdDate = createdDate; 206 } 207 208 @Override 209 public String getCreatedBy() { 210 return createdBy; 211 } 212 213 /** 214 * @param createdBy the createdBy to set 215 */ 216 public void setCreatedBy(final String createdBy) { 217 this.createdBy = createdBy; 218 } 219 220 @Override 221 public Instant getLastModifiedDate() { 222 return lastModifiedDate; 223 } 224 225 /** 226 * @param lastModifiedDate the lastModifiedDate to set 227 */ 228 public void setLastModifiedDate(final Instant lastModifiedDate) { 229 this.lastModifiedDate = lastModifiedDate; 230 } 231 232 @Override 233 public String getLastModifiedBy() { 234 return lastModifiedBy; 235 } 236 237 /** 238 * @param lastModifiedby the lastModifiedby to set 239 */ 240 public void setLastModifiedBy(final String lastModifiedby) { 241 this.lastModifiedBy = lastModifiedby; 242 } 243 244 @Override 245 public Instant getMementoCreatedDate() { 246 return mementoCreatedDate; 247 } 248 249 /** 250 * @param mementoCreatedDate the mementoCreateDate to set 251 */ 252 public void setMementoCreatedDate(final Instant mementoCreatedDate) { 253 this.mementoCreatedDate = mementoCreatedDate; 254 } 255 256 /** 257 * @param externalUrl the externalUrl to set 258 */ 259 public void setExternalUrl(final String externalUrl) { 260 this.externalUrl = externalUrl; 261 } 262 263 @Override 264 public String getExternalUrl() { 265 return externalUrl; 266 } 267 268 /** 269 * 270 * @param flag boolean flag 271 */ 272 public void setArchivalGroup(final boolean flag) { 273 this.archivalGroup = flag; 274 } 275 276 @Override 277 public boolean isArchivalGroup() { 278 return archivalGroup; 279 } 280 281 /** 282 * @param flag boolean flag 283 */ 284 public void setObjectRoot(final boolean flag) { 285 this.objectRoot = flag; 286 } 287 288 @Override 289 public boolean isObjectRoot() { 290 if (isArchivalGroup()) { 291 return true; 292 } else { 293 return objectRoot; 294 } 295 } 296 297 /** 298 * Set deleted status flag. 299 * @param deleted true if deleted (a tombstone). 300 */ 301 public void setDeleted(final boolean deleted) { 302 this.deleted = deleted; 303 } 304 305 /** 306 * {@inheritDoc} 307 */ 308 @Override 309 public boolean isDeleted() { 310 return deleted; 311 } 312 313 /** 314 * {@inheritDoc} 315 */ 316 @Override 317 public String getContentPath() { 318 return contentPath; 319 } 320 321 /** 322 * Sets the path to the content file associated with the header file 323 * 324 * @param contentPath path to content file 325 */ 326 public void setContentPath(final String contentPath) { 327 this.contentPath = contentPath; 328 } 329 330 @Override 331 public String getHeadersVersion() { 332 return headersVersion; 333 } 334 335 /** 336 * @param headersVersion the headers version 337 */ 338 public void setHeadersVersion(final String headersVersion) { 339 this.headersVersion = headersVersion; 340 } 341 342 @Override 343 public String toString() { 344 return "ResourceHeadersImpl{" + 345 "id=" + id + 346 ", parent=" + parent + 347 ", archivalGroupId=" + archivalGroupId + 348 ", stateToken='" + stateToken + '\'' + 349 ", interactionModel='" + interactionModel + '\'' + 350 ", mimeType='" + mimeType + '\'' + 351 ", filename='" + filename + '\'' + 352 ", contentSize=" + contentSize + 353 ", digests=" + digests + 354 ", externalUrl='" + externalUrl + '\'' + 355 ", externalHandling='" + externalHandling + '\'' + 356 ", createdDate=" + createdDate + 357 ", createdBy='" + createdBy + '\'' + 358 ", lastModifiedDate=" + lastModifiedDate + 359 ", lastModifiedBy='" + lastModifiedBy + '\'' + 360 ", mementoCreatedDate=" + mementoCreatedDate + 361 ", archivalGroup=" + archivalGroup + 362 ", objectRoot=" + objectRoot + 363 ", deleted=" + deleted + 364 ", contentPath='" + contentPath + '\'' + 365 ", headersVersion='" + headersVersion + '\'' + 366 '}'; 367 } 368 369}