001package org.apache.archiva.redback.rest.api.model.v2; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 021import io.swagger.v3.oas.annotations.media.Schema; 022 023import javax.xml.bind.annotation.XmlRootElement; 024import java.time.Instant; 025import java.time.OffsetDateTime; 026import java.time.ZoneId; 027 028/** 029 * Returns a status of availability (does exist, or does not exist) of a given object. 030 * If the object exists, the creation date of the object may be returned. 031 * 032 * @author Martin Stockhammer <martin_s@apache.org> 033 */ 034@XmlRootElement(name="availabilityStatus") 035@Schema(name="AvailabilityStatus", description = "Status of availability of a requested resource") 036public class AvailabilityStatus 037{ 038 boolean exists = false; 039 OffsetDateTime since; 040 041 public AvailabilityStatus(boolean exists, OffsetDateTime since) { 042 this.exists = exists; 043 this.since = since; 044 } 045 046 public AvailabilityStatus(boolean exists, Instant since) { 047 this.exists = exists; 048 setSinceByInstant( since ); 049 } 050 051 public AvailabilityStatus(boolean exists) { 052 this.exists = exists; 053 this.since = OffsetDateTime.ofInstant( Instant.EPOCH, ZoneId.systemDefault() ); 054 } 055 056 @Schema(description = "Returns true, if the resource exists") 057 public boolean isExists( ) 058 { 059 return exists; 060 } 061 062 public void setExists( boolean exists ) 063 { 064 this.exists = exists; 065 } 066 067 @Schema(description = "Returns the last date since the resource was updated") 068 public OffsetDateTime getSince( ) 069 { 070 return since; 071 } 072 073 public void setSince( OffsetDateTime since ) 074 { 075 this.since = since; 076 } 077 078 public void setSinceByInstant( Instant since ) { 079 this.since = OffsetDateTime.ofInstant( since, ZoneId.systemDefault( ) ); 080 } 081}