--- /dev/null
+Apache Archiva
+Copyright 2006-2019 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.time.LocalDateTime;
+import java.util.EventObject;
+
+/**
+ * Base class for events. Events have a type and a source.
+ * The source is the instance that raised the event.
+ *
+ * There are different event types for a given event. The types are represented in a hierarchical structure.
+ *
+ * Events can be chained, which means a event listener can catch events and rethrow them as its own event.
+ *
+ */
+public class Event extends EventObject implements Cloneable {
+
+ private static final long serialVersionUID = -7171846575892044990L;
+
+ public static final EventType<Event> ANY = EventType.ROOT;
+
+ private Event previous;
+ private final EventType<? extends Event> type;
+ private final LocalDateTime createTime;
+
+ public Event(EventType<? extends Event> type, Object originator) {
+ super(originator);
+ this.type = type;
+ this.createTime = LocalDateTime.now();
+ }
+
+ private Event(Event previous, Object originator) {
+ super(originator);
+ this.previous = previous;
+ this.type = previous.getType();
+ this.createTime = previous.getCreateTime();
+ }
+
+ /**
+ * Returns the event type that is associated with this event instance.
+ * @return the event type
+ */
+ public EventType<? extends Event> getType() {
+ return type;
+ };
+
+ /**
+ * Returns the time, when the event was created.
+ * @return
+ */
+ public LocalDateTime getCreateTime() {
+ return createTime;
+ }
+
+
+ /**
+ * Recreates the event with the given instance as the new source. The
+ * current source is stored in the previous event.
+ * @param newSource The new source
+ * @return a new event instance, where <code>this</code> is stored as previous event
+ */
+ public Event copyFor(Object newSource) {
+ Event newEvent = (Event) this.clone();
+ newEvent.previous = this;
+ newEvent.source = newSource;
+ return newEvent;
+ }
+
+ /**
+ * Returns the previous event or <code>null</code>, if this is a root event.
+ * @return the previous event or <code>null</code>, if it does not exist
+ */
+ public Event getPreviousEvent() {
+ return previous;
+ }
+
+ /**
+ * Returns <code>true</code>, if the event has a previous event.
+ * @return <code>true</code>, if this has a previous event, otherwise <code>false</code>
+ */
+ public boolean hasPreviousEvent() {
+ return previous!=null;
+ }
+
+ @Override
+ protected Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // this should not happen
+ throw new RuntimeException("Event is not clonable");
+ }
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.EventListener;
+
+/**
+ * A listener that accepts events.
+ */
+public interface EventHandler<T extends Event> extends EventListener {
+
+ void handle(T event);
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class EventManager implements EventSource {
+
+ private static final Logger log = LoggerFactory.getLogger(EventManager.class);
+
+ private final ConcurrentHashMap<EventType<? extends Event>, Set<EventHandler>> handlerMap = new ConcurrentHashMap<>();
+
+ private final Object source;
+
+ public EventManager(Object source) {
+ if (source==null) {
+ throw new IllegalArgumentException("The source may not be null");
+ }
+ this.source = source;
+ }
+
+ @Override
+ public <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) {
+ Set<EventHandler> handlers = handlerMap.computeIfAbsent(type, t -> new LinkedHashSet<>());
+ if (!handlers.contains(eventHandler)) {
+ handlers.add(eventHandler);
+ }
+ }
+
+ @Override
+ public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) {
+ if (handlerMap.containsKey(type)) {
+ handlerMap.get(type).remove(eventHandler);
+ }
+ }
+
+ public void fireEvent(Event fireEvent) {
+ final EventType<? extends Event> type = fireEvent.getType();
+ Event event;
+ if (fireEvent.getSource()!=source) {
+ event = fireEvent.copyFor(source);
+ } else {
+ event = fireEvent;
+ }
+ for (EventType<? extends Event> handlerType : handlerMap.keySet()) {
+ if (EventType.isInstanceOf(type, handlerType)) {
+ for (EventHandler handler : handlerMap.get(handlerType)) {
+ try {
+ handler.handle(event);
+ } catch (Exception e) {
+ // We catch all errors from handlers
+ log.error("An error occured during event handling: {}", e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A repository event source raises events to its registered listeners.
+ * Listeners register to event types that are structured hierarchical.
+ *
+ */
+public interface EventSource {
+
+ <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);
+
+ <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);
+
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Event types define a hierarchical structure of events. Each event is bound to a certain event type.
+ * All event types have a super type, only the root event type {@link EventType#ROOT} has no super type.
+ *
+ * Event types should be stored as static fields on the events itself.
+ *
+ * @param <T> The type class parameter allows to define the types in a type safe way and represents a event class,
+ * where the type is associated to.
+ */
+public class EventType<T extends Event> implements Serializable {
+
+
+ public static final EventType<Event> ROOT = new EventType<>();
+
+ private final String name;
+ private final EventType<? super T> superType;
+ private WeakHashMap<EventType<? extends T>, Void> subTypes;
+
+ /**
+ * Creates a type with the given name and the root type as parent.
+ * @param name the name of the new type
+ */
+ public EventType(String name) {
+ this.superType = ROOT;
+ this.name = name;
+ }
+
+ /**
+ * Creates a event type instance with the given super type and name.
+ *
+ * @param superType The super type or <code>null</code>, if this is the root type.
+ * @param name
+ */
+ public EventType(EventType<? super T> superType, String name) {
+ if (superType==null) {
+ throw new NullPointerException("Super Type may not be null");
+ }
+ this.name = name;
+ this.superType = superType;
+ superType.register(this);
+ }
+
+ /**
+ * Creates the root type
+ */
+ private EventType() {
+ this.name="ROOT";
+ this.superType=null;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public EventType<? super T> getSuperType() {
+ return superType;
+ }
+
+ private void register(EventType<? extends T> subType) {
+ if (subTypes == null) {
+ subTypes = new WeakHashMap<>();
+ }
+ for (EventType<? extends T> t : subTypes.keySet()) {
+ if (((t.name == null && subType.name == null) || (t.name != null && t.name.equals(subType.name)))) {
+ throw new IllegalArgumentException("EventType \"" + subType + "\""
+ + "with parent \"" + subType.getSuperType()+"\" already exists");
+ }
+ }
+ subTypes.put(subType, null);
+ }
+
+
+ public static List<EventType<?>> fetchSuperTypes(EventType<?> type) {
+ List<EventType<?>> typeList = new ArrayList<>();
+ EventType<?> cType = type;
+ while (cType!=null) {
+ typeList.add(cType);
+ cType = cType.getSuperType();
+ }
+ return typeList;
+ }
+
+ public static boolean isInstanceOf(EventType<?> type, EventType<?> baseType) {
+ EventType<?> cType = type;
+ while(cType!=null) {
+ if (cType == baseType) {
+ return true;
+ }
+ cType = cType.getSuperType();
+ }
+ return false;
+ }
+
+
+ private Object writeReplace() throws ObjectStreamException {
+ Deque<String> path = new LinkedList<String>();
+ EventType<?> t = this;
+ while (t != ROOT) {
+ path.addFirst(t.name);
+ t = t.superType;
+ }
+ return new EventTypeSerialization(new ArrayList<>(path));
+ }
+
+ static class EventTypeSerialization implements Serializable {
+ private static final long serialVersionUID = 1841649460281865547L;
+ private List<String> path;
+
+ public EventTypeSerialization(List<String> path) {
+ this.path = path;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ EventType t = ROOT;
+ for (int i = 0; i < path.size(); ++i) {
+ String p = path.get(i);
+ if (t.subTypes != null) {
+ EventType<?> s = findSubType(t.subTypes.keySet(), p);
+ if (s == null) {
+ throw new InvalidObjectException("Cannot find event type \"" + p + "\" (of " + t + ")");
+ }
+ t = s;
+ } else {
+ throw new InvalidObjectException("Cannot find event type \"" + p + "\" (of " + t + ")");
+ }
+ }
+ return t;
+ }
+
+ private EventType<?> findSubType(Set<EventType> subTypes, String name) {
+ for (EventType t : subTypes) {
+ if (((t.name == null && name == null) || (t.name != null && t.name.equals(name)))) {
+ return t;
+ }
+ }
+ return null;
+ }
+
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.repository.Repository;
+
+/**
+ * Raises events about the repository lifecycle. The following events are raised:
+ * <ul>
+ * <li>REGISTERED: a repository has been registered by the repository registry</li>
+ * <li>UNREGISTERED: a repository has been removed by the repository registry</li>
+ * <li>UPDATED: A repository attribute was updated</li>
+ * </ul>
+ */
+public class LifecycleEvent extends RepositoryEvent {
+
+ private static final long serialVersionUID = -2520982087439428714L;
+ public static EventType<LifecycleEvent> ANY = new EventType<>(RepositoryEvent.ANY, "REPOSITORY.LIFECYCLE");
+ public static EventType<LifecycleEvent> REGISTERED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.REGISTERED");
+ public static EventType<LifecycleEvent> UNREGISTERED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.UNREGISTERED");
+ public static EventType<LifecycleEvent> UPDATED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.UPDATED");
+
+ public LifecycleEvent(EventType<? extends LifecycleEvent> type, Object origin, Repository repository) {
+ super(type, origin, repository);
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.repository.Repository;
+
+/**
+ * A repository event is specific to a repository and holds a reference to the repository that
+ * is related to this event.
+ */
+public class RepositoryEvent extends Event {
+
+ private static final long serialVersionUID = 4676673476606414834L;
+
+ public static final EventType<RepositoryEvent> ANY = new EventType<>(Event.ANY, "REPOSITORY");
+
+ private final Repository repository;
+
+ public RepositoryEvent(EventType<? extends RepositoryEvent> type, Object origin, Repository repository) {
+ super(type, origin);
+ this.repository = repository;
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ @Override
+ public EventType<? extends RepositoryEvent> getType() {
+ return (EventType<? extends RepositoryEvent>) super.getType();
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.archiva.repository.Repository;
+
+import java.net.URI;
+
+/**
+ * These events are thrown, when index information has changed.
+ */
+public class RepositoryIndexEvent extends RepositoryValueEvent<URI> {
+
+ private static final long serialVersionUID = -7801989699524776524L;
+
+ public static EventType<RepositoryIndexEvent> ANY = new EventType<>(RepositoryValueEvent.ANY, "REPOSITORY.VALUE.INDEX");
+ public static EventType<RepositoryIndexEvent> INDEX_URI_CHANGED = new EventType<>(ANY, "REPOSITORY.VALUE.INDEX.URI_CHANGED");
+ public static EventType<RepositoryIndexEvent> PACKED_INDEX_URI_CHANGED = new EventType<>(ANY, "REPOSITORY.VALUE.INDEX.PACKED_URI_CHANGED");
+
+ RepositoryIndexEvent(EventType<? extends RepositoryIndexEvent> type, Object origin, Repository repo, URI oldValue, URI value) {
+ super(type, origin, repo, oldValue, value, "index.uri");
+ }
+
+ public static final <O> RepositoryIndexEvent indexUriChange(O origin, Repository repo, URI oldValue, URI newValue) {
+ return new RepositoryIndexEvent(INDEX_URI_CHANGED, origin, repo, oldValue, newValue);
+ }
+
+ public static final <O> RepositoryIndexEvent packedIndexUriChange(O origin, Repository repo, URI oldValue, URI newValue) {
+ return new RepositoryIndexEvent(PACKED_INDEX_URI_CHANGED, origin, repo, oldValue, newValue);
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Repository registry events are raised by the repository registry itself.
+ */
+public class RepositoryRegistryEvent extends Event {
+
+ private static final long serialVersionUID = -4740127827269612094L;
+
+ /**
+ * All repository registry events
+ */
+ public static EventType<RepositoryRegistryEvent> ANY = new EventType(EventType.ROOT, "REGISTRY");
+ /**
+ * When the registry has reloaded the registry data from the configuration
+ */
+ public static EventType<RepositoryRegistryEvent> RELOADED = new EventType(ANY, "REGISTRY.RELOADED");
+ /**
+ * When the registry was destroyed. Repository instances may still be referenced, but are not updated.
+ */
+ public static EventType<RepositoryRegistryEvent> DESTROYED = new EventType(ANY, "REGISTRY.DESTROYED");
+ /**
+ * When the registry was initialized
+ */
+ public static EventType<RepositoryRegistryEvent> INITIALIZED = new EventType(ANY, "REGISTRY.INITIALIZED");
+
+ public RepositoryRegistryEvent(EventType<? extends RepositoryRegistryEvent> type, Object origin) {
+ super(type, origin);
+ }
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.repository.Repository;
+
+/**
+ * Repository value events are used for providing information about repository attribute changes.
+ * The value event gives information of the attribute value before and after the change.
+ *
+ * @param <V> The type of the changed attribute
+ */
+public class RepositoryValueEvent<V> extends RepositoryEvent {
+
+ private static final long serialVersionUID = 4176597620699304794L;
+
+ public static final EventType<RepositoryValueEvent<?>> ANY = new EventType(RepositoryEvent.ANY, "REPOSITORY.VALUE");
+
+ final V value;
+ final V oldValue;
+ final String attributeName;
+
+ public RepositoryValueEvent(EventType<? extends RepositoryValueEvent<V>> type, Object origin, Repository repo, V oldValue, V value,
+ String attributeName) {
+ super(type, origin, repo);
+ this.value = value;
+ this.oldValue = oldValue;
+ this.attributeName = attributeName;
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public V getOldValue() {
+ return oldValue;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.time.LocalDateTime;
-import java.util.EventObject;
-
-/**
- * Base class for events. Events have a type and a source.
- * The source is the instance that raised the event.
- *
- * There are different event types for a given event. The types are represented in a hierarchical structure.
- *
- * Events can be chained, which means a event listener can catch events and rethrow them as its own event.
- *
- */
-public class Event extends EventObject implements Cloneable {
-
- private static final long serialVersionUID = -7171846575892044990L;
-
- public static final EventType<Event> ANY = EventType.ROOT;
-
- private Event previous;
- private final EventType<? extends Event> type;
- private final LocalDateTime createTime;
-
- public Event(EventType<? extends Event> type, Object originator) {
- super(originator);
- this.type = type;
- this.createTime = LocalDateTime.now();
- }
-
- private Event(Event previous, Object originator) {
- super(originator);
- this.previous = previous;
- this.type = previous.getType();
- this.createTime = previous.getCreateTime();
- }
-
- /**
- * Returns the event type that is associated with this event instance.
- * @return the event type
- */
- public EventType<? extends Event> getType() {
- return type;
- };
-
- /**
- * Returns the time, when the event was created.
- * @return
- */
- public LocalDateTime getCreateTime() {
- return createTime;
- }
-
-
- /**
- * Recreates the event with the given instance as the new source. The
- * current source is stored in the previous event.
- * @param newSource The new source
- * @return a new event instance, where <code>this</code> is stored as previous event
- */
- public Event copyFor(Object newSource) {
- Event newEvent = (Event) this.clone();
- newEvent.previous = this;
- newEvent.source = newSource;
- return newEvent;
- }
-
- /**
- * Returns the previous event or <code>null</code>, if this is a root event.
- * @return the previous event or <code>null</code>, if it does not exist
- */
- public Event getPreviousEvent() {
- return previous;
- }
-
- /**
- * Returns <code>true</code>, if the event has a previous event.
- * @return <code>true</code>, if this has a previous event, otherwise <code>false</code>
- */
- public boolean hasPreviousEvent() {
- return previous!=null;
- }
-
- @Override
- protected Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- // this should not happen
- throw new RuntimeException("Event is not clonable");
- }
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.EventListener;
-
-/**
- * A listener that accepts events.
- */
-public interface EventHandler<T extends Event> extends EventListener {
-
- void handle(T event);
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class EventManager implements EventSource {
-
- private static final Logger log = LoggerFactory.getLogger(EventManager.class);
-
- private final ConcurrentHashMap<EventType<? extends Event>, Set<EventHandler>> handlerMap = new ConcurrentHashMap<>();
-
- private final Object source;
-
- public EventManager(Object source) {
- if (source==null) {
- throw new IllegalArgumentException("The source may not be null");
- }
- this.source = source;
- }
-
- @Override
- public <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) {
- Set<EventHandler> handlers = handlerMap.computeIfAbsent(type, t -> new LinkedHashSet<>());
- if (!handlers.contains(eventHandler)) {
- handlers.add(eventHandler);
- }
- }
-
- @Override
- public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) {
- if (handlerMap.containsKey(type)) {
- handlerMap.get(type).remove(eventHandler);
- }
- }
-
- public void fireEvent(Event fireEvent) {
- final EventType<? extends Event> type = fireEvent.getType();
- Event event;
- if (fireEvent.getSource()!=source) {
- event = fireEvent.copyFor(source);
- } else {
- event = fireEvent;
- }
- for (EventType<? extends Event> handlerType : handlerMap.keySet()) {
- if (EventType.isInstanceOf(type, handlerType)) {
- for (EventHandler handler : handlerMap.get(handlerType)) {
- try {
- handler.handle(event);
- } catch (Exception e) {
- // We catch all errors from handlers
- log.error("An error occured during event handling: {}", e.getMessage(), e);
- }
- }
- }
- }
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A repository event source raises events to its registered listeners.
- * Listeners register to event types that are structured hierarchical.
- *
- */
-public interface EventSource {
-
- <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);
-
- <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler);
-
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.InvalidObjectException;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Event types define a hierarchical structure of events. Each event is bound to a certain event type.
- * All event types have a super type, only the root event type {@link EventType#ROOT} has no super type.
- *
- * Event types should be stored as static fields on the events itself.
- *
- * @param <T> The type class parameter allows to define the types in a type safe way and represents a event class,
- * where the type is associated to.
- */
-public class EventType<T extends Event> implements Serializable {
-
-
- public static final EventType<Event> ROOT = new EventType<>();
-
- private final String name;
- private final EventType<? super T> superType;
- private WeakHashMap<EventType<? extends T>, Void> subTypes;
-
- /**
- * Creates a type with the given name and the root type as parent.
- * @param name the name of the new type
- */
- public EventType(String name) {
- this.superType = ROOT;
- this.name = name;
- }
-
- /**
- * Creates a event type instance with the given super type and name.
- *
- * @param superType The super type or <code>null</code>, if this is the root type.
- * @param name
- */
- public EventType(EventType<? super T> superType, String name) {
- if (superType==null) {
- throw new NullPointerException("Super Type may not be null");
- }
- this.name = name;
- this.superType = superType;
- superType.register(this);
- }
-
- /**
- * Creates the root type
- */
- private EventType() {
- this.name="ROOT";
- this.superType=null;
- }
-
- public String name() {
- return name;
- }
-
- public EventType<? super T> getSuperType() {
- return superType;
- }
-
- private void register(EventType<? extends T> subType) {
- if (subTypes == null) {
- subTypes = new WeakHashMap<>();
- }
- for (EventType<? extends T> t : subTypes.keySet()) {
- if (((t.name == null && subType.name == null) || (t.name != null && t.name.equals(subType.name)))) {
- throw new IllegalArgumentException("EventType \"" + subType + "\""
- + "with parent \"" + subType.getSuperType()+"\" already exists");
- }
- }
- subTypes.put(subType, null);
- }
-
-
- public static List<EventType<?>> fetchSuperTypes(EventType<?> type) {
- List<EventType<?>> typeList = new ArrayList<>();
- EventType<?> cType = type;
- while (cType!=null) {
- typeList.add(cType);
- cType = cType.getSuperType();
- }
- return typeList;
- }
-
- public static boolean isInstanceOf(EventType<?> type, EventType<?> baseType) {
- EventType<?> cType = type;
- while(cType!=null) {
- if (cType == baseType) {
- return true;
- }
- cType = cType.getSuperType();
- }
- return false;
- }
-
-
- private Object writeReplace() throws ObjectStreamException {
- Deque<String> path = new LinkedList<String>();
- EventType<?> t = this;
- while (t != ROOT) {
- path.addFirst(t.name);
- t = t.superType;
- }
- return new EventTypeSerialization(new ArrayList<>(path));
- }
-
- static class EventTypeSerialization implements Serializable {
- private static final long serialVersionUID = 1841649460281865547L;
- private List<String> path;
-
- public EventTypeSerialization(List<String> path) {
- this.path = path;
- }
-
- private Object readResolve() throws ObjectStreamException {
- EventType t = ROOT;
- for (int i = 0; i < path.size(); ++i) {
- String p = path.get(i);
- if (t.subTypes != null) {
- EventType<?> s = findSubType(t.subTypes.keySet(), p);
- if (s == null) {
- throw new InvalidObjectException("Cannot find event type \"" + p + "\" (of " + t + ")");
- }
- t = s;
- } else {
- throw new InvalidObjectException("Cannot find event type \"" + p + "\" (of " + t + ")");
- }
- }
- return t;
- }
-
- private EventType<?> findSubType(Set<EventType> subTypes, String name) {
- for (EventType t : subTypes) {
- if (((t.name == null && name == null) || (t.name != null && t.name.equals(name)))) {
- return t;
- }
- }
- return null;
- }
-
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.Repository;
-
-/**
- * Raises events about the repository lifecycle. The following events are raised:
- * <ul>
- * <li>REGISTERED: a repository has been registered by the repository registry</li>
- * <li>UNREGISTERED: a repository has been removed by the repository registry</li>
- * <li>UPDATED: A repository attribute was updated</li>
- * </ul>
- */
-public class LifecycleEvent extends RepositoryEvent {
-
- private static final long serialVersionUID = -2520982087439428714L;
- public static EventType<LifecycleEvent> ANY = new EventType<>(RepositoryEvent.ANY, "REPOSITORY.LIFECYCLE");
- public static EventType<LifecycleEvent> REGISTERED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.REGISTERED");
- public static EventType<LifecycleEvent> UNREGISTERED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.UNREGISTERED");
- public static EventType<LifecycleEvent> UPDATED = new EventType<>(ANY, "REPOSITORY.LIFECYCLE.UPDATED");
-
- public LifecycleEvent(EventType<? extends LifecycleEvent> type, Object origin, Repository repository) {
- super(type, origin, repository);
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.Repository;
-
-/**
- * A repository event is specific to a repository and holds a reference to the repository that
- * is related to this event.
- */
-public class RepositoryEvent extends Event {
-
- private static final long serialVersionUID = 4676673476606414834L;
-
- public static final EventType<RepositoryEvent> ANY = new EventType<>(Event.ANY, "REPOSITORY");
-
- private final Repository repository;
-
- public RepositoryEvent(EventType<? extends RepositoryEvent> type, Object origin, Repository repository) {
- super(type, origin);
- this.repository = repository;
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- @Override
- public EventType<? extends RepositoryEvent> getType() {
- return (EventType<? extends RepositoryEvent>) super.getType();
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import org.apache.archiva.repository.Repository;
-
-import java.net.URI;
-
-/**
- * These events are thrown, when index information has changed.
- */
-public class RepositoryIndexEvent extends RepositoryValueEvent<URI> {
-
- private static final long serialVersionUID = -7801989699524776524L;
-
- public static EventType<RepositoryIndexEvent> ANY = new EventType<>(RepositoryValueEvent.ANY, "REPOSITORY.VALUE.INDEX");
- public static EventType<RepositoryIndexEvent> INDEX_URI_CHANGED = new EventType<>(ANY, "REPOSITORY.VALUE.INDEX.URI_CHANGED");
- public static EventType<RepositoryIndexEvent> PACKED_INDEX_URI_CHANGED = new EventType<>(ANY, "REPOSITORY.VALUE.INDEX.PACKED_URI_CHANGED");
-
- RepositoryIndexEvent(EventType<? extends RepositoryIndexEvent> type, Object origin, Repository repo, URI oldValue, URI value) {
- super(type, origin, repo, oldValue, value, "index.uri");
- }
-
- public static final <O> RepositoryIndexEvent indexUriChange(O origin, Repository repo, URI oldValue, URI newValue) {
- return new RepositoryIndexEvent(INDEX_URI_CHANGED, origin, repo, oldValue, newValue);
- }
-
- public static final <O> RepositoryIndexEvent packedIndexUriChange(O origin, Repository repo, URI oldValue, URI newValue) {
- return new RepositoryIndexEvent(PACKED_INDEX_URI_CHANGED, origin, repo, oldValue, newValue);
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Repository registry events are raised by the repository registry itself.
- */
-public class RepositoryRegistryEvent extends Event {
-
- private static final long serialVersionUID = -4740127827269612094L;
-
- /**
- * All repository registry events
- */
- public static EventType<RepositoryRegistryEvent> ANY = new EventType(EventType.ROOT, "REGISTRY");
- /**
- * When the registry has reloaded the registry data from the configuration
- */
- public static EventType<RepositoryRegistryEvent> RELOADED = new EventType(ANY, "REGISTRY.RELOADED");
- /**
- * When the registry was destroyed. Repository instances may still be referenced, but are not updated.
- */
- public static EventType<RepositoryRegistryEvent> DESTROYED = new EventType(ANY, "REGISTRY.DESTROYED");
- /**
- * When the registry was initialized
- */
- public static EventType<RepositoryRegistryEvent> INITIALIZED = new EventType(ANY, "REGISTRY.INITIALIZED");
-
- public RepositoryRegistryEvent(EventType<? extends RepositoryRegistryEvent> type, Object origin) {
- super(type, origin);
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.Repository;
-
-/**
- * Repository value events are used for providing information about repository attribute changes.
- * The value event gives information of the attribute value before and after the change.
- *
- * @param <V> The type of the changed attribute
- */
-public class RepositoryValueEvent<V> extends RepositoryEvent {
-
- private static final long serialVersionUID = 4176597620699304794L;
-
- public static final EventType<RepositoryValueEvent<?>> ANY = new EventType(RepositoryEvent.ANY, "REPOSITORY.VALUE");
-
- final V value;
- final V oldValue;
- final String attributeName;
-
- public RepositoryValueEvent(EventType<? extends RepositoryValueEvent<V>> type, Object origin, Repository repo, V oldValue, V value,
- String attributeName) {
- super(type, origin, repo);
- this.value = value;
- this.oldValue = oldValue;
- this.attributeName = attributeName;
- }
-
- public V getValue() {
- return value;
- }
-
- public V getOldValue() {
- return oldValue;
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
-}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.facets.AuditEvent;
+
+/**
+ * AuditListener
+ *
+ *
+ */
+public interface AuditListener
+{
+ /**
+ * Notification that an audit event occured.
+ *
+ * @param event the event details.
+ */
+ void auditEvent( AuditEvent event );
+}
--- /dev/null
+package org.apache.archiva.repository.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataException;
+
+/**
+ * Listen to events on the repository. This class is a stopgap
+ * refactoring measure until an event bus is in place to handle
+ * generic events such as these.
+ * <p>
+ * This assumes that the events occur before the action has completed, though they don't currently offer any mechanism
+ * to prevent an event from occurring or guarantee that it will happen.
+ * <p>
+ * FIXME: this needs to be made more permanent since 3rd party plugins will depend on it heavily
+ */
+public interface RepositoryListener
+{
+ void deleteArtifact( MetadataRepository metadataRepository, String repositoryId, String namespace, String project,
+ String version, String id );
+
+ void addArtifact( RepositorySession session, String repoId, String namespace, String projectId,
+ ProjectVersionMetadata metadata );
+
+ // FIXME: this would be better as a "processException" method, with the event information captured in a single class
+ void addArtifactProblem( RepositorySession session, String repoId, String namespace, String projectId,
+ String projectVersion, RepositoryStorageMetadataException exception );
+}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.metadata.model.facets.AuditEvent;
-
-/**
- * AuditListener
- *
- *
- */
-public interface AuditListener
-{
- /**
- * Notification that an audit event occured.
- *
- * @param event the event details.
- */
- void auditEvent( AuditEvent event );
-}
+++ /dev/null
-package org.apache.archiva.repository.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataException;
-
-/**
- * Listen to events on the repository. This class is a stopgap
- * refactoring measure until an event bus is in place to handle
- * generic events such as these.
- * <p>
- * This assumes that the events occur before the action has completed, though they don't currently offer any mechanism
- * to prevent an event from occurring or guarantee that it will happen.
- * <p>
- * FIXME: this needs to be made more permanent since 3rd party plugins will depend on it heavily
- */
-public interface RepositoryListener
-{
- void deleteArtifact( MetadataRepository metadataRepository, String repositoryId, String namespace, String project,
- String version, String id );
-
- void addArtifact( RepositorySession session, String repoId, String namespace, String projectId,
- ProjectVersionMetadata metadata );
-
- // FIXME: this would be better as a "processException" method, with the event information captured in a single class
- void addArtifactProblem( RepositorySession session, String repoId, String namespace, String projectId,
- String projectVersion, RepositoryStorageMetadataException exception );
-}