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.kernel.api;
019
020import java.net.URI;
021import java.time.Duration;
022import java.time.Instant;
023import java.util.Optional;
024
025/**
026 * The Fedora Session abstraction
027 *
028 * @author acoburn
029 */
030public interface FedoraSession {
031
032    /**
033     * Expire the session
034     */
035    void expire();
036
037    /**
038     * Commit any batch operations
039     */
040    void commit();
041
042    /**
043     * Update the expiry by the provided amount
044     * @param amountToAdd the amount of time to add
045     * @return the new expiration date
046     */
047    Instant updateExpiry(Duration amountToAdd);
048
049    /**
050     * Get the date this session expires
051     * @return expiration date, if one exists
052     */
053    Optional<Instant> getExpires();
054
055    /**
056     * Get the session identifier
057     * @return the session id
058     */
059    String getId();
060
061    /**
062     * Get the user URI
063     * @return URI
064     */
065    URI getUserURI();
066
067    /**
068     * Add session-specific data
069     * @param key the key
070     * @param value the value
071     *
072     * Note: it is up to the particular implementation as to whether multi-valued session data
073     * is allowed.
074     */
075    void addSessionData(String key, String value);
076
077}