Implement new Library Service API.
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/AbstractBaseView.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/AbstractBaseView.java
index 89379be..d75bf89 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/AbstractBaseView.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/AbstractBaseView.java
@@ -255,14 +255,18 @@
 	 * @see org.eclipse.epf.library.ILibraryServiceListener#libraryCreated(MethodLibrary)
 	 */
 	public void libraryCreated(MethodLibrary library) {
-		System.out.println("libraryCreated");
 	}
 
 	/**
 	 * @see org.eclipse.epf.library.ILibraryServiceListener#libraryOpened(MethodLibrary)
 	 */
 	public void libraryOpened(MethodLibrary library) {
-		System.out.println("libraryOpened");
+	}
+
+	/**
+	 * @see org.eclipse.epf.library.ILibraryServiceListener#libraryReopened(MethodLibrary)
+	 */
+	public void libraryReopened(MethodLibrary library) {
 	}
 
 	/**
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ConfigurationView.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ConfigurationView.java
index 0add09c..240545e 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ConfigurationView.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ConfigurationView.java
@@ -39,6 +39,7 @@
 import org.eclipse.epf.library.edit.TngAdapterFactory;
 import org.eclipse.epf.library.events.ILibraryChangeListener;
 import org.eclipse.epf.library.ui.LibraryUIManager;
+import org.eclipse.epf.library.ui.LibraryUIUtil;
 import org.eclipse.epf.uma.MethodConfiguration;
 import org.eclipse.epf.uma.MethodLibrary;
 import org.eclipse.jface.action.Action;
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
index 9e7313e..dd075b0 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
@@ -380,7 +380,7 @@
 			UIActionDispatcher.getInstance().setSelection(emptySelection);
 
 			getViewer().setInput(model);
-			updateLastRefreshTimestamp();
+			updateLastRefreshTimestamp();	
 		} else {
 			AuthoringUIPlugin
 					.getDefault()
@@ -453,7 +453,14 @@
 			statusLineManager.setMessage(path);
 		}
 	}
-
+	
+	/**
+	 * @see org.eclipse.epf.library.ILibraryServiceListener#libraryReopened(MethodLibrary)
+	 */
+	public void libraryReopened(MethodLibrary library) {
+		refreshViews();
+	}	
+	
 	class LibraryViewActionBarContributor extends LibraryActionBarContributor {
 
 		private IAction newPluginAction = new NewPluginAction(
diff --git a/plugins/org.eclipse.epf.import.xml/src/org/eclipse/epf/importing/xml/services/XmlImportService.java b/plugins/org.eclipse.epf.import.xml/src/org/eclipse/epf/importing/xml/services/XmlImportService.java
index 8cf2a2f..284aee2 100755
--- a/plugins/org.eclipse.epf.import.xml/src/org/eclipse/epf/importing/xml/services/XmlImportService.java
+++ b/plugins/org.eclipse.epf.import.xml/src/org/eclipse/epf/importing/xml/services/XmlImportService.java
@@ -157,7 +157,7 @@
 			LibraryUtil.saveLibrary(LibraryProcessor.getInstance().getLibrary(), true, false);
 			
 			logger.logMessage("re-open target library ..."); //$NON-NLS-1$
-			LibraryProcessor.getInstance().openLibrary();
+			LibraryService.getInstance().reopenCurrentMethodLibrary();
 						
 			logger.logMessage("import completed successfully ..."); //$NON-NLS-1$
 
diff --git a/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/ConfigurationImportService.java b/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/ConfigurationImportService.java
index fa4289d..84703b3 100755
--- a/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/ConfigurationImportService.java
+++ b/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/ConfigurationImportService.java
@@ -18,7 +18,6 @@
 import org.eclipse.epf.importing.ImportResources;
 import org.eclipse.epf.library.LibraryService;
 import org.eclipse.epf.library.project.MethodLibraryProject;
-import org.eclipse.epf.library.services.LibraryProcessor;
 import org.eclipse.epf.library.util.LibraryUtil;
 import org.eclipse.epf.persistence.refresh.RefreshJob;
 import org.eclipse.epf.uma.MethodLibrary;
@@ -156,10 +155,6 @@
 
 				importingMgr.doMerge(data.replaceExisting, monitor);
 			}
-
-			// refresh resources
-			LibraryProcessor.getInstance().refreshResources(monitor);
-
 		} catch (Exception e) {
 			ImportPlugin.getDefault().getLogger().logError(e);
 		} finally {
@@ -171,9 +166,8 @@
 		}	
 		
 		try {
-
 			// Reopen the library.
-			LibraryProcessor.getInstance().openLibrary();			
+			LibraryService.getInstance().reopenCurrentMethodLibrary();		
 
 		} catch (Exception e) {
 			ImportPlugin.getDefault().getLogger().logError(e);
diff --git a/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/PluginImportingService.java b/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/PluginImportingService.java
index d23470c..c7b8904 100755
--- a/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/PluginImportingService.java
+++ b/plugins/org.eclipse.epf.import/src/org/eclipse/epf/importing/services/PluginImportingService.java
@@ -168,9 +168,8 @@
 			}
 
 			// re-open library and fresh the workspace
-			LibraryProcessor.getInstance().openLibrary();
-
-			LibraryProcessor.getInstance().refreshResources(monitor);
+			MethodLibrary library = LibraryService.getInstance()
+					.reopenCurrentMethodLibrary();
 
 		} catch (Exception e) {
 			ImportPlugin.getDefault().getLogger().logError(e);
diff --git a/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java b/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
index 67ceb31..d49f398 100755
--- a/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
+++ b/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
@@ -22,6 +22,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.emf.common.CommonPlugin;
 import org.eclipse.epf.common.serviceability.MsgDialog;
+import org.eclipse.epf.library.ILibraryManager;
 import org.eclipse.epf.library.LibraryService;
 import org.eclipse.epf.library.services.LibraryProcessor;
 import org.eclipse.epf.library.ui.actions.ConfigurationContributionItem;
@@ -187,7 +188,8 @@
 				return;
 			}
 			if (XMILibraryUtil.isValidLibrary(libPath, true) == Status.OK_STATUS) {
-				if (LibraryProcessor.getInstance().isLibraryLocked(libPath)) {
+				ILibraryManager manager = LibraryService.getInstance().getCurrentLibraryManager();
+				if (manager != null && manager.isMethodLibraryLocked()) {
 					if (displayLibraryLockedMessage() != 0)
 						continue;
 				}
diff --git a/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/XMILibraryManager.java b/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/XMILibraryManager.java
index 9ad1e90..e29cfc2 100755
--- a/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/XMILibraryManager.java
+++ b/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/XMILibraryManager.java
@@ -154,6 +154,29 @@
 	}
 
 	/**
+	 * Reopens the managed method library.
+	 * 
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenMethodLibrary() throws LibraryServiceException {
+		String libraryPath = getMethodLibraryPath();
+		File libraryXMIFile = new File(libraryPath, LIBRARY_XMI);
+		if (!libraryXMIFile.exists()) {
+			throw new LibraryNotFoundException();
+		}
+
+		try {
+			libraryProcessor.openLibrary(libraryXMIFile.getAbsolutePath());
+			library = libraryProcessor.getLibrary();
+			return library;
+		} catch (Exception e) {
+			throw new LibraryServiceException(e);
+		}
+	}
+
+	/**
 	 * Saves a method library.
 	 * 
 	 * @throw <code>LibraryServiceException</code> if an error occurred while
@@ -218,6 +241,16 @@
 	}
 
 	/**
+	 * Checks whether the managed method library is locked.
+	 * 
+	 * @return <code>true</code> if the method library is locked.
+	 */
+	public boolean isMethodLibraryLocked() {
+		return libraryProcessor
+				.isLibraryLocked(new File(getMethodLibraryPath()));
+	}
+
+	/**
 	 * Attaches a changed listener to the managed method library.
 	 * 
 	 * @param listener
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryManager.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryManager.java
index 1d3c3e9..ec54049 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryManager.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryManager.java
@@ -52,6 +52,15 @@
 			throws LibraryServiceException;
 
 	/**
+	 * Reopens the managed method library.
+	 * 
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenMethodLibrary() throws LibraryServiceException;
+
+	/**
 	 * Saves a method library.
 	 * 
 	 * @throw <code>LibraryServiceException</code> if an error occurred while
@@ -99,6 +108,13 @@
 	public ComposedAdapterFactory getAdapterFactory();
 
 	/**
+	 * Checks whether the managed method library is locked.
+	 * 
+	 * @return <code>true</code> if the method library is locked.
+	 */
+	public boolean isMethodLibraryLocked();
+
+	/**
 	 * Attaches a changed listener to the managed method library.
 	 * 
 	 * @param listener
@@ -113,14 +129,15 @@
 	 *            A library change listener.
 	 */
 	public void removeListener(ILibraryChangeListener listener);
-	
+
 	/**
 	 * Returns a method element.
 	 * 
-	 * @param guid	The method element's GUID.
+	 * @param guid
+	 *            The method element's GUID.
 	 * 
 	 * @return A <code>MethodElement</code> or <code>null</code>.
 	 */
-	public MethodElement getMethodElement(String guid);	
+	public MethodElement getMethodElement(String guid);
 
 }
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryService.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryService.java
index 6966d71..f7928a8 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryService.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryService.java
@@ -84,6 +84,28 @@
 			throws LibraryServiceException;
 
 	/**
+	 * Reopens a method library.
+	 * 
+	 * @param library
+	 *            A method library.
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenMethodLibrary(MethodLibrary library)
+			throws LibraryServiceException;
+
+	/**
+	 * Reopens the current method library.
+	 * 
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenCurrentMethodLibrary()
+			throws LibraryServiceException;
+
+	/**
 	 * Saves a method library.
 	 * 
 	 * @param library
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryServiceListener.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryServiceListener.java
index cc943bd..7662165 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryServiceListener.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/ILibraryServiceListener.java
@@ -40,6 +40,14 @@
 	public void libraryOpened(MethodLibrary library);
 
 	/**
+	 * Receives notification when a method library has been reopened.
+	 * 
+	 * @param library
+	 *            A method library.
+	 */
+	public void libraryReopened(MethodLibrary library);
+
+	/**
 	 * Receives notification when a method library has been closed.
 	 * 
 	 * @param library
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryService.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryService.java
index 01b818f..1cec4ea 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryService.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryService.java
@@ -33,12 +33,14 @@
 	protected static final int EVENT_CREATE_LIBRARY = 1;
 
 	protected static final int EVENT_OPEN_LIBRARY = 2;
+	
+	protected static final int EVENT_REOPEN_LIBRARY = 3;	
 
-	protected static final int EVENT_CLOSE_LIBRARY = 3;
+	protected static final int EVENT_CLOSE_LIBRARY = 4;
 
-	protected static final int EVENT_SET_CURRENT_LIBRARY = 4;
+	protected static final int EVENT_SET_CURRENT_LIBRARY = 5;
 
-	protected static final int EVENT_SET_CURRENT_CONFIGURATION = 5;
+	protected static final int EVENT_SET_CURRENT_CONFIGURATION = 6;
 
 	// The shared instance.
 	protected static ILibraryService instance = null;
@@ -201,6 +203,42 @@
 	}
 
 	/**
+	 * Reopens a method library.
+	 * 
+	 * @param library
+	 *            A method library.
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenMethodLibrary(MethodLibrary library)
+			throws LibraryServiceException {
+		ILibraryManager manager = (ILibraryManager) libraryManagers
+				.get(library);
+		if (manager != null) {
+			try {
+				manager.reopenMethodLibrary();
+				notifyListeners(library, EVENT_REOPEN_LIBRARY);
+			} catch (Exception e) {
+				throw new LibraryServiceException(e);
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Reopens the current method library.
+	 * 
+	 * @return A <code>MethodLibrary</code>.
+	 * @throw <code>LibraryServiceException</code> if an error occurred while
+	 *        performing the operation.
+	 */
+	public MethodLibrary reopenCurrentMethodLibrary()
+			throws LibraryServiceException {
+		return reopenMethodLibrary(currentLibrary);
+	}
+
+	/**
 	 * Saves a method library.
 	 * 
 	 * @param library
@@ -465,6 +503,13 @@
 					}
 				});
 				break;
+			case EVENT_REOPEN_LIBRARY:
+				SafeUpdateController.syncExec(new Runnable() {
+					public void run() {
+						listener.libraryReopened(library);
+					}
+				});
+				break;				
 			case EVENT_CLOSE_LIBRARY:
 				SafeUpdateController.syncExec(new Runnable() {
 					public void run() {
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryModificationHelper.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryModificationHelper.java
index b4c19f6..9cf5c4f 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryModificationHelper.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryModificationHelper.java
@@ -19,13 +19,13 @@
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.epf.library.LibraryPlugin;
 import org.eclipse.epf.library.LibraryResources;
+import org.eclipse.epf.library.LibraryService;
 import org.eclipse.epf.library.edit.command.ActionManager;
 import org.eclipse.epf.library.edit.util.TngUtil;
 import org.eclipse.epf.uma.UmaPackage;
 import org.eclipse.epf.uma.util.ContentDescriptionFactory;
 import org.eclipse.epf.uma.util.IMethodLibraryPersister.FailSafeMethodLibraryPersister;
 
-
 /**
  * This helper is using an instance of IActionManager to keep track of changes.
  * Clien must {@link #dispose() <em>dispose</em>} this helper after use.
@@ -122,7 +122,8 @@
 				} catch (Throwable th) {
 					try {
 						// if rollback failed, reload the library
-						LibraryProcessor.getInstance().openLibrary();
+						LibraryService.getInstance()
+								.reopenCurrentMethodLibrary();
 					} catch (RuntimeException e1) {
 						e1.printStackTrace();
 					}
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryProcessor.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryProcessor.java
index eae3c6f..bb6ab3e 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryProcessor.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/services/LibraryProcessor.java
@@ -1355,43 +1355,4 @@
 		lock = FileUtil.lockFile(lockFile);
 	}
 
-	/**
-	 * refresh the resources of the library
-	 * @param path
-	 * @param monitor
-	 * @throws Exception
-	 */
-	public void refreshResources(IProgressMonitor monitor) throws Exception {
-		// does not work
-//		IResource res = FileManager.getResourceForLocation(getLibraryRootPath().getAbsolutePath());
-//		if ( res != null ) {
-//			res.refreshLocal(IResource.DEPTH_INFINITE, monitor);
-//		}
-		
-		// try this
-//		List processed = new ArrayList();
-//		Resource res = getLibrary().eResource();
-//		if ( res != null ) {
-//			ResourceSet resSet = res.getResourceSet();
-//			for ( Iterator it = resSet.getResources().iterator(); it.hasNext(); ) {
-//				res = (Resource) it.next();
-//				if ( res != null ) {
-//					File f = new File(res.getURI().toFileString());
-//					if ( f.isFile() ) {
-//						f = f.getParentFile();
-//					}
-//					String file = f.getAbsolutePath();
-//					if ( processed.contains(file) ) {
-//						continue;
-//					}
-//					
-//					processed.add(file);
-//					IResource ires = FileManager.getResourceForLocation(file);
-//					if ( ires != null ) {
-//						ires.refreshLocal(IResource.DEPTH_ONE, monitor);
-//					}
-//				}
-//			}
-//		}
-	}
 }
\ No newline at end of file