/*
 * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed 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.
 */
package com.b2international.snowowl.core.api.index;

import java.util.List;

import com.b2international.snowowl.core.api.IBranchPath;

/**
 * Interface for the index update service. You can add, delete or update the index based on the newly persisted element.
 * 
 * @param E the {@link IIndexEntry} subtype this index service uses
 * 
 */
public interface IIndexUpdater<E extends IIndexEntry> extends IIndexService<E> {
	
	/**
	 * Indexes a new entry, or updates an existing one if present.
	 * 
	 * @param branchPath the branch path reference limiting visibility to a particular branch (may not be {@code null})
	 * @param indexMappingStrategy generic strategy which is responsible for mapping to documents to be indexed (may not
	 * be {@code null})
	 */
	void index(final IBranchPath branchPath, final IIndexMappingStrategy indexMappingStrategy);
	
	/**
	 * Removes an entry from the index.
	 * 
	 * @param branchPath the branch path reference limiting visibility to a particular branch (may not be {@code null})
	 * @param storageKey the storage key of the document
	 */
	void delete(final IBranchPath branchPath, final long storageKey);

	/**
	 * Commits all pending changes to the index.
	 * 
	 * @param branchPath the branch path reference limiting visibility to a particular branch (may not be {@code null})
	 */
	void commit(final IBranchPath branchPath);
	
	/**
	 * Rolls back all pending changes.
	 * 
	 * @param branchPath the branch path reference limiting visibility to a particular branch (may not be {@code null})
	 */
	void rollback(final IBranchPath branchPath);
	
	/**
	 * Calling this method will drop all of the documents in the index.
	 * <p>
	 * <b>NOTE:</b> this method will forcefully abort all merges in progress. If other threads are running
	 * {@link #optimize(IBranchPath)} or {@link #index(IBranchPath, IIndexMappingStrategy)} methods, they will receive
	 * an {@link IndexException}.
	 * 
	 * @param branchPath the branch path reference limiting visibility to a particular branch (may not be {@code null})
	 */
	void deleteAll(final IBranchPath branchPath);
	
	/**
	 * Signals the index updater that the indexes for the specified branch path should be closed and removed from the disk.
	 * 
	 * @param branchPath
	 */
	void inactiveClose(final IBranchPath branchPath);

	/**
	 * Creates an empty commit with custom metadata set for a given branch index.
	 * 
	 * @param branchPath the branch path
	 * @param cdoBranchPath a sequence of CDO branch identifiers, starting with 0 (MAIN)
	 * @param baseTimestamp
	 */
	void reopen(final IBranchPath branchPath, final int[] cdoBranchPath, final long baseTimestamp);

	/**
	 * Returns with the UUID of the repository which is associated with the current index service. 
	 * @return the repository UUID.
	 */
	String getRepositoryUuid();
	
	/**
	 * Collects a list of absolute file paths that contain index data for the specified branch path. Note that the list
	 * may not be complete to reproduce an index by itself in case of "layered" indexes.
	 * @return the list of files which carry data for this update, or an empty list (never {@code null})
	 */
	List<String> listFiles(final IBranchPath branchPath);
}

@@ -698,16 +698,72 @@
 .List;%0A%0A
+import com.b2international.snowowl.core.api.BranchPath;%0A
 import c
@@ -1447,22 +1447,16 @@
 d index(
-final 
 IBranchP
@@ -1470,22 +1470,16 @@
 nchPath,
- final
  IIndexM
@@ -1754,22 +1754,16 @@
  delete(
-final 
 IBranchP
@@ -1773,30 +1773,24 @@
  branchPath,
- final
  long storag
@@ -1988,22 +1988,16 @@
  commit(
-final 
 IBranchP
@@ -2198,22 +2198,16 @@
 ollback(
-final 
 IBranchP
@@ -2701,22 +2701,16 @@
 leteAll(
-final 
 IBranchP
@@ -2906,22 +2906,16 @@
 veClose(
-final 
 IBranchP
@@ -3024,38 +3024,39 @@
 %09 * %0A%09 * @param 
-branch
+logical
 Path the branch 
@@ -3058,124 +3058,98 @@
 anch
- path%0A%09 * @param cdoBranchPath a sequence of CDO branch identifiers, starting with 0 (MAIN)%0A%09 * @param baseTimestamp
+-specific index service key to re-register%0A%09 * @param physicalPath the branch path to open
 %0A%09 *
@@ -3163,22 +3163,16 @@
  reopen(
-final 
 IBranchP
@@ -3179,71 +3179,44 @@
 ath 
-branchPath, final int%5B%5D cdoBranchPath, final long baseTimestamp
+logicalPath, BranchPath physicalPath
 );%0A%0A
@@ -3729,14 +3729,8 @@
 les(
-final 
 IBra

Remove final keywords from IIndexUpdater, change reopen sig.