001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.repository.activities; 017 018import java.time.ZonedDateTime; 019import java.time.format.DateTimeFormatter; 020import java.util.Map; 021 022import javax.jcr.RepositoryException; 023 024import org.ametys.core.user.UserIdentity; 025import org.ametys.plugins.repository.AmetysObjectIterable; 026import org.ametys.plugins.repository.RepositoryConstants; 027 028/** 029 * Interface for activity holder 030 */ 031public interface ActivityHolder 032{ 033 /** the activity root node name */ 034 public static final String ACTIVITIES_ROOT_NODE_NAME = RepositoryConstants.NAMESPACE_PREFIX_INTERNAL + ":activities"; 035 /** Prefix used for naming the activity node */ 036 public static final String ACTIVITY_NAME_PREFIX = "ametys-activity_"; 037 /** formatter to store date time in jcr node name */ 038 public static final DateTimeFormatter JCR_UTC_FORMAT = DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss_SSS"); 039 040 /** 041 * Returns the activities stored by this activity holder 042 * @return The activities 043 * @throws RepositoryException if failed to get activity nodes 044 */ 045 public AmetysObjectIterable<Activity> getActivities() throws RepositoryException; 046 047 /** 048 * Add an activity to the activity holder 049 * @param type the type 050 * @param parameters the parameters 051 * @param eventId the id of the event 052 * @return the activity 053 * @throws RepositoryException when an error occurred 054 */ 055 public Activity addActivity(ActivityType type, Map<String, Object> parameters, String eventId) throws RepositoryException; 056 057 /** 058 * Add an activity to the activity holder 059 * @param date the date 060 * @param type the type 061 * @param parameters the parameters 062 * @param author the author 063 * @param eventId the id of the event 064 * @return the activity 065 * @throws RepositoryException when an error occurred 066 */ 067 public Activity addActivity(ZonedDateTime date, ActivityType type, Map<String, Object> parameters, UserIdentity author, String eventId) throws RepositoryException; 068}