diff options
author | Uwe Stieber | 2014-07-22 06:18:07 +0000 |
---|---|---|
committer | Uwe Stieber | 2014-07-22 06:18:07 +0000 |
commit | 74e2cbe5e8e0a1d4b7a9d9c5b18b36d06133add8 (patch) | |
tree | 4573ae7ee7f3b58c00b9032af46e6e5c06724784 /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core | |
parent | d8459b49d147c94baa877f455af893406ec9efca (diff) | |
download | org.eclipse.tcf-74e2cbe5e8e0a1d4b7a9d9c5b18b36d06133add8.tar.gz org.eclipse.tcf-74e2cbe5e8e0a1d4b7a9d9c5b18b36d06133add8.tar.xz org.eclipse.tcf-74e2cbe5e8e0a1d4b7a9d9c5b18b36d06133add8.zip |
Releng: Fix copyrights
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core')
67 files changed, 4298 insertions, 4320 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/build.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/build.properties index 29192edd0..01eb11d9e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/build.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/build.properties @@ -1,16 +1,16 @@ -###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
-# This program and the accompanying materials are made available under the terms
-# of the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Wind River Systems - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.properties,\
- plugin.xml,\
- about.html
+############################################################################### +# Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License v1.0 which accompanies this distribution, and is +# available at http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Wind River Systems - initial API and implementation +############################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties,\ + plugin.xml,\ + about.html diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.properties index 3b7f461be..89fbd0f70 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.properties @@ -1,12 +1,12 @@ -################################################################################## -# Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved. +############################################################################### +# Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. # This program and the accompanying materials are made available under the terms # of the Eclipse Public License v1.0 which accompanies this distribution, and is # available at http://www.eclipse.org/legal/epl-v10.html # # Contributors: -# Wind River Systems - initial API and implementation -################################################################################## +# Wind River Systems - initial API and implementation +############################################################################### providerName = Eclipse.org - Target Explorer pluginName = Target Explorer, TCF File System Extensions Core diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java index f8335f7fb..2260a4294 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java @@ -1,93 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.activator;
-
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.url.URLConstants;
-import org.osgi.service.url.URLStreamHandlerService;
-
-/**
- * The activator class of the core file system plugin.
- */
-public class CorePlugin extends Plugin {
-
- // The bundle context of this plugin.
- private static BundleContext context;
- // The shared instance of this plug-in.
- private static CorePlugin plugin;
- // The service registration for the "tcf" URL stream handler.
- private ServiceRegistration<?> regURLStreamHandlerService;
-
- /**
- * Get the bundle context of this plugin.
- * @return The bundle context object.
- */
- static BundleContext getContext() {
- return context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext bundleContext) throws Exception {
- super.start(bundleContext);
- CorePlugin.context = bundleContext;
- plugin = this;
- // Register the "tcf" URL stream handler service.
- Hashtable<String, String[]> properties = new Hashtable<String, String[]>();
- properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] { TcfURLConnection.PROTOCOL_SCHEMA });
- regURLStreamHandlerService = context.registerService(URLStreamHandlerService.class.getName(), new TcfURLStreamHandlerService(), properties);
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext bundleContext) throws Exception {
- if (PersistenceManager.needsDisposal()) PersistenceManager.getInstance().dispose();
- if (regURLStreamHandlerService != null) {
- // When URL stream handler service is unregistered, any URL related operation will be invalid.
- regURLStreamHandlerService.unregister();
- regURLStreamHandlerService = null;
- }
- CorePlugin.context = null;
- plugin = null;
- super.stop(bundleContext);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static CorePlugin getDefault() {
- return plugin;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- if (getContext() != null && getContext().getBundle() != null) {
- return getContext().getBundle().getSymbolicName();
- }
- return "org.eclipse.tcf.te.tcf.filesystem.core"; //$NON-NLS-1$
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.activator; + +import java.util.Hashtable; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.url.URLConstants; +import org.osgi.service.url.URLStreamHandlerService; + +/** + * The activator class of the core file system plugin. + */ +public class CorePlugin extends Plugin { + + // The bundle context of this plugin. + private static BundleContext context; + // The shared instance of this plug-in. + private static CorePlugin plugin; + // The service registration for the "tcf" URL stream handler. + private ServiceRegistration<?> regURLStreamHandlerService; + + /** + * Get the bundle context of this plugin. + * @return The bundle context object. + */ + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext bundleContext) throws Exception { + super.start(bundleContext); + CorePlugin.context = bundleContext; + plugin = this; + // Register the "tcf" URL stream handler service. + Hashtable<String, String[]> properties = new Hashtable<String, String[]>(); + properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] { TcfURLConnection.PROTOCOL_SCHEMA }); + regURLStreamHandlerService = context.registerService(URLStreamHandlerService.class.getName(), new TcfURLStreamHandlerService(), properties); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext bundleContext) throws Exception { + if (PersistenceManager.needsDisposal()) PersistenceManager.getInstance().dispose(); + if (regURLStreamHandlerService != null) { + // When URL stream handler service is unregistered, any URL related operation will be invalid. + regURLStreamHandlerService.unregister(); + regURLStreamHandlerService = null; + } + CorePlugin.context = null; + plugin = null; + super.stop(bundleContext); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static CorePlugin getDefault() { + return plugin; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getContext() != null && getContext().getBundle() != null) { + return getContext().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.tcf.filesystem.core"; //$NON-NLS-1$ + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IConfirmCallback.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IConfirmCallback.java index a3116b137..7d546e4d2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IConfirmCallback.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IConfirmCallback.java @@ -1,42 +1,42 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
-
-/**
- * A confirmation callback used to get UI confirmation from user for a long process
- */
-public interface IConfirmCallback {
- // Yes button ID.
- int YES = 0;
- // Yes to All button ID.
- int YES_TO_ALL = 1;
- // No to All button ID.
- int NO = 2;
- // Cancel button ID.
- int CANCEL = 3;
- // OK button ID.
- int OK = YES;
- // No to all button ID.
- int NO_TO_ALL = 4;
- /**
- * Test if the given object requires confirmation.
- *
- * @param object The object being tested.
- * @return true if it requires confirmation.
- */
- boolean requires(Object object);
- /**
- * Confirm with the user weather the process should continue, continue for all, skip or cancel.
- *
- * @param object The object being tested.
- * @return a button ID the user selects during confirmation.
- */
- int confirms(Object object);
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.interfaces; + +/** + * A confirmation callback used to get UI confirmation from user for a long process + */ +public interface IConfirmCallback { + // Yes button ID. + int YES = 0; + // Yes to All button ID. + int YES_TO_ALL = 1; + // No to All button ID. + int NO = 2; + // Cancel button ID. + int CANCEL = 3; + // OK button ID. + int OK = YES; + // No to all button ID. + int NO_TO_ALL = 4; + /** + * Test if the given object requires confirmation. + * + * @param object The object being tested. + * @return true if it requires confirmation. + */ + boolean requires(Object object); + /** + * Confirm with the user weather the process should continue, continue for all, skip or cancel. + * + * @param object The object being tested. + * @return a button ID the user selects during confirmation. + */ + int confirms(Object object); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java index 28d7df531..35ca4617b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java @@ -1,61 +1,61 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A class that implement this interface represents an file system operation,
- * which is an abstract of the action operated over files/folders.
- */
-public interface IOperation {
-
- /**
- * The algorithm of calculating the message digest of a file.
- */
- public static final String MD_ALG = "MD5"; //$NON-NLS-1$
-
- /**
- * Runs this operation. Progress should be reported to the given progress monitor.
- * A request to cancel the operation should be honored and acknowledged
- * by throwing <code>InterruptedException</code>.
- *
- * @param monitor the progress monitor to use to display progress and receive
- * requests for cancellation
- * @exception InvocationTargetException if the run method must propagate a checked exception,
- * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically
- * wrapped in an <code>InvocationTargetException</code> by the calling context
- * @exception InterruptedException if the operation detects a request to cancel,
- * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
- * <code>InterruptedException</code>
- *
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
-
- /**
- * Get the operation's name. This name will be used as the task name of
- * the given monitor.
- *
- * @see IProgressMonitor#beginTask(String, int)
- * @return The name of the operation.
- */
- public String getName();
-
- /**
- * Get the total amount of work which will used by the progress
- * monitor to set the total work.
- *
- * @see IProgressMonitor#beginTask(String, int)
- * @return The total amount of work or UNKNOWN if it is in-determinant
- */
- public int getTotalWork();
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.interfaces; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * A class that implement this interface represents an file system operation, + * which is an abstract of the action operated over files/folders. + */ +public interface IOperation { + + /** + * The algorithm of calculating the message digest of a file. + */ + public static final String MD_ALG = "MD5"; //$NON-NLS-1$ + + /** + * Runs this operation. Progress should be reported to the given progress monitor. + * A request to cancel the operation should be honored and acknowledged + * by throwing <code>InterruptedException</code>. + * + * @param monitor the progress monitor to use to display progress and receive + * requests for cancellation + * @exception InvocationTargetException if the run method must propagate a checked exception, + * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically + * wrapped in an <code>InvocationTargetException</code> by the calling context + * @exception InterruptedException if the operation detects a request to cancel, + * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing + * <code>InterruptedException</code> + * + */ + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException; + + /** + * Get the operation's name. This name will be used as the task name of + * the given monitor. + * + * @see IProgressMonitor#beginTask(String, int) + * @return The name of the operation. + */ + public String getName(); + + /** + * Get the total amount of work which will used by the progress + * monitor to set the total work. + * + * @see IProgressMonitor#beginTask(String, int) + * @return The total amount of work or UNKNOWN if it is in-determinant + */ + public int getTotalWork(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java index e0239d838..bc9030144 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java @@ -1,97 +1,97 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
-
-/**
- * Windows specific file system attribute definitions.
- *
- * @see <nop>Windows File Attribute Constants for more details.
- */
-public interface IWindowsFileAttributes {
-
- /**
- * If set, the file is read-only. Read-only files cannot be modified or deleted.
- * The attributes does not apply to directories.
- */
- public int FILE_ATTRIBUTE_READONLY = 1;
-
- /**
- * If set, the file or directory is hidden. Hidden files or directories should not
- * be included in default directory content lists.
- */
- public int FILE_ATTRIBUTE_HIDDEN = 2;
-
- /**
- * If set, the file or directory is reserved to be used by the OS.
- */
- public int FILE_ATTRIBUTE_SYSTEM = 4;
-
- /**
- * The file system object is a directory.
- */
- public int FILE_ATTRIBUTE_DIRECTORY = 16;
-
- /**
- * If set, the file or directory is an archive file or directory.
- */
- public int FILE_ATTRIBUTE_ARCHIVE = 32;
-
- /**
- * Reserved for system use.
- */
- public int FILE_ATTRIBUTE_DEVICE = 64;
-
- /**
- * The file system object is a file with no other attributes set. Valid
- * only if used exclusively.
- */
- public int FILE_ATTRIBUTE_NORMAL = 128;
-
- /**
- * If set, the file is used for temporary storage.
- */
- public int FILE_ATTRIBUTE_TEMPORARY = 256;
-
- /**
- * The file is a sparse file.
- */
- public int FILE_ATTRIBUTE_SPARSE_FILE = 512;
-
- /**
- * If set, the file or directory has an associated reparse point or is a symbolic link.
- */
- public int FILE_ATTRIBUTE_REPARSE_POINT = 1024;
-
- /**
- * If set, the file or directory is compressed.
- */
- public int FILE_ATTRIBUTE_COMPRESSED = 2048;
-
- /**
- * If set, the content of the file is currently not available.
- * This attribute should not be changed by applications.
- */
- public int FILE_ATTRIBUTE_OFFLINE = 4096;
-
- /**
- * If set, the file or directory is not indexed.
- */
- public int FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192;
-
- /**
- * If set, the file or directory is encrypted.
- */
- public int FILE_ATTRIBUTE_ENCRYPTED = 16384;
-
- /**
- * Reserved for system use.
- */
- public int FILE_ATTRIBUTE_VIRTUAL = 65536;
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.interfaces; + +/** + * Windows specific file system attribute definitions. + * + * @see <nop>Windows File Attribute Constants for more details. + */ +public interface IWindowsFileAttributes { + + /** + * If set, the file is read-only. Read-only files cannot be modified or deleted. + * The attributes does not apply to directories. + */ + public int FILE_ATTRIBUTE_READONLY = 1; + + /** + * If set, the file or directory is hidden. Hidden files or directories should not + * be included in default directory content lists. + */ + public int FILE_ATTRIBUTE_HIDDEN = 2; + + /** + * If set, the file or directory is reserved to be used by the OS. + */ + public int FILE_ATTRIBUTE_SYSTEM = 4; + + /** + * The file system object is a directory. + */ + public int FILE_ATTRIBUTE_DIRECTORY = 16; + + /** + * If set, the file or directory is an archive file or directory. + */ + public int FILE_ATTRIBUTE_ARCHIVE = 32; + + /** + * Reserved for system use. + */ + public int FILE_ATTRIBUTE_DEVICE = 64; + + /** + * The file system object is a file with no other attributes set. Valid + * only if used exclusively. + */ + public int FILE_ATTRIBUTE_NORMAL = 128; + + /** + * If set, the file is used for temporary storage. + */ + public int FILE_ATTRIBUTE_TEMPORARY = 256; + + /** + * The file is a sparse file. + */ + public int FILE_ATTRIBUTE_SPARSE_FILE = 512; + + /** + * If set, the file or directory has an associated reparse point or is a symbolic link. + */ + public int FILE_ATTRIBUTE_REPARSE_POINT = 1024; + + /** + * If set, the file or directory is compressed. + */ + public int FILE_ATTRIBUTE_COMPRESSED = 2048; + + /** + * If set, the content of the file is currently not available. + * This attribute should not be changed by applications. + */ + public int FILE_ATTRIBUTE_OFFLINE = 4096; + + /** + * If set, the file or directory is not indexed. + */ + public int FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192; + + /** + * If set, the file or directory is encrypted. + */ + public int FILE_ATTRIBUTE_ENCRYPTED = 16384; + + /** + * Reserved for system use. + */ + public int FILE_ATTRIBUTE_VIRTUAL = 65536; +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java index c89068eb4..bce7eba69 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java @@ -5,7 +5,7 @@ * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/steps/IFileSystemStepAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/steps/IFileSystemStepAttributes.java index 8801a4c7e..d9bcae4ee 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/steps/IFileSystemStepAttributes.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/steps/IFileSystemStepAttributes.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.steps; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java index e55ebccc5..8edbc92e1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java @@ -1,95 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River) - [352302]Opening a file in an editor depending on
- * the client's permissions.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal;
-
-/**
- * The data model of a user account.
- */
-public class UserAccount {
- // The user's id.
- private int uid;
- // The user's group id.
- private int gid;
- // The user's effective id.
- private int euid;
- // The user's effective group id.
- private int egid;
- // The user's home directory.
- private String home;
-
- /**
- * Create a user account with given data.
- *
- * @param uid
- * The user's id
- * @param gid
- * The user's group id
- * @param euid
- * The user's effective id.
- * @param egid
- * The user's effective group id.
- * @param home
- * The user's home directory.
- */
- public UserAccount(int uid, int gid, int euid, int egid, String home) {
- this.uid = uid;
- this.gid = gid;
- this.euid = euid;
- this.egid = egid;
- this.home = home;
- }
-
- /**
- * Get the user's id.
- *
- * @return The user's id.
- */
- public int getUID() {
- return uid;
- }
-
- /**
- * Get the user's group id.
- *
- * @return The user's group id.
- */
- public int getGID() {
- return gid;
- }
-
- /**
- * Get the user's effective id.
- *
- * @return The user's effective id.
- */
- public int getEUID() {
- return euid;
- }
-
- /**
- * Get the user's effective group id.
- *
- * @return The user's effective group id.
- */
- public int getEGID() {
- return egid;
- }
-
- /**
- * Get the user's home directory.
- *
- * @return The user's home directory.
- */
- public String getHome() {
- return home;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal; + +/** + * The data model of a user account. + */ +public class UserAccount { + // The user's id. + private int uid; + // The user's group id. + private int gid; + // The user's effective id. + private int euid; + // The user's effective group id. + private int egid; + // The user's home directory. + private String home; + + /** + * Create a user account with given data. + * + * @param uid + * The user's id + * @param gid + * The user's group id + * @param euid + * The user's effective id. + * @param egid + * The user's effective group id. + * @param home + * The user's home directory. + */ + public UserAccount(int uid, int gid, int euid, int egid, String home) { + this.uid = uid; + this.gid = gid; + this.euid = euid; + this.egid = egid; + this.home = home; + } + + /** + * Get the user's id. + * + * @return The user's id. + */ + public int getUID() { + return uid; + } + + /** + * Get the user's group id. + * + * @return The user's group id. + */ + public int getGID() { + return gid; + } + + /** + * Get the user's effective id. + * + * @return The user's effective id. + */ + public int getEUID() { + return euid; + } + + /** + * Get the user's effective group id. + * + * @return The user's effective group id. + */ + public int getEGID() { + return egid; + } + + /** + * Get the user's home directory. + * + * @return The user's home directory. + */ + public String getHome() { + return home; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java index f10f6b070..4dd8e4106 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import org.eclipse.tcf.protocol.IErrorReport;
-/**
- * The base class for all callback classes.
- */
-public class CallbackBase {
-
- /**
- * Get the error message from the throwable error.
- *
- * @param error The throwable error.
- * @return The error message.
- */
- protected String getErrorMessage(Throwable error) {
- String message = null;
- if(error instanceof IErrorReport) {
- IErrorReport report = (IErrorReport) error;
- message = (String)report.getAttributes().get(IErrorReport.ERROR_FORMAT);
- }
- else {
- message = error.getMessage();
- }
- return message;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import org.eclipse.tcf.protocol.IErrorReport; +/** + * The base class for all callback classes. + */ +public class CallbackBase { + + /** + * Get the error message from the throwable error. + * + * @param error The throwable error. + * @return The error message. + */ + protected String getErrorMessage(Throwable error) { + String message = null; + if(error instanceof IErrorReport) { + IErrorReport report = (IErrorReport) error; + message = (String)report.getAttributes().get(IErrorReport.ERROR_FORMAT); + } + else { + message = error.getMessage(); + } + return message; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java index d24c85997..6df6c0319 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java @@ -1,82 +1,82 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DoneClose;
-import org.eclipse.tcf.services.IFileSystem.DoneOpen;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.services.IFileSystem.IFileHandle;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event that a directory is opened.
- */
-public class QueryDoneOpen extends CallbackBase implements DoneOpen {
- // The tcf channel used.
- IChannel channel;
- // The file system service.
- IFileSystem service;
- // The parent node being queried.
- FSTreeNode parentNode;
- // The callback
- ICallback callback;
-
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param callback the callback
- * @param channel The tcf channel.
- * @param service The file system service.
- * @param node The parent node.
- */
- public QueryDoneOpen(ICallback callback, IChannel channel, IFileSystem service, FSTreeNode node) {
- this.callback = callback;
- this.channel = channel;
- this.service = service;
- this.parentNode = node;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneOpen#doneOpen(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.IFileHandle)
- */
- @Override
- public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
- if (error == null) {
- // Read the directory content until finished
- service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode));
- }
- else if (callback != null) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- if (handle != null) {
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- IStatus status;
- if (error == null) status = Status.OK_STATUS;
- else status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- });
- }
- else {
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.services.IFileSystem.DoneClose; +import org.eclipse.tcf.services.IFileSystem.DoneOpen; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.services.IFileSystem.IFileHandle; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The callback handler that handles the event that a directory is opened. + */ +public class QueryDoneOpen extends CallbackBase implements DoneOpen { + // The tcf channel used. + IChannel channel; + // The file system service. + IFileSystem service; + // The parent node being queried. + FSTreeNode parentNode; + // The callback + ICallback callback; + + /** + * Create an instance with parameters to initialize the fields. + * + * @param callback the callback + * @param channel The tcf channel. + * @param service The file system service. + * @param node The parent node. + */ + public QueryDoneOpen(ICallback callback, IChannel channel, IFileSystem service, FSTreeNode node) { + this.callback = callback; + this.channel = channel; + this.service = service; + this.parentNode = node; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem.DoneOpen#doneOpen(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.IFileHandle) + */ + @Override + public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) { + if (error == null) { + // Read the directory content until finished + service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode)); + } + else if (callback != null) { + // Close the handle and channel if EOF is signaled or an error occurred. + if (handle != null) { + service.close(handle, new DoneClose() { + @Override + public void doneClose(IToken token, FileSystemException error) { + IStatus status; + if (error == null) status = Status.OK_STATUS; + else status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error); + callback.done(this, status); + } + }); + } + else { + IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error); + callback.done(this, status); + } + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java index bd297ddde..16e973db6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java @@ -1,93 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The callback handler that handles the event when the channel opens.
- */
-public class QueryDoneOpenChannel extends CallbackBase implements DoneOpenChannel {
- // The parent node to be queried.
- FSTreeNode parentNode;
- // Callback object.
- ICallback callback;
-
- /**
- * Create an instance with a parent node.
- *
- * @param parentNode The parent node.
- */
- public QueryDoneOpenChannel(FSTreeNode parentNode) {
- this(parentNode, null);
- }
-
- /**
- * Create an instance with a parent node.
- *
- * @param parentNode The parent node.
- * @param callback Callback object.
- */
- public QueryDoneOpenChannel(FSTreeNode parentNode, ICallback callback) {
- this.parentNode = parentNode;
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel#doneOpenChannel(java.lang.Throwable, org.eclipse.tcf.protocol.IChannel)
- */
- @Override
- public void doneOpenChannel(Throwable error, final IChannel channel) {
- Assert.isTrue(Protocol.isDispatchThread());
- if(error == null) {
- ICallback proxy = new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- // Reset the children query markers
- parentNode.queryDone();
- Tcf.getChannelManager().closeChannel(channel);
- if(callback != null) {
- callback.done(caller, status);
- }
- }
- };
- IFileSystem service = channel.getRemoteService(IFileSystem.class);
- if(service != null) {
- if(parentNode.isSystemRoot()) {
- service.roots(new QueryDoneRoots(proxy, parentNode));
- } else {
- String absPath = parentNode.getLocation();
- service.opendir(absPath, new QueryDoneOpen(proxy, channel, service, parentNode));
- }
- } else {
- Status status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), Messages.Operation_NoFileSystemError, null);
- proxy.done(this, status);
- }
- }
- else if(!(error instanceof OperationCanceledException) && callback != null) {
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.te.runtime.callback.Callback; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * The callback handler that handles the event when the channel opens. + */ +public class QueryDoneOpenChannel extends CallbackBase implements DoneOpenChannel { + // The parent node to be queried. + FSTreeNode parentNode; + // Callback object. + ICallback callback; + + /** + * Create an instance with a parent node. + * + * @param parentNode The parent node. + */ + public QueryDoneOpenChannel(FSTreeNode parentNode) { + this(parentNode, null); + } + + /** + * Create an instance with a parent node. + * + * @param parentNode The parent node. + * @param callback Callback object. + */ + public QueryDoneOpenChannel(FSTreeNode parentNode, ICallback callback) { + this.parentNode = parentNode; + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel#doneOpenChannel(java.lang.Throwable, org.eclipse.tcf.protocol.IChannel) + */ + @Override + public void doneOpenChannel(Throwable error, final IChannel channel) { + Assert.isTrue(Protocol.isDispatchThread()); + if(error == null) { + ICallback proxy = new Callback(){ + @Override + protected void internalDone(Object caller, IStatus status) { + // Reset the children query markers + parentNode.queryDone(); + Tcf.getChannelManager().closeChannel(channel); + if(callback != null) { + callback.done(caller, status); + } + } + }; + IFileSystem service = channel.getRemoteService(IFileSystem.class); + if(service != null) { + if(parentNode.isSystemRoot()) { + service.roots(new QueryDoneRoots(proxy, parentNode)); + } else { + String absPath = parentNode.getLocation(); + service.opendir(absPath, new QueryDoneOpen(proxy, channel, service, parentNode)); + } + } else { + Status status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), Messages.Operation_NoFileSystemError, null); + proxy.done(this, status); + } + } + else if(!(error instanceof OperationCanceledException) && callback != null) { + IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error); + callback.done(this, status); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java index 414b7ef32..12b657855 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java @@ -1,96 +1,96 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.DoneClose;
-import org.eclipse.tcf.services.IFileSystem.DoneReadDir;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event when a directory is read.
- */
-public class QueryDoneReadDir extends CallbackBase implements DoneReadDir {
- // The tcf channel.
- IChannel channel;
- // The file system service.
- IFileSystem service;
- // The file handle of the parent directory.
- IFileSystem.IFileHandle handle;
- // The parent node being queried.
- FSTreeNode parentNode;
- // The callback object.
- ICallback callback;
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param channel The tcf channel.
- * @param service The file system service.
- * @param handle The directory's file handle.
- * @param parentNode The parent directory.
- */
- public QueryDoneReadDir(ICallback callback, IChannel channel, IFileSystem service, IFileSystem.IFileHandle handle, FSTreeNode parentNode) {
- this.callback = callback;
- this.channel = channel;
- this.service = service;
- this.handle = handle;
- this.parentNode = parentNode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneReadDir#doneReadDir(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[], boolean)
- */
- @Override
- public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) {
- // Process the returned data
- if (error == null) {
- if (entries != null && entries.length > 0) {
- for (DirEntry entry : entries) {
- FSTreeNode node = new FSTreeNode(parentNode, entry, false);
- parentNode.addChild(node);
- }
- }
-
- if (eof) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- if(callback != null) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), error.getMessage(), error);
- callback.done(this, status);
- }
- }});
- }
- else {
- // And invoke ourself again
- service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode));
- }
- } else if(callback != null) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- });
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.services.IFileSystem.DirEntry; +import org.eclipse.tcf.services.IFileSystem.DoneClose; +import org.eclipse.tcf.services.IFileSystem.DoneReadDir; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The callback handler that handles the event when a directory is read. + */ +public class QueryDoneReadDir extends CallbackBase implements DoneReadDir { + // The tcf channel. + IChannel channel; + // The file system service. + IFileSystem service; + // The file handle of the parent directory. + IFileSystem.IFileHandle handle; + // The parent node being queried. + FSTreeNode parentNode; + // The callback object. + ICallback callback; + /** + * Create an instance with parameters to initialize the fields. + * + * @param channel The tcf channel. + * @param service The file system service. + * @param handle The directory's file handle. + * @param parentNode The parent directory. + */ + public QueryDoneReadDir(ICallback callback, IChannel channel, IFileSystem service, IFileSystem.IFileHandle handle, FSTreeNode parentNode) { + this.callback = callback; + this.channel = channel; + this.service = service; + this.handle = handle; + this.parentNode = parentNode; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem.DoneReadDir#doneReadDir(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[], boolean) + */ + @Override + public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) { + // Process the returned data + if (error == null) { + if (entries != null && entries.length > 0) { + for (DirEntry entry : entries) { + FSTreeNode node = new FSTreeNode(parentNode, entry, false); + parentNode.addChild(node); + } + } + + if (eof) { + // Close the handle and channel if EOF is signaled or an error occurred. + service.close(handle, new DoneClose() { + @Override + public void doneClose(IToken token, FileSystemException error) { + if(callback != null) { + IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), error.getMessage(), error); + callback.done(this, status); + } + }}); + } + else { + // And invoke ourself again + service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode)); + } + } else if(callback != null) { + // Close the handle and channel if EOF is signaled or an error occurred. + service.close(handle, new DoneClose() { + @Override + public void doneClose(IToken token, FileSystemException error) { + IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error); + callback.done(this, status); + } + }); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java index ea4aaadf1..23af6e1c0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java @@ -1,64 +1,64 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.DoneRoots;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event when the roots are listed.
- */
-public class QueryDoneRoots extends CallbackBase implements DoneRoots {
- // The parent directory node.
- FSTreeNode parentNode;
- // The callback object
- ICallback callback;
-
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param callback the callback.
- * @param parentNode The parent directory node.
- */
- public QueryDoneRoots(ICallback callback, FSTreeNode parentNode) {
- this.callback = callback;
- this.parentNode = parentNode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneRoots#doneRoots(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[])
- */
- @Override
- public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
- if (error == null) {
- if (entries.length > 0) {
- for (DirEntry entry : entries) {
- FSTreeNode node = new FSTreeNode(parentNode, entry, true);
- parentNode.addChild(node);
- }
- }
- else {
- parentNode.clearChildren();
- }
- }
- if(callback != null) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem.DirEntry; +import org.eclipse.tcf.services.IFileSystem.DoneRoots; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The callback handler that handles the event when the roots are listed. + */ +public class QueryDoneRoots extends CallbackBase implements DoneRoots { + // The parent directory node. + FSTreeNode parentNode; + // The callback object + ICallback callback; + + /** + * Create an instance with parameters to initialize the fields. + * + * @param callback the callback. + * @param parentNode The parent directory node. + */ + public QueryDoneRoots(ICallback callback, FSTreeNode parentNode) { + this.callback = callback; + this.parentNode = parentNode; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem.DoneRoots#doneRoots(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[]) + */ + @Override + public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) { + if (error == null) { + if (entries.length > 0) { + for (DirEntry entry : entries) { + FSTreeNode node = new FSTreeNode(parentNode, entry, true); + parentNode.addChild(node); + } + } + else { + parentNode.clearChildren(); + } + } + if(callback != null) { + IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error); + callback.done(this, status); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java index d194fb97e..6c9b0cd3a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java index 6227671d8..65812d128 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java @@ -1,111 +1,111 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem.DoneStat;
-import org.eclipse.tcf.services.IFileSystem.FileAttrs;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpTargetFileDigest;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback to process the stat done event when
- * refreshing the state of a file system node.
- */
-public class RefreshStateDoneStat extends CallbackBase implements DoneStat {
- // The channel used to refresh the node's state.
- IChannel channel;
- // The node whose state is being refreshed.
- FSTreeNode node;
- // The callback to be invoked after refreshing.
- ICallback callback;
-
- /**
- * Create an instance
- */
- public RefreshStateDoneStat(FSTreeNode node, IChannel channel, ICallback callback) {
- this.node = node;
- this.channel = channel;
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs)
- */
- @Override
- public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
- Tcf.getChannelManager().closeChannel(channel);
- if (error == null) {
- FileAttrs oldAttrs = node.attr;
- node.setAttributes(attrs);
- // Only update a file's cache diagest.
- if (node.isFile()) {
- // Only update its target digest when it has a local cache file.
- File file = CacheManager.getCacheFile(node);
- if (file.exists()) {
- FileState fileDigest = PersistenceManager.getInstance().getFileDigest(node);
- if (fileDigest.getTargetDigest() == null || (oldAttrs == null && attrs != null || oldAttrs != null && attrs == null || oldAttrs != null && attrs != null && oldAttrs.mtime != attrs.mtime)) {
- // Its modification time has changed. Update the digest.
- updateTargetDigest();
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- String message = getErrorMessage(error);
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), message, error);
- invokeCallback(status);
- }
- }
-
- /**
- * Invoke the callback handler if it is not null using
- * the specified status.
- *
- * @param status The refreshing result.
- */
- protected void invokeCallback(IStatus status) {
- if(callback != null) {
- callback.done(this, status);
- }
- }
-
- /**
- * Update the node's target digest and invoke the callback
- * when the job is done.
- */
- private void updateTargetDigest() {
- JobExecutor executor = new JobExecutor(callback);
- executor.execute(new OpTargetFileDigest(node));
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks; + +import java.io.File; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem.DoneStat; +import org.eclipse.tcf.services.IFileSystem.FileAttrs; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpTargetFileDigest; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The callback to process the stat done event when + * refreshing the state of a file system node. + */ +public class RefreshStateDoneStat extends CallbackBase implements DoneStat { + // The channel used to refresh the node's state. + IChannel channel; + // The node whose state is being refreshed. + FSTreeNode node; + // The callback to be invoked after refreshing. + ICallback callback; + + /** + * Create an instance + */ + public RefreshStateDoneStat(FSTreeNode node, IChannel channel, ICallback callback) { + this.node = node; + this.channel = channel; + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs) + */ + @Override + public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) { + Tcf.getChannelManager().closeChannel(channel); + if (error == null) { + FileAttrs oldAttrs = node.attr; + node.setAttributes(attrs); + // Only update a file's cache diagest. + if (node.isFile()) { + // Only update its target digest when it has a local cache file. + File file = CacheManager.getCacheFile(node); + if (file.exists()) { + FileState fileDigest = PersistenceManager.getInstance().getFileDigest(node); + if (fileDigest.getTargetDigest() == null || (oldAttrs == null && attrs != null || oldAttrs != null && attrs == null || oldAttrs != null && attrs != null && oldAttrs.mtime != attrs.mtime)) { + // Its modification time has changed. Update the digest. + updateTargetDigest(); + } + else { + invokeCallback(Status.OK_STATUS); + } + } + else { + invokeCallback(Status.OK_STATUS); + } + } + else { + invokeCallback(Status.OK_STATUS); + } + } + else { + String message = getErrorMessage(error); + IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), message, error); + invokeCallback(status); + } + } + + /** + * Invoke the callback handler if it is not null using + * the specified status. + * + * @param status The refreshing result. + */ + protected void invokeCallback(IStatus status) { + if(callback != null) { + callback.done(this, status); + } + } + + /** + * Update the node's target digest and invoke the callback + * when the job is done. + */ + private void updateTargetDigest() { + JobExecutor executor = new JobExecutor(callback); + executor.execute(new OpTargetFileDigest(node)); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFChannelException.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFChannelException.java index c90975125..0151c77a4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFChannelException.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFChannelException.java @@ -1,44 +1,43 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions;
-
-/**
- * TCF channel exception.
- */
-public class TCFChannelException extends TCFException {
- private static final long serialVersionUID = 7414816212710485160L;
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- */
- public TCFChannelException(int severity, String message) {
- super(severity, message);
- }
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- * @param cause
- * The exception cause or <code>null</code>.
- */
- public TCFChannelException(int severity, String message, Throwable cause){
- super(severity, message, cause);
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions; + +/** + * TCF channel exception. + */ +public class TCFChannelException extends TCFException { + private static final long serialVersionUID = 7414816212710485160L; + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + */ + public TCFChannelException(int severity, String message) { + super(severity, message); + } + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + * @param cause + * The exception cause or <code>null</code>. + */ + public TCFChannelException(int severity, String message, Throwable cause){ + super(severity, message, cause); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java index 592ec2e41..be311e2b6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java @@ -1,73 +1,72 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions;
-
-/**
- * TCF file system implementation base exception.
- */
-public class TCFException extends Exception {
- private static final long serialVersionUID = -220092425137980661L;
-
- // The severity code of this exception, could be used in job status handling.
- private int severity;
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- */
- public TCFException(int severity, String message) {
- super(message);
- this.severity = severity;
- }
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- * @param cause
- * The exception cause or <code>null</code>.
- */
- public TCFException(int severity, String message, Throwable cause) {
- super(message, cause);
- this.severity = severity;
- }
-
- /**
- * Returns the severity. The severities are as follows (in
- * descending order):
- * <ul>
- * <li><code>CANCEL</code> - cancelation occurred</li>
- * <li><code>ERROR</code> - a serious error (most severe)</li>
- * <li><code>WARNING</code> - a warning (less severe)</li>
- * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
- * <li><code>OK</code> - everything is just fine</li>
- * </ul>
- * <p>
- * The severity of a multi-status is defined to be the maximum
- * severity of any of its children, or <code>OK</code> if it has
- * no children.
- * </p>
- *
- * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @see #matches(int)
- */
- public int getSeverity() {
- return severity;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions; + +/** + * TCF file system implementation base exception. + */ +public class TCFException extends Exception { + private static final long serialVersionUID = -220092425137980661L; + + // The severity code of this exception, could be used in job status handling. + private int severity; + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + */ + public TCFException(int severity, String message) { + super(message); + this.severity = severity; + } + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + * @param cause + * The exception cause or <code>null</code>. + */ + public TCFException(int severity, String message, Throwable cause) { + super(message, cause); + this.severity = severity; + } + + /** + * Returns the severity. The severities are as follows (in + * descending order): + * <ul> + * <li><code>CANCEL</code> - cancelation occurred</li> + * <li><code>ERROR</code> - a serious error (most severe)</li> + * <li><code>WARNING</code> - a warning (less severe)</li> + * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li> + * <li><code>OK</code> - everything is just fine</li> + * </ul> + * <p> + * The severity of a multi-status is defined to be the maximum + * severity of any of its children, or <code>OK</code> if it has + * no children. + * </p> + * + * @return the severity: one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @see #matches(int) + */ + public int getSeverity() { + return severity; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFFileSystemException.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFFileSystemException.java index 3971aa0d6..c914f3917 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFFileSystemException.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFFileSystemException.java @@ -1,45 +1,44 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions;
-
-/**
- * TCF remote file system exception.
- */
-public class TCFFileSystemException extends TCFException {
- private static final long serialVersionUID = -5203855887734608373L;
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- */
- public TCFFileSystemException(int severity, String message) {
- super(severity, message);
- }
-
- /**
- * Constructor.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param message
- * The exception detail message or <code>null</code>.
- * @param cause
- * The exception cause or <code>null</code>.
- */
- public TCFFileSystemException(int severity, String message, Throwable cause) {
- super(severity, message, cause);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions; + +/** + * TCF remote file system exception. + */ +public class TCFFileSystemException extends TCFException { + private static final long serialVersionUID = -5203855887734608373L; + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + */ + public TCFFileSystemException(int severity, String message) { + super(severity, message); + } + + /** + * Constructor. + * + * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>, + * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code> + * @param message + * The exception detail message or <code>null</code>. + * @param cause + * The exception cause or <code>null</code>. + */ + public TCFFileSystemException(int severity, String message, Throwable cause) { + super(severity, message, cause); + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java index 0be9bcb8d..aed4ad9df 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java @@ -1,28 +1,28 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-
-/**
- * The interface is to defined an operation executor, which executes
- * the given operation providing the context including the progress monitor.
- */
-public interface IOpExecutor {
- /**
- * Execute the specified operation providing an execution
- * context.
- *
- * @param operation The operation to be executed.
- * @return a result status of the execution.
- */
- public IStatus execute(IOperation operation);
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; + +/** + * The interface is to defined an operation executor, which executes + * the given operation providing the context including the progress monitor. + */ +public interface IOpExecutor { + /** + * Execute the specified operation providing an execution + * context. + * + * @param operation The operation to be executed. + * @return a result status of the execution. + */ + public IStatus execute(IOperation operation); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java index 92b6a1b0f..0c5a50b3d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java @@ -1,100 +1,100 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-
-/**
- * The operation that is executed as a back ground job.
- */
-public class JobExecutor implements IOpExecutor{
- // The callback
- protected ICallback callback;
-
- /**
- * Create an instance with no callback.
- */
- public JobExecutor() {
- this(null);
- }
-
- /**
- * Create an instance with the specified callback.
- *
- * @param callback called when the creation is done.
- */
- public JobExecutor(ICallback callback) {
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation)
- */
- @Override
- public IStatus execute(final IOperation operation) {
- Job job = new Job(operation.getName()){
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- monitor.setTaskName(operation.getName());
- monitor.beginTask(operation.getName(), operation.getTotalWork());
- operation.run(monitor);
- return Status.OK_STATUS;
- }
- catch (InvocationTargetException e) {
- Throwable throwable = e.getTargetException();
- if(throwable instanceof TCFException) {
- int severity = ((TCFException)throwable).getSeverity();
- return new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- }
- finally {
- monitor.done();
- }
- }};
- job.addJobChangeListener(new JobChangeAdapter(){
- @Override
- public void done(final IJobChangeEvent event) {
- doCallback(operation, event);
- }
- });
- job.schedule();
- return Status.OK_STATUS;
- }
-
- /**
- * Called when the creation is done.
- *
- * @param operation The operation object.
- * @param event The job change event.
- */
- void doCallback(IOperation operation, IJobChangeEvent event) {
- IStatus status = event.getResult();
- if(callback != null) {
- callback.done(operation, status);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; + +/** + * The operation that is executed as a back ground job. + */ +public class JobExecutor implements IOpExecutor{ + // The callback + protected ICallback callback; + + /** + * Create an instance with no callback. + */ + public JobExecutor() { + this(null); + } + + /** + * Create an instance with the specified callback. + * + * @param callback called when the creation is done. + */ + public JobExecutor(ICallback callback) { + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation) + */ + @Override + public IStatus execute(final IOperation operation) { + Job job = new Job(operation.getName()){ + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + monitor.setTaskName(operation.getName()); + monitor.beginTask(operation.getName(), operation.getTotalWork()); + operation.run(monitor); + return Status.OK_STATUS; + } + catch (InvocationTargetException e) { + Throwable throwable = e.getTargetException(); + if(throwable instanceof TCFException) { + int severity = ((TCFException)throwable).getSeverity(); + return new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable); + } + return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable); + } + catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } + finally { + monitor.done(); + } + }}; + job.addJobChangeListener(new JobChangeAdapter(){ + @Override + public void done(final IJobChangeEvent event) { + doCallback(operation, event); + } + }); + job.schedule(); + return Status.OK_STATUS; + } + + /** + * Called when the creation is done. + * + * @param operation The operation object. + * @param event The job change event. + */ + void doCallback(IOperation operation, IJobChangeEvent event) { + IStatus status = event.getResult(); + if(callback != null) { + callback.done(operation, status); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java index 5becbbbd1..d7d073784 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java @@ -1,79 +1,79 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-
-/**
- * An operation executor that executes an operation directly and silently.
- */
-public class NullOpExecutor implements IOpExecutor {
- // The callback being invoked after execution.
- ICallback callback;
-
- /**
- * Empty argument constructor
- */
- public NullOpExecutor() {
- this(null);
- }
-
- /**
- * Create an instance with a callback.
- *
- * @param callback The callback to be invoked after execution.
- */
- public NullOpExecutor(ICallback callback) {
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation)
- */
- @Override
- public IStatus execute(IOperation operation) {
- IProgressMonitor monitor = new NullProgressMonitor();
- IStatus status;
- try {
- monitor.setTaskName(operation.getName());
- monitor.beginTask(operation.getName(), operation.getTotalWork());
- operation.run(monitor);
- status = Status.OK_STATUS;
- }
- catch (InvocationTargetException e) {
- Throwable throwable = e.getTargetException();
- if (throwable instanceof TCFException) {
- int severity = ((TCFException) throwable).getSeverity();
- status = new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- else {
- status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- }
- catch (InterruptedException e) {
- status = Status.CANCEL_STATUS;
- }
- finally {
- monitor.done();
- }
- if(callback != null) callback.done(operation, status);
- return status;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; + +/** + * An operation executor that executes an operation directly and silently. + */ +public class NullOpExecutor implements IOpExecutor { + // The callback being invoked after execution. + ICallback callback; + + /** + * Empty argument constructor + */ + public NullOpExecutor() { + this(null); + } + + /** + * Create an instance with a callback. + * + * @param callback The callback to be invoked after execution. + */ + public NullOpExecutor(ICallback callback) { + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation) + */ + @Override + public IStatus execute(IOperation operation) { + IProgressMonitor monitor = new NullProgressMonitor(); + IStatus status; + try { + monitor.setTaskName(operation.getName()); + monitor.beginTask(operation.getName(), operation.getTotalWork()); + operation.run(monitor); + status = Status.OK_STATUS; + } + catch (InvocationTargetException e) { + Throwable throwable = e.getTargetException(); + if (throwable instanceof TCFException) { + int severity = ((TCFException) throwable).getSeverity(); + status = new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable); + } + else { + status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable); + } + } + catch (InterruptedException e) { + status = Status.CANCEL_STATUS; + } + finally { + monitor.done(); + } + if(callback != null) callback.done(operation, status); + return status; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java index 56d3c13cd..b1528628d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java @@ -1,112 +1,112 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The operation to calculate the message digest of a cache file.
- */
-public class OpCacheFileDigest implements IOperation {
- // The digest of which is going to be computed.
- FSTreeNode node;
- // The computing result
- byte[] digest;
-
- /**
- * Create an operation to compute the digest of its local cache file.
- *
- * @param node The file system node.
- */
- public OpCacheFileDigest(FSTreeNode node) {
- this.node = node;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- File file = CacheManager.getCacheFile(node);
- BufferedInputStream input = null;
- try {
- long totalSize = file.length();
- int chunk_size = (int) totalSize / 100;
- int percentRead = 0;
- long bytesRead = 0;
- MessageDigest digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest));
- byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE];
- int length;
- while ((length = input.read(data)) >= 0){
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- }
- }
- }
- this.digest = digest.digest();
- }
- catch (NoSuchAlgorithmException e) {
- throw new InvocationTargetException(e);
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (input != null) {
- try {input.close();} catch (Exception e) {}
- }
- }
- }
-
- /**
- * Get the computing result.
- *
- * @return The message digest of this cache file.
- */
- public byte[] getDigest() {
- return digest;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- return "Update cache digest"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The operation to calculate the message digest of a cache file. + */ +public class OpCacheFileDigest implements IOperation { + // The digest of which is going to be computed. + FSTreeNode node; + // The computing result + byte[] digest; + + /** + * Create an operation to compute the digest of its local cache file. + * + * @param node The file system node. + */ + public OpCacheFileDigest(FSTreeNode node) { + this.node = node; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + File file = CacheManager.getCacheFile(node); + BufferedInputStream input = null; + try { + long totalSize = file.length(); + int chunk_size = (int) totalSize / 100; + int percentRead = 0; + long bytesRead = 0; + MessageDigest digest = MessageDigest.getInstance(MD_ALG); + input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest)); + byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE]; + int length; + while ((length = input.read(data)) >= 0){ + bytesRead += length; + if (chunk_size != 0) { + int percent = (int) bytesRead / chunk_size; + if (percent != percentRead) { // Update the progress. + monitor.worked(percent - percentRead); + percentRead = percent; // Remember the percentage. + } + } + } + this.digest = digest.digest(); + } + catch (NoSuchAlgorithmException e) { + throw new InvocationTargetException(e); + } + catch (IOException e) { + throw new InvocationTargetException(e); + } + finally { + if (input != null) { + try {input.close();} catch (Exception e) {} + } + } + } + + /** + * Get the computing result. + * + * @return The message digest of this cache file. + */ + public byte[] getDigest() { + return digest; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName() + */ + @Override + public String getName() { + return "Update cache digest"; //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork() + */ + @Override + public int getTotalWork() { + return 100; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java index 215bd32ea..d7bab9ae0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java @@ -1,76 +1,76 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The operation class that updates the local cache to target file systems.
- */
-public class OpCacheUpdate extends OpDownload {
-
- /**
- * Create an instance of an OpCacheUpdate which
- * updates the specified nodes.
- *
- * @param nodes The nodes to be updated.
- */
- public OpCacheUpdate(FSTreeNode... nodes) {
- super(nodes);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- for (FSTreeNode node : srcNodes) {
- // Write the data to its local cache file.
- File file = CacheManager.getCachePath(node).toFile();
- if (file.exists() && !file.canWrite()) {
- // If the file exists and is read-only, delete it.
- deleteFileChecked(file);
- }
- }
- try {
- super.run(monitor);
- } finally {
- if (!monitor.isCanceled()) {
- for (FSTreeNode node : srcNodes) {
- File file = CacheManager.getCachePath(node).toFile();
- if (file.exists()) {
- // If downloading is successful, update the attributes of the file and
- // set the last modified time to that of its corresponding file.
- if (!node.isWritable()) setReadOnlyChecked(file);
- }
- }
- }
- monitor.done();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#updateNodeDigest(org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode, byte[])
- */
- @Override
- protected void updateNodeDigest(FSTreeNode node, byte[] digest) {
- FileState fdigest = PersistenceManager.getInstance().getFileDigest(node);
- fdigest.reset(digest);
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The operation class that updates the local cache to target file systems. + */ +public class OpCacheUpdate extends OpDownload { + + /** + * Create an instance of an OpCacheUpdate which + * updates the specified nodes. + * + * @param nodes The nodes to be updated. + */ + public OpCacheUpdate(FSTreeNode... nodes) { + super(nodes); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + for (FSTreeNode node : srcNodes) { + // Write the data to its local cache file. + File file = CacheManager.getCachePath(node).toFile(); + if (file.exists() && !file.canWrite()) { + // If the file exists and is read-only, delete it. + deleteFileChecked(file); + } + } + try { + super.run(monitor); + } finally { + if (!monitor.isCanceled()) { + for (FSTreeNode node : srcNodes) { + File file = CacheManager.getCachePath(node).toFile(); + if (file.exists()) { + // If downloading is successful, update the attributes of the file and + // set the last modified time to that of its corresponding file. + if (!node.isWritable()) setReadOnlyChecked(file); + } + } + } + monitor.done(); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#updateNodeDigest(org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode, byte[]) + */ + @Override + protected void updateNodeDigest(FSTreeNode node, byte[] digest) { + FileState fdigest = PersistenceManager.getInstance().getFileDigest(node); + fdigest.reset(digest); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java index 4b92a59b8..457527a6c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java index c6d16b186..272f6dc32 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java @@ -1,85 +1,85 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DoneSetStat;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-/**
- * The operation implementation to commit the new attributes to
- * the file system node.
- */
-public class OpCommitAttr extends Operation {
- // The node whose attributes are being updated.
- FSTreeNode node;
- // The new attributes for the file system node.
- IFileSystem.FileAttrs attrs;
-
- /**
- * Create an instance
- */
- public OpCommitAttr(FSTreeNode node, IFileSystem.FileAttrs attrs) {
- this.node = node;
- this.attrs = attrs;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- IChannel channel = null;
- try {
- channel = openChannel(node.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = Operation.getBlockingFileSystem(channel);
- if (service != null) {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- String path = node.getLocation(true);
- service.setstat(path, attrs, new DoneSetStat() {
- @Override
- public void doneSetStat(IToken token, FileSystemException error) {
- if (error == null) {
- node.setAttributes(attrs);
- } else {
- errors[0] = newTCFException(IStatus.WARNING, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- } else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
- }
- }
- catch(TCFException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.services.IFileSystem.DoneSetStat; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; +/** + * The operation implementation to commit the new attributes to + * the file system node. + */ +public class OpCommitAttr extends Operation { + // The node whose attributes are being updated. + FSTreeNode node; + // The new attributes for the file system node. + IFileSystem.FileAttrs attrs; + + /** + * Create an instance + */ + public OpCommitAttr(FSTreeNode node, IFileSystem.FileAttrs attrs) { + this.node = node; + this.attrs = attrs; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + IChannel channel = null; + try { + channel = openChannel(node.peerNode.getPeer()); + if (channel != null) { + IFileSystem service = Operation.getBlockingFileSystem(channel); + if (service != null) { + final TCFFileSystemException[] errors = new TCFFileSystemException[1]; + String path = node.getLocation(true); + service.setstat(path, attrs, new DoneSetStat() { + @Override + public void doneSetStat(IToken token, FileSystemException error) { + if (error == null) { + node.setAttributes(attrs); + } else { + errors[0] = newTCFException(IStatus.WARNING, error); + } + } + }); + if (errors[0] != null) { + throw errors[0]; + } + } else { + String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId()); + throw new TCFFileSystemException(IStatus.ERROR, message); + } + } + } + catch(TCFException e) { + throw new InvocationTargetException(e); + } + finally { + if (channel != null) Tcf.getChannelManager().closeChannel(channel); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java index eec8ce292..e6edae184 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java index ad9460869..e8750800d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java index 44d9bdc98..3f162e8ef 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java index f2ff3a59b..29c6eb396 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java index 5dea3e520..fd78a2c09 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java index 3b72c9355..835a2589b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java index d1d0e50d1..b4634b2df 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java index 2dc64d497..54ac3213b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java @@ -1,98 +1,98 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The operation class that download a file node to a specified output stream.
- */
-public class OpOutStreamOp extends OpStreamOp {
- // The output stream to write to.
- private OutputStream output;
- // The file node to download from.
- private FSTreeNode node;
-
- /**
- * Create an operation instance to download the specified file to the specified
- * output stream.
- *
- * @param node The file to be downloaded.
- * @param output The output stream to write to.
- */
- public OpOutStreamOp(FSTreeNode node, OutputStream output) {
- this.node = node;
- this.output = output;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- super.run(monitor);
- InputStream input = null;
- // Open the input stream of the node using the tcf stream protocol.
- try {
- URL url = node.getLocationURL();
- InputStream in = url.openStream();
- input = new BufferedInputStream(in);
- // The buffer used to download the file.
- byte[] data = new byte[DEFAULT_CHUNK_SIZE];
- // Calculate the chunk size of one percent.
- int chunk_size = (int) node.attr.size / 100;
- // Total size displayed on the progress dialog.
- String total_size = formatSize(node.attr.size);
-
- int percentRead = 0;
- long bytesRead = 0;
- int length;
- while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
- output.write(data, 0, length);
- output.flush();
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS.bind(Messages.OpOutStreamOp_DownloadingProgress, formatSize(bytesRead), total_size));
- }
- }
- }
- if(monitor.isCanceled()) throw new InterruptedException();
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (input != null) {
- try {
- input.close();
- }
- catch (Exception e) {
- }
- }
- monitor.done();
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * The operation class that download a file node to a specified output stream. + */ +public class OpOutStreamOp extends OpStreamOp { + // The output stream to write to. + private OutputStream output; + // The file node to download from. + private FSTreeNode node; + + /** + * Create an operation instance to download the specified file to the specified + * output stream. + * + * @param node The file to be downloaded. + * @param output The output stream to write to. + */ + public OpOutStreamOp(FSTreeNode node, OutputStream output) { + this.node = node; + this.output = output; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + super.run(monitor); + InputStream input = null; + // Open the input stream of the node using the tcf stream protocol. + try { + URL url = node.getLocationURL(); + InputStream in = url.openStream(); + input = new BufferedInputStream(in); + // The buffer used to download the file. + byte[] data = new byte[DEFAULT_CHUNK_SIZE]; + // Calculate the chunk size of one percent. + int chunk_size = (int) node.attr.size / 100; + // Total size displayed on the progress dialog. + String total_size = formatSize(node.attr.size); + + int percentRead = 0; + long bytesRead = 0; + int length; + while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) { + output.write(data, 0, length); + output.flush(); + bytesRead += length; + if (chunk_size != 0) { + int percent = (int) bytesRead / chunk_size; + if (percent != percentRead) { // Update the progress. + monitor.worked(percent - percentRead); + percentRead = percent; // Remember the percentage. + // Report the progress. + monitor.subTask(NLS.bind(Messages.OpOutStreamOp_DownloadingProgress, formatSize(bytesRead), total_size)); + } + } + } + if(monitor.isCanceled()) throw new InterruptedException(); + } + catch (IOException e) { + throw new InvocationTargetException(e); + } + finally { + if (input != null) { + try { + input.close(); + } + catch (Exception e) { + } + } + monitor.done(); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java index 625f37747..10a3202e7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java index 8df9e38eb..7dd58db32 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java index 6470c6e12..2ddb3cfec 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java index f7a0661c5..91fbf2aa0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java index 98857be1e..c0239dac2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java @@ -1,74 +1,74 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.File;
-import java.text.DecimalFormat;
-
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The operation class that streams file upward downward. It is the base
- * class for uploading, downloading, cache update and commit.
- */
-public abstract class OpStreamOp extends Operation {
- // The formatter used to format the size displayed while downloading.
- protected static final DecimalFormat SIZE_FORMAT = new DecimalFormat("#,##0.##"); //$NON-NLS-1$
- // The default chunk size of the buffer used during downloading files.
- public static final int DEFAULT_CHUNK_SIZE = 5 * 1024;
-
- /**
- * Check if the file exists and set its read-only attribute if it does. Record
- * the failure message if it fails.
- *
- * @param file The file to be set.
- */
- protected void setReadOnlyChecked(final File file) {
- if (file.exists()) {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void run() throws Exception {
- if (!file.setReadOnly()) {
- throw new Exception(NLS.bind(Messages.OpStreamOp_SetReadOnlyFailed, file.getAbsolutePath()));
- }
- }
-
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }});
- }
- }
-
- /**
- * Use the SIZE_FORMAT to format the file's size. The rule is: 1. If the
- * size is less than 1024 bytes, then show it as "####" bytes. 2. If the
- * size is less than 1024 KBs, while more than 1 KB, then show it as
- * "####.##" KBs. 3. If the size is more than 1 MB, then show it as
- * "####.##" MBs.
- *
- * @param size
- * The file size to be displayed.
- * @return The string representation of the size.
- */
- protected String formatSize(long size) {
- double kbSize = size / 1024.0;
- if (kbSize < 1.0) {
- return SIZE_FORMAT.format(size) + Messages.OpStreamOp_Bytes;
- }
- double mbSize = kbSize / 1024.0;
- if (mbSize < 1.0)
- return SIZE_FORMAT.format(kbSize) + Messages.OpStreamOp_KBs;
- return SIZE_FORMAT.format(mbSize) + Messages.OpStreamOp_MBs;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.File; +import java.text.DecimalFormat; + +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * The operation class that streams file upward downward. It is the base + * class for uploading, downloading, cache update and commit. + */ +public abstract class OpStreamOp extends Operation { + // The formatter used to format the size displayed while downloading. + protected static final DecimalFormat SIZE_FORMAT = new DecimalFormat("#,##0.##"); //$NON-NLS-1$ + // The default chunk size of the buffer used during downloading files. + public static final int DEFAULT_CHUNK_SIZE = 5 * 1024; + + /** + * Check if the file exists and set its read-only attribute if it does. Record + * the failure message if it fails. + * + * @param file The file to be set. + */ + protected void setReadOnlyChecked(final File file) { + if (file.exists()) { + SafeRunner.run(new ISafeRunnable(){ + @Override + public void run() throws Exception { + if (!file.setReadOnly()) { + throw new Exception(NLS.bind(Messages.OpStreamOp_SetReadOnlyFailed, file.getAbsolutePath())); + } + } + + @Override + public void handleException(Throwable exception) { + // Ignore on purpose + }}); + } + } + + /** + * Use the SIZE_FORMAT to format the file's size. The rule is: 1. If the + * size is less than 1024 bytes, then show it as "####" bytes. 2. If the + * size is less than 1024 KBs, while more than 1 KB, then show it as + * "####.##" KBs. 3. If the size is more than 1 MB, then show it as + * "####.##" MBs. + * + * @param size + * The file size to be displayed. + * @return The string representation of the size. + */ + protected String formatSize(long size) { + double kbSize = size / 1024.0; + if (kbSize < 1.0) { + return SIZE_FORMAT.format(size) + Messages.OpStreamOp_Bytes; + } + double mbSize = kbSize / 1024.0; + if (mbSize < 1.0) + return SIZE_FORMAT.format(kbSize) + Messages.OpStreamOp_KBs; + return SIZE_FORMAT.format(mbSize) + Messages.OpStreamOp_MBs; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java index f84a5cd0f..5d2063461 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java @@ -1,110 +1,110 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The operation that computes the digest of the cache file in the background.
- */
-public class OpTargetFileDigest implements IOperation {
- // The digest of which is going to be computed.
- FSTreeNode node;
- // The computing result
- byte[] digest;
-
- /**
- * Create an operation to compute the digest of its target file.
- *
- * @param node The file system node.
- */
- public OpTargetFileDigest(FSTreeNode node) {
- this.node = node;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- BufferedInputStream input = null;
- try {
- long totalSize = node.attr.size;
- int chunk_size = (int) totalSize / 100;
- int percentRead = 0;
- long bytesRead = 0;
- URL url = node.getLocationURL();
- MessageDigest digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(url.openStream(), digest));
- // The buffer used to download the file.
- byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE];
- int length;
- while ((length = input.read(data)) >= 0){
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- }
- }
- }
- this.digest = digest.digest();
- }
- catch (NoSuchAlgorithmException e) {
- throw new InvocationTargetException(e);
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (input != null) {
- try {input.close();} catch (Exception e) {}
- }
- }
- }
-
- /**
- * Get the computing result.
- *
- * @return The message digest of this cache file.
- */
- public byte[] getDigest() {
- return digest;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- return "Update target digest"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The operation that computes the digest of the cache file in the background. + */ +public class OpTargetFileDigest implements IOperation { + // The digest of which is going to be computed. + FSTreeNode node; + // The computing result + byte[] digest; + + /** + * Create an operation to compute the digest of its target file. + * + * @param node The file system node. + */ + public OpTargetFileDigest(FSTreeNode node) { + this.node = node; + } + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + BufferedInputStream input = null; + try { + long totalSize = node.attr.size; + int chunk_size = (int) totalSize / 100; + int percentRead = 0; + long bytesRead = 0; + URL url = node.getLocationURL(); + MessageDigest digest = MessageDigest.getInstance(MD_ALG); + input = new BufferedInputStream(new DigestInputStream(url.openStream(), digest)); + // The buffer used to download the file. + byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE]; + int length; + while ((length = input.read(data)) >= 0){ + bytesRead += length; + if (chunk_size != 0) { + int percent = (int) bytesRead / chunk_size; + if (percent != percentRead) { // Update the progress. + monitor.worked(percent - percentRead); + percentRead = percent; // Remember the percentage. + } + } + } + this.digest = digest.digest(); + } + catch (NoSuchAlgorithmException e) { + throw new InvocationTargetException(e); + } + catch (IOException e) { + throw new InvocationTargetException(e); + } + finally { + if (input != null) { + try {input.close();} catch (Exception e) {} + } + } + } + + /** + * Get the computing result. + * + * @return The message digest of this cache file. + */ + public byte[] getDigest() { + return digest; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName() + */ + @Override + public String getName() { + return "Update target digest"; //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork() + */ + @Override + public int getTotalWork() { + return 100; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java index c7018bbb4..364216a66 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java @@ -1,431 +1,431 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * Upload multiple files from local system to a remote system.
- */
-public class OpUpload extends OpStreamOp {
- // The source files to be uploaded.
- File[] srcFiles;
- // The destination URLs to be uploaded to.
- URL[] dstURLs;
- // The confirm callback
- IConfirmCallback confirmCallback;
- // The parent folder map to search files that have same names.
- Map<File, FSTreeNode> parentFolders;
- // The files that are to be committed to its target file system.
- FSTreeNode[] nodes;
-
- /**
- * Constructor.
- *
- * @param srcFile The source file to be uploaded.
- * @param dstURL The destination URL.
- */
- public OpUpload(File srcFile, URL dstURL) {
- this(new File[]{srcFile}, new URL[]{dstURL});
- }
-
- /**
- * Constructor.
- *
- * @param srcFiles The source files to be uploaded.
- * @param dstURLs The destination URLs.
- */
- public OpUpload(File[] srcFiles, URL[] dstURLs) {
- this(srcFiles, dstURLs, null);
- }
-
- /**
- * Constructor.
- *
- * @param sourceFiles The source files in the native file system to be uploaded.
- * @param targetFolder The taret parent folder to upload these files to.
- */
- public OpUpload(String[]sourceFiles, FSTreeNode targetFolder) {
- this(sourceFiles, targetFolder, null);
- }
-
- /**
- * Constructor.
- *
- * @param sourceFiles The source files in the native file system to be uploaded.
- * @param targetFolder The target parent folder to upload these files to.
- * @param confirmCallback the confirmation callback to confirm overwriting.
- */
- public OpUpload(File[] srcFiles, URL[] dstURLs, IConfirmCallback confirmCallback) {
- this.srcFiles = srcFiles;
- this.dstURLs = dstURLs;
- this.confirmCallback = confirmCallback;
- }
-
- /**
- * Constructor that upload the local cache files of the specified nodes.
- *
- * @param nodes The nodes to be uploaded.
- */
- public OpUpload(FSTreeNode... nodes) {
- srcFiles = new File[nodes.length];
- dstURLs = new URL[nodes.length];
- for (int i = 0; i < nodes.length; i++) {
- srcFiles[i] = CacheManager.getCacheFile(nodes[i]);
- dstURLs[i] = nodes[i].getLocationURL();
- }
- this.nodes = nodes;
- }
-
- /**
- * Create an instance with specified files, target folder and a callback.
- *
- * @param sourceFiles the source files being uploaded.
- * @param targetFolder the target folder to upload the files to.
- * @param callback the callback that is invoked after uploading.
- */
- public OpUpload(String[] sourceFiles, FSTreeNode targetFolder, IConfirmCallback confirmCallback) {
- this.confirmCallback = confirmCallback;
- List<File> fileList = new ArrayList<File>();
- List<URL> urlList = new ArrayList<URL>();
- prepareDirStruct(sourceFiles, fileList, urlList, targetFolder);
- srcFiles = fileList.toArray(new File[fileList.size()]);
- dstURLs = urlList.toArray(new URL[urlList.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.operations.FSOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- super.run(monitor);
- try {
- uploadFiles(srcFiles, dstURLs);
- if(monitor.isCanceled()) throw new InterruptedException();
- } catch (MalformedURLException e) {
- throw new InvocationTargetException(e);
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- /**
- * Test if the specified file should be confirmed.
- *
- * @param file The file to be confirmed.
- * @return true if it is.
- */
- private boolean requireConfirmation(File file) {
- return parentFolders != null && confirmCallback != null && !yes2All && confirmCallback.requires(file) && findNode(file) != null;
- }
-
- /**
- * Upload the specified file list to the specified locations, reporting the progress
- * using the specified monitor.
- *
- * @param files The file list to be uploaded.
- * @param urls The
- * @param monitor
- * @throws IOException
- */
- private void uploadFiles(File[] files, URL[] urls) throws IOException {
- // The buffer used to download the file.
- byte[] data = new byte[DEFAULT_CHUNK_SIZE];
- // Calculate the total size.
- long totalSize = 0;
- for (File file:files) {
- totalSize += file.length();
- }
- // Calculate the chunk size of one percent.
- int chunk_size = (int) totalSize / 100;
- // The current reading percentage.
- int percentRead = 0;
- // The current length of read bytes.
- long bytesRead = 0;
- for (int i = 0; i < files.length && !monitor.isCanceled(); i++) {
- File file = files[i];
- if (requireConfirmation(file)) {
- int result = confirmCallback.confirms(file);
- switch (result) {
- case IConfirmCallback.YES:
- break;
- case IConfirmCallback.YES_TO_ALL:
- yes2All = true;
- break;
- case IConfirmCallback.NO:
- bytesRead += file.length();
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS
- .bind(Messages.OpUpload_UploadingProgress, new Object[] { file
- .getName(), formatSize(bytesRead), formatSize(file
- .length()) }));
- }
- }
- continue;
- case IConfirmCallback.CANCEL:
- monitor.setCanceled(true);
- continue;
- }
- }
- BufferedInputStream input = null;
- BufferedOutputStream output = null;
- MessageDigest digest = null;
- try {
- URL url = urls[i];
- TcfURLConnection connection = (TcfURLConnection) url.openConnection();
- connection.setDoInput(false);
- connection.setDoOutput(true);
- if (nodes != null) {
- try {
- digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest));
- }
- catch (NoSuchAlgorithmException e) {
- input = new BufferedInputStream(new FileInputStream(file));
- }
- }
- else {
- input = new BufferedInputStream(new FileInputStream(file));
- }
- output = new BufferedOutputStream(connection.getOutputStream());
-
- // Total size displayed on the progress dialog.
- String fileLength = formatSize(file.length());
- int length;
- while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
- output.write(data, 0, length);
- output.flush();
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS.bind(Messages.OpUpload_UploadingProgress, new Object[]{file.getName(), formatSize(bytesRead), fileLength}));
- }
- }
- }
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (Exception e) {
- }
- }
- if (input != null) {
- try {
- input.close();
- } catch (Exception e) {
- }
- }
- if(digest != null && nodes != null) {
- FileState filedigest = PersistenceManager.getInstance().getFileDigest(nodes[i]);
- filedigest.reset(digest.digest());
- }
- }
- }
- }
-
- /**
- * Prepare the directory structure on the remote target, creating necessary intermediate directories
- * and found all files that should be uploaded. The resulting files to be uploaded should be stored
- * to the file list. The resulting corresponding target file URLs should be stored in the url list.
- *
- * @param fileList The file list to store the files that should be uploaded.
- * @param urlList The list containing the corresponding urls.
- */
- private void prepareDirStruct(String[] sourceFiles, List<File> fileList, List<URL> urlList, FSTreeNode targetFolder) {
- parentFolders = Collections.synchronizedMap(new HashMap<File, FSTreeNode>());
- List<File> files = new ArrayList<File>();
- for(String path: sourceFiles) {
- files.add(new File(path));
- }
- // Find the root nodes of these files.
- List<File> topFiles = getTopFiles(files);
- for(File topFile : topFiles) {
- appendFile(topFile, fileList, urlList, targetFolder);
- }
- }
-
- /**
- * Append the specified file object to the file list and url list. If the file object is a file
- * then append it to the two lists. If the file object is a directory, then recursively
- * add its children and grand children to the two list. During this process, the parents of
- * these files and directories traversed should be put into the parent folders map so that
- * it could be queried to check if it has a file/directory with a same name.
- *
- * @param file The file to be added
- * @param fileList The file list
- * @param urlList The url list
- * @param parent The current parent node
- */
- private void appendFile(final File file, final List<File> fileList, final List<URL> urlList, final FSTreeNode parent) {
- parentFolders.put(file, parent);
- if(file.isFile()) {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void run() throws Exception {
- URL folderURL = parent.getLocationURL();
- URL url = new URL(folderURL, file.getName());
- fileList.add(file);
- urlList.add(url);
- }
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }});
- } else if(file.isDirectory()) {
- FSTreeNode node = findNode(file);
- if(node == null) {
- OpCreateFolder create = new OpCreateFolder(parent, file.getName());
- new NullOpExecutor().execute(create);
- node = create.getNode();
- }
- File[] children = file.listFiles();
- for(File child : children) {
- appendFile(child, fileList, urlList, node);
- }
- }
- }
-
- /**
- * Get the root files of the specified files/folders in the list.
- *
- * @param files The files to be checked.
- * @return Root nodes of these files that has no parent.
- */
- private List<File> getTopFiles(List<File>files) {
- List<File> result = new ArrayList<File>();
- for(File file : files) {
- if(!hasFileAncestor(file, files)) {
- result.add(file);
- }
- }
- return result;
- }
-
- /**
- * Check if the target file has an ancestral parent in the specified list.
- *
- * @param target The target file to be checked.
- * @param files The file list to be searched.
- * @return true if it has an ancestral parent.
- */
- private boolean hasFileAncestor(File target, List<File> files) {
- for(File file : files) {
- if(isFileAncestor(file, target)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if the specified "file" is an ancestral parent of the "target" file.
- *
- * @param file The ancestral file.
- * @param target The target file.
- * @return true if "file" is an ancestral parent of "target"
- */
- private boolean isFileAncestor(File file, File target) {
- if(target == null) return false;
- File parent = target.getParentFile();
- if(file.equals(parent)) return true;
- return isFileAncestor(file, parent);
- }
-
- /**
- * Check if the specified file has a same-named file under its corresponding
- * parent folder.
- *
- * @param file The file to checked.
- * @return the node that has the same name with the file.
- */
- private FSTreeNode findNode(File file) {
- final FSTreeNode parent = parentFolders.get(file);
- if (parent != null) {
- final List<FSTreeNode> targetChildren = new ArrayList<FSTreeNode>();
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- targetChildren.addAll(getChildren(parent));
- }
-
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }
- });
- String name = file.getName();
- for (FSTreeNode child : targetChildren) {
- if (name.equals(child.name)) return child;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- String message;
- if(srcFiles.length==1)
- message = NLS.bind(Messages.OpUpload_UploadSingleFile, srcFiles[0].getName());
- else
- message = NLS.bind(Messages.OpUpload_UploadNFiles, Long.valueOf(srcFiles.length));
- return message;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * Upload multiple files from local system to a remote system. + */ +public class OpUpload extends OpStreamOp { + // The source files to be uploaded. + File[] srcFiles; + // The destination URLs to be uploaded to. + URL[] dstURLs; + // The confirm callback + IConfirmCallback confirmCallback; + // The parent folder map to search files that have same names. + Map<File, FSTreeNode> parentFolders; + // The files that are to be committed to its target file system. + FSTreeNode[] nodes; + + /** + * Constructor. + * + * @param srcFile The source file to be uploaded. + * @param dstURL The destination URL. + */ + public OpUpload(File srcFile, URL dstURL) { + this(new File[]{srcFile}, new URL[]{dstURL}); + } + + /** + * Constructor. + * + * @param srcFiles The source files to be uploaded. + * @param dstURLs The destination URLs. + */ + public OpUpload(File[] srcFiles, URL[] dstURLs) { + this(srcFiles, dstURLs, null); + } + + /** + * Constructor. + * + * @param sourceFiles The source files in the native file system to be uploaded. + * @param targetFolder The taret parent folder to upload these files to. + */ + public OpUpload(String[]sourceFiles, FSTreeNode targetFolder) { + this(sourceFiles, targetFolder, null); + } + + /** + * Constructor. + * + * @param sourceFiles The source files in the native file system to be uploaded. + * @param targetFolder The target parent folder to upload these files to. + * @param confirmCallback the confirmation callback to confirm overwriting. + */ + public OpUpload(File[] srcFiles, URL[] dstURLs, IConfirmCallback confirmCallback) { + this.srcFiles = srcFiles; + this.dstURLs = dstURLs; + this.confirmCallback = confirmCallback; + } + + /** + * Constructor that upload the local cache files of the specified nodes. + * + * @param nodes The nodes to be uploaded. + */ + public OpUpload(FSTreeNode... nodes) { + srcFiles = new File[nodes.length]; + dstURLs = new URL[nodes.length]; + for (int i = 0; i < nodes.length; i++) { + srcFiles[i] = CacheManager.getCacheFile(nodes[i]); + dstURLs[i] = nodes[i].getLocationURL(); + } + this.nodes = nodes; + } + + /** + * Create an instance with specified files, target folder and a callback. + * + * @param sourceFiles the source files being uploaded. + * @param targetFolder the target folder to upload the files to. + * @param callback the callback that is invoked after uploading. + */ + public OpUpload(String[] sourceFiles, FSTreeNode targetFolder, IConfirmCallback confirmCallback) { + this.confirmCallback = confirmCallback; + List<File> fileList = new ArrayList<File>(); + List<URL> urlList = new ArrayList<URL>(); + prepareDirStruct(sourceFiles, fileList, urlList, targetFolder); + srcFiles = fileList.toArray(new File[fileList.size()]); + dstURLs = urlList.toArray(new URL[urlList.size()]); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.internal.operations.FSOperation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + super.run(monitor); + try { + uploadFiles(srcFiles, dstURLs); + if(monitor.isCanceled()) throw new InterruptedException(); + } catch (MalformedURLException e) { + throw new InvocationTargetException(e); + } catch (IOException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + /** + * Test if the specified file should be confirmed. + * + * @param file The file to be confirmed. + * @return true if it is. + */ + private boolean requireConfirmation(File file) { + return parentFolders != null && confirmCallback != null && !yes2All && confirmCallback.requires(file) && findNode(file) != null; + } + + /** + * Upload the specified file list to the specified locations, reporting the progress + * using the specified monitor. + * + * @param files The file list to be uploaded. + * @param urls The + * @param monitor + * @throws IOException + */ + private void uploadFiles(File[] files, URL[] urls) throws IOException { + // The buffer used to download the file. + byte[] data = new byte[DEFAULT_CHUNK_SIZE]; + // Calculate the total size. + long totalSize = 0; + for (File file:files) { + totalSize += file.length(); + } + // Calculate the chunk size of one percent. + int chunk_size = (int) totalSize / 100; + // The current reading percentage. + int percentRead = 0; + // The current length of read bytes. + long bytesRead = 0; + for (int i = 0; i < files.length && !monitor.isCanceled(); i++) { + File file = files[i]; + if (requireConfirmation(file)) { + int result = confirmCallback.confirms(file); + switch (result) { + case IConfirmCallback.YES: + break; + case IConfirmCallback.YES_TO_ALL: + yes2All = true; + break; + case IConfirmCallback.NO: + bytesRead += file.length(); + if (chunk_size != 0) { + int percent = (int) bytesRead / chunk_size; + if (percent != percentRead) { // Update the progress. + monitor.worked(percent - percentRead); + percentRead = percent; // Remember the percentage. + // Report the progress. + monitor.subTask(NLS + .bind(Messages.OpUpload_UploadingProgress, new Object[] { file + .getName(), formatSize(bytesRead), formatSize(file + .length()) })); + } + } + continue; + case IConfirmCallback.CANCEL: + monitor.setCanceled(true); + continue; + } + } + BufferedInputStream input = null; + BufferedOutputStream output = null; + MessageDigest digest = null; + try { + URL url = urls[i]; + TcfURLConnection connection = (TcfURLConnection) url.openConnection(); + connection.setDoInput(false); + connection.setDoOutput(true); + if (nodes != null) { + try { + digest = MessageDigest.getInstance(MD_ALG); + input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest)); + } + catch (NoSuchAlgorithmException e) { + input = new BufferedInputStream(new FileInputStream(file)); + } + } + else { + input = new BufferedInputStream(new FileInputStream(file)); + } + output = new BufferedOutputStream(connection.getOutputStream()); + + // Total size displayed on the progress dialog. + String fileLength = formatSize(file.length()); + int length; + while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) { + output.write(data, 0, length); + output.flush(); + bytesRead += length; + if (chunk_size != 0) { + int percent = (int) bytesRead / chunk_size; + if (percent != percentRead) { // Update the progress. + monitor.worked(percent - percentRead); + percentRead = percent; // Remember the percentage. + // Report the progress. + monitor.subTask(NLS.bind(Messages.OpUpload_UploadingProgress, new Object[]{file.getName(), formatSize(bytesRead), fileLength})); + } + } + } + } finally { + if (output != null) { + try { + output.close(); + } catch (Exception e) { + } + } + if (input != null) { + try { + input.close(); + } catch (Exception e) { + } + } + if(digest != null && nodes != null) { + FileState filedigest = PersistenceManager.getInstance().getFileDigest(nodes[i]); + filedigest.reset(digest.digest()); + } + } + } + } + + /** + * Prepare the directory structure on the remote target, creating necessary intermediate directories + * and found all files that should be uploaded. The resulting files to be uploaded should be stored + * to the file list. The resulting corresponding target file URLs should be stored in the url list. + * + * @param fileList The file list to store the files that should be uploaded. + * @param urlList The list containing the corresponding urls. + */ + private void prepareDirStruct(String[] sourceFiles, List<File> fileList, List<URL> urlList, FSTreeNode targetFolder) { + parentFolders = Collections.synchronizedMap(new HashMap<File, FSTreeNode>()); + List<File> files = new ArrayList<File>(); + for(String path: sourceFiles) { + files.add(new File(path)); + } + // Find the root nodes of these files. + List<File> topFiles = getTopFiles(files); + for(File topFile : topFiles) { + appendFile(topFile, fileList, urlList, targetFolder); + } + } + + /** + * Append the specified file object to the file list and url list. If the file object is a file + * then append it to the two lists. If the file object is a directory, then recursively + * add its children and grand children to the two list. During this process, the parents of + * these files and directories traversed should be put into the parent folders map so that + * it could be queried to check if it has a file/directory with a same name. + * + * @param file The file to be added + * @param fileList The file list + * @param urlList The url list + * @param parent The current parent node + */ + private void appendFile(final File file, final List<File> fileList, final List<URL> urlList, final FSTreeNode parent) { + parentFolders.put(file, parent); + if(file.isFile()) { + SafeRunner.run(new ISafeRunnable(){ + @Override + public void run() throws Exception { + URL folderURL = parent.getLocationURL(); + URL url = new URL(folderURL, file.getName()); + fileList.add(file); + urlList.add(url); + } + @Override + public void handleException(Throwable exception) { + // Ignore on purpose + }}); + } else if(file.isDirectory()) { + FSTreeNode node = findNode(file); + if(node == null) { + OpCreateFolder create = new OpCreateFolder(parent, file.getName()); + new NullOpExecutor().execute(create); + node = create.getNode(); + } + File[] children = file.listFiles(); + for(File child : children) { + appendFile(child, fileList, urlList, node); + } + } + } + + /** + * Get the root files of the specified files/folders in the list. + * + * @param files The files to be checked. + * @return Root nodes of these files that has no parent. + */ + private List<File> getTopFiles(List<File>files) { + List<File> result = new ArrayList<File>(); + for(File file : files) { + if(!hasFileAncestor(file, files)) { + result.add(file); + } + } + return result; + } + + /** + * Check if the target file has an ancestral parent in the specified list. + * + * @param target The target file to be checked. + * @param files The file list to be searched. + * @return true if it has an ancestral parent. + */ + private boolean hasFileAncestor(File target, List<File> files) { + for(File file : files) { + if(isFileAncestor(file, target)) { + return true; + } + } + return false; + } + + /** + * Check if the specified "file" is an ancestral parent of the "target" file. + * + * @param file The ancestral file. + * @param target The target file. + * @return true if "file" is an ancestral parent of "target" + */ + private boolean isFileAncestor(File file, File target) { + if(target == null) return false; + File parent = target.getParentFile(); + if(file.equals(parent)) return true; + return isFileAncestor(file, parent); + } + + /** + * Check if the specified file has a same-named file under its corresponding + * parent folder. + * + * @param file The file to checked. + * @return the node that has the same name with the file. + */ + private FSTreeNode findNode(File file) { + final FSTreeNode parent = parentFolders.get(file); + if (parent != null) { + final List<FSTreeNode> targetChildren = new ArrayList<FSTreeNode>(); + SafeRunner.run(new ISafeRunnable() { + @Override + public void run() throws Exception { + targetChildren.addAll(getChildren(parent)); + } + + @Override + public void handleException(Throwable exception) { + // Ignore on purpose + } + }); + String name = file.getName(); + for (FSTreeNode child : targetChildren) { + if (name.equals(child.name)) return child; + } + } + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName() + */ + @Override + public String getName() { + String message; + if(srcFiles.length==1) + message = NLS.bind(Messages.OpUpload_UploadSingleFile, srcFiles[0].getName()); + else + message = NLS.bind(Messages.OpUpload_UploadNFiles, Long.valueOf(srcFiles.length)); + return message; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork() + */ + @Override + public int getTotalWork() { + return 100; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java index 269f9b142..ecded937e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java index 117667b3e..d8b5f8dce 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java index f0e90f7ac..a4deb32a8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java @@ -1,116 +1,113 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River) - [345387]Open the remote files with a proper editor
- * William Chen (Wind River) - [352302]Opening a file in an editor depending on
- * the client's permissions.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.testers;
-
-import java.io.File;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.ContentTypeHelper;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The property tester of an FSTreeNode. The properties include "isFile"
- * if it is a file node, "isDirectory" if it is a directory, "isBinaryFile"
- * if it is a binary file, "isReadable" if it is readable, "isWritable" if
- * it is writable, "isExecutable" if it is executable, "isRoot" if it is a
- * root directory, "isWindows" if it is a windows file node, "isReadOnly"
- * if it is read only, "isHidden" if it is hidden, "getCacheState" to
- * get a node's state.
- * <p>
- * "testParent" is a property by which the parent or even the grand parent
- * of a node can be tested. The arguments is a recursive list of the above
- * test property including "testParent".
- * <p>
- * The following is an example of how it is used.
- * <pre>
- * <test
- * args="isWritable"
- * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent">
- * </test>
- * </pre>
- * <p>
- * The above example tests if the parent node is writable.
- * <pre>
- * <test
- * args="testParent,isWritable"
- * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent">
- * </test>
- * </pre>
- * <p>
- * The above example tests if the grand parent node is writable.
- * <p>
- * And so on, you can test its ancestor recursively:
- * <pre>
- * <test
- * args="testParent,testParent,testParent,...,isWritable"
- * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent">
- * </test>
- * </pre>
- */
-public class FSTreeNodePropertyTester extends PropertyTester {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
- */
- @Override
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if(receiver == null)
- return false;
- Assert.isTrue(receiver instanceof FSTreeNode);
- FSTreeNode node = (FSTreeNode) receiver;
- if (property.equals("isFile")) { //$NON-NLS-1$
- return node.isFile();
- } else if (property.equals("isDirectory")) { //$NON-NLS-1$
- return node.isDirectory();
- } else if (property.equals("isBinaryFile")) { //$NON-NLS-1$
- return ContentTypeHelper.isBinaryFile(node);
- } else if (property.equals("isReadable")){ //$NON-NLS-1$
- return node.isReadable();
- } else if (property.equals("isWritable")){ //$NON-NLS-1$
- return node.isWritable();
- } else if (property.equals("isExecutable")){ //$NON-NLS-1$
- return node.isExecutable();
- } else if (property.equals("isRoot")) { //$NON-NLS-1$
- return node.isRoot();
- } else if (property.equals("isSystemRoot")) { //$NON-NLS-1$
- return node.isSystemRoot();
- } else if (property.equals("isWindows")) { //$NON-NLS-1$
- return node.isWindowsNode();
- } else if (property.equals("isReadOnly")) { //$NON-NLS-1$
- return node.isReadOnly();
- } else if (property.equals("isHidden")) { //$NON-NLS-1$
- return node.isHidden();
- } else if (property.equals("testParent")) { //$NON-NLS-1$
- return testParent(node, args, expectedValue);
- } else if (property.equals("getCacheState")){ //$NON-NLS-1$
- File file = CacheManager.getCacheFile(node);
- if(!file.exists())
- return false;
- CacheState state = node.getCacheState();
- return state.name().equals(expectedValue);
- }
- return false;
- }
-
- private boolean testParent(FSTreeNode node, Object[] args, Object expectedValue) {
- if(args == null || args.length == 0)
- return false;
- String arg = (String) args[0];
- Object[] newArgs = new Object[args.length -1];
- System.arraycopy(args, 1, newArgs, 0, args.length - 1);
- return test(node.getParent(), arg, newArgs, expectedValue);
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.testers; + +import java.io.File; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.ContentTypeHelper; +import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The property tester of an FSTreeNode. The properties include "isFile" + * if it is a file node, "isDirectory" if it is a directory, "isBinaryFile" + * if it is a binary file, "isReadable" if it is readable, "isWritable" if + * it is writable, "isExecutable" if it is executable, "isRoot" if it is a + * root directory, "isWindows" if it is a windows file node, "isReadOnly" + * if it is read only, "isHidden" if it is hidden, "getCacheState" to + * get a node's state. + * <p> + * "testParent" is a property by which the parent or even the grand parent + * of a node can be tested. The arguments is a recursive list of the above + * test property including "testParent". + * <p> + * The following is an example of how it is used. + * <pre> + * <test + * args="isWritable" + * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent"> + * </test> + * </pre> + * <p> + * The above example tests if the parent node is writable. + * <pre> + * <test + * args="testParent,isWritable" + * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent"> + * </test> + * </pre> + * <p> + * The above example tests if the grand parent node is writable. + * <p> + * And so on, you can test its ancestor recursively: + * <pre> + * <test + * args="testParent,testParent,testParent,...,isWritable" + * property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent"> + * </test> + * </pre> + */ +public class FSTreeNodePropertyTester extends PropertyTester { + + /* (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if(receiver == null) + return false; + Assert.isTrue(receiver instanceof FSTreeNode); + FSTreeNode node = (FSTreeNode) receiver; + if (property.equals("isFile")) { //$NON-NLS-1$ + return node.isFile(); + } else if (property.equals("isDirectory")) { //$NON-NLS-1$ + return node.isDirectory(); + } else if (property.equals("isBinaryFile")) { //$NON-NLS-1$ + return ContentTypeHelper.isBinaryFile(node); + } else if (property.equals("isReadable")){ //$NON-NLS-1$ + return node.isReadable(); + } else if (property.equals("isWritable")){ //$NON-NLS-1$ + return node.isWritable(); + } else if (property.equals("isExecutable")){ //$NON-NLS-1$ + return node.isExecutable(); + } else if (property.equals("isRoot")) { //$NON-NLS-1$ + return node.isRoot(); + } else if (property.equals("isSystemRoot")) { //$NON-NLS-1$ + return node.isSystemRoot(); + } else if (property.equals("isWindows")) { //$NON-NLS-1$ + return node.isWindowsNode(); + } else if (property.equals("isReadOnly")) { //$NON-NLS-1$ + return node.isReadOnly(); + } else if (property.equals("isHidden")) { //$NON-NLS-1$ + return node.isHidden(); + } else if (property.equals("testParent")) { //$NON-NLS-1$ + return testParent(node, args, expectedValue); + } else if (property.equals("getCacheState")){ //$NON-NLS-1$ + File file = CacheManager.getCacheFile(node); + if(!file.exists()) + return false; + CacheState state = node.getCacheState(); + return state.name().equals(expectedValue); + } + return false; + } + + private boolean testParent(FSTreeNode node, Object[] args, Object expectedValue) { + if(args == null || args.length == 0) + return false; + String arg = (String) args[0]; + Object[] newArgs = new Object[args.length -1]; + System.arraycopy(args, 1, newArgs, 0, args.length - 1); + return test(node.getParent(), arg, newArgs, expectedValue); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java index 3b6ca32b0..d423d43f5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.testers; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java index 613bf6f64..d12148ff4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * William Chen (Wind River)- [345387]Open the remote files with a proper editor + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.url; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java index 6f1c7e202..b432d416d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * William Chen (Wind River) - [345552] Edit the remote files with a proper editor + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.url; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java index 3d1e53126..37a0a3ef8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * William Chen (Wind River)- [345387]Open the remote files with a proper editor + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.url; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java index 2145629ed..93e60c543 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java @@ -1,216 +1,216 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.url;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-import org.osgi.service.url.AbstractURLStreamHandlerService;
-
-/**
- * The stream handler service used to parse tcf stream protocol.
- */
-public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService {
- // The pattern of a windows path.
- private static final String WINPATH_PATTERN = "[A-Za-z]:.*"; //$NON-NLS-1$
- private static final char[] WINPATH_FORBIDDEN_CHARS = {':', '*', '?', '"', '<', '>', '|' };
-
- /*
- * (non-Javadoc)
- * @see org.osgi.service.url.AbstractURLStreamHandlerService#openConnection(java.net.URL)
- */
- @Override
- public URLConnection openConnection(URL u) throws IOException {
- return new TcfURLConnection(u);
- }
-
- /**
- * Parse the given spec to the specified URL object. The expected format is:
- * <p>
- *
- * <pre>
- * TCF_URL = tcf:/<strong>PEER_ID</strong>/(<strong>URL_PATH</strong>)?
- * PEER_ID = (.^/)+
- * URL_PATH = <strong>WIN_PATH</strong> | <strong>RELATIVE_PATH</strong>
- * WIN_PATH = <strong>DISK_SEG</strong> / (<strong>RELATIVE_PATH</strong>)?
- * DISK_SEG = [a-zA-Z]:
- * RELATIVE_PATH = <strong>PATH_SEG</strong> | <strong>PATH_SEG</strong>/<strong>RELATIVE_PATH</strong>
- * Unix/Linux PATH_SEG = (.^[/])+
- * Windows PATH_SEG = (.^[\/:*?"<>|])+
- * </pre>
- */
- @Override
- protected void parseURL(URL u, String spec, int start, int limit) {
- if (u.getPath() != null) {
- String path = u.getPath();
- if (!path.endsWith("/")) { //$NON-NLS-1$
- path += "/"; //$NON-NLS-1$
- }
- path += spec;
- setURL(u, u.getProtocol(), u.getHost(), u.getPort(), u.getAuthority(), u.getUserInfo(), path, u.getQuery(), u.getRef());
- }
- else {
- IllegalArgumentException errorFormat = new IllegalArgumentException(Messages.TcfURLStreamHandlerService_ErrorURLFormat);
- int end = spec.indexOf("/", start); //$NON-NLS-1$
- if (end == -1) throw errorFormat;
- start = end + 1;
- end = spec.indexOf("/", start); //$NON-NLS-1$
- if (end == -1) throw errorFormat;
- String peerId = spec.substring(start, end);
- if (peerId.trim().length() == 0) throw errorFormat;
- start = end + 1;
- String path = spec.substring(start);
- if (path.length() > 0) {
- if (path.matches(WINPATH_PATTERN)) {
- String pathext = path.substring(2); // Cut the path after ':'.
- if (pathext.length() == 0) throw new IllegalArgumentException(Messages.TcfURLStreamHandlerService_OnlyDiskPartError);
- pathext = pathext.substring(1); // Cut the path after the disk part.
- checkWinPath(pathext);
- }
- else {
- path = "/" + path; //$NON-NLS-1$
- }
- }
- else {
- path = "/"; //$NON-NLS-1$
- }
- final String path2decode = path;
- final AtomicReference<String> pathRef = new AtomicReference<String>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }
- @Override
- public void run() throws Exception {
- pathRef.set(decodeURLPath(path2decode));
- }});
- path = pathRef.get();
- setURL(u, TcfURLConnection.PROTOCOL_SCHEMA, peerId, -1, null, null, path, null, null);
- }
- }
-
- /**
- * Decode the path from URI compatible path to a
- * file system path.
- *
- * @see FSTreeNode#getURLEncodedPath
- * @param path The URL whose path is to be decoded.
- * @return The file system path.
- * @throws UnsupportedEncodingException
- */
- String decodeURLPath(String path) throws UnsupportedEncodingException {
- StringTokenizer st = new StringTokenizer(path, "/"); //$NON-NLS-1$
- StringBuilder builder = new StringBuilder();
- while(st.hasMoreTokens()) {
- if(builder.length() > 0) {
- builder.append("/"); //$NON-NLS-1$
- }
- String segment = st.nextToken();
- builder.append(URLDecoder.decode(segment, "UTF-8")); //$NON-NLS-1$
- }
- String relative = builder.toString();
- return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /**
- * Check the format of the specified windows path.
- *
- * @param path The relative path to a disk part.
- */
- private void checkWinPath(String path) {
- for (int i = 0; i < path.length(); i++) {
- char c = path.charAt(i);
- for(int j=0;j<WINPATH_FORBIDDEN_CHARS.length;j++) {
- if(c==WINPATH_FORBIDDEN_CHARS[j]) {
- throw new IllegalArgumentException(NLS.bind(Messages.TcfURLStreamHandlerService_IllegalCharacter, "'"+c+"'")); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- }
- }
-
- /**
- * Encode the path from a file system path to
- * URI compatible path.
- *
- * @see FSTreeNode#getURLEncodedPath
- * @param path The URL whose path is to be decoded.
- * @return The file system path.
- * @throws UnsupportedEncodingException
- */
- String encodeURLPath(String path) throws UnsupportedEncodingException {
- StringTokenizer st = new StringTokenizer(path, "/"); //$NON-NLS-1$
- StringBuilder builder = new StringBuilder();
- while(st.hasMoreTokens()) {
- if(builder.length() > 0) {
- builder.append("/"); //$NON-NLS-1$
- String segment = st.nextToken();
- builder.append(URLEncoder.encode(segment, "UTF-8")); //$NON-NLS-1$
- }
- else {
- String segment = st.nextToken();
- if(path.matches(WINPATH_PATTERN)) {
- builder.append(segment);
- }
- else{
- builder.append(URLEncoder.encode(segment, "UTF-8")); //$NON-NLS-1$
- }
- }
- }
- String relative = builder.toString();
- return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.service.url.AbstractURLStreamHandlerService#toExternalForm(java.net.URL)
- */
- @Override
- public String toExternalForm(final URL u) {
- String peerId = u.getHost();
- StringBuilder builder = new StringBuilder();
- builder.append(TcfURLConnection.PROTOCOL_SCHEMA);
- builder.append(":/"); //$NON-NLS-1$
- builder.append(peerId);
- final AtomicReference<String> pathRef = new AtomicReference<String>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore
- }
- @Override
- public void run() throws Exception {
- pathRef.set(encodeURLPath(u.getPath()));
- }});
- String path = pathRef.get();
- if(path == null) {
- builder.append("/"); //$NON-NLS-1$
- } else if(path.length() == 0) {
- builder.append("/"); //$NON-NLS-1$
- } else if(path.matches(WINPATH_PATTERN)) {
- builder.append("/"); //$NON-NLS-1$
- builder.append(path);
- } else {
- builder.append(path);
- }
- return builder.toString();
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.url; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.StringTokenizer; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; +import org.osgi.service.url.AbstractURLStreamHandlerService; + +/** + * The stream handler service used to parse tcf stream protocol. + */ +public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService { + // The pattern of a windows path. + private static final String WINPATH_PATTERN = "[A-Za-z]:.*"; //$NON-NLS-1$ + private static final char[] WINPATH_FORBIDDEN_CHARS = {':', '*', '?', '"', '<', '>', '|' }; + + /* + * (non-Javadoc) + * @see org.osgi.service.url.AbstractURLStreamHandlerService#openConnection(java.net.URL) + */ + @Override + public URLConnection openConnection(URL u) throws IOException { + return new TcfURLConnection(u); + } + + /** + * Parse the given spec to the specified URL object. The expected format is: + * <p> + * + * <pre> + * TCF_URL = tcf:/<strong>PEER_ID</strong>/(<strong>URL_PATH</strong>)? + * PEER_ID = (.^/)+ + * URL_PATH = <strong>WIN_PATH</strong> | <strong>RELATIVE_PATH</strong> + * WIN_PATH = <strong>DISK_SEG</strong> / (<strong>RELATIVE_PATH</strong>)? + * DISK_SEG = [a-zA-Z]: + * RELATIVE_PATH = <strong>PATH_SEG</strong> | <strong>PATH_SEG</strong>/<strong>RELATIVE_PATH</strong> + * Unix/Linux PATH_SEG = (.^[/])+ + * Windows PATH_SEG = (.^[\/:*?"<>|])+ + * </pre> + */ + @Override + protected void parseURL(URL u, String spec, int start, int limit) { + if (u.getPath() != null) { + String path = u.getPath(); + if (!path.endsWith("/")) { //$NON-NLS-1$ + path += "/"; //$NON-NLS-1$ + } + path += spec; + setURL(u, u.getProtocol(), u.getHost(), u.getPort(), u.getAuthority(), u.getUserInfo(), path, u.getQuery(), u.getRef()); + } + else { + IllegalArgumentException errorFormat = new IllegalArgumentException(Messages.TcfURLStreamHandlerService_ErrorURLFormat); + int end = spec.indexOf("/", start); //$NON-NLS-1$ + if (end == -1) throw errorFormat; + start = end + 1; + end = spec.indexOf("/", start); //$NON-NLS-1$ + if (end == -1) throw errorFormat; + String peerId = spec.substring(start, end); + if (peerId.trim().length() == 0) throw errorFormat; + start = end + 1; + String path = spec.substring(start); + if (path.length() > 0) { + if (path.matches(WINPATH_PATTERN)) { + String pathext = path.substring(2); // Cut the path after ':'. + if (pathext.length() == 0) throw new IllegalArgumentException(Messages.TcfURLStreamHandlerService_OnlyDiskPartError); + pathext = pathext.substring(1); // Cut the path after the disk part. + checkWinPath(pathext); + } + else { + path = "/" + path; //$NON-NLS-1$ + } + } + else { + path = "/"; //$NON-NLS-1$ + } + final String path2decode = path; + final AtomicReference<String> pathRef = new AtomicReference<String>(); + SafeRunner.run(new ISafeRunnable(){ + @Override + public void handleException(Throwable exception) { + // Ignore on purpose + } + @Override + public void run() throws Exception { + pathRef.set(decodeURLPath(path2decode)); + }}); + path = pathRef.get(); + setURL(u, TcfURLConnection.PROTOCOL_SCHEMA, peerId, -1, null, null, path, null, null); + } + } + + /** + * Decode the path from URI compatible path to a + * file system path. + * + * @see FSTreeNode#getURLEncodedPath + * @param path The URL whose path is to be decoded. + * @return The file system path. + * @throws UnsupportedEncodingException + */ + String decodeURLPath(String path) throws UnsupportedEncodingException { + StringTokenizer st = new StringTokenizer(path, "/"); //$NON-NLS-1$ + StringBuilder builder = new StringBuilder(); + while(st.hasMoreTokens()) { + if(builder.length() > 0) { + builder.append("/"); //$NON-NLS-1$ + } + String segment = st.nextToken(); + builder.append(URLDecoder.decode(segment, "UTF-8")); //$NON-NLS-1$ + } + String relative = builder.toString(); + return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$ + } + + /** + * Check the format of the specified windows path. + * + * @param path The relative path to a disk part. + */ + private void checkWinPath(String path) { + for (int i = 0; i < path.length(); i++) { + char c = path.charAt(i); + for(int j=0;j<WINPATH_FORBIDDEN_CHARS.length;j++) { + if(c==WINPATH_FORBIDDEN_CHARS[j]) { + throw new IllegalArgumentException(NLS.bind(Messages.TcfURLStreamHandlerService_IllegalCharacter, "'"+c+"'")); //$NON-NLS-1$//$NON-NLS-2$ + } + } + } + } + + /** + * Encode the path from a file system path to + * URI compatible path. + * + * @see FSTreeNode#getURLEncodedPath + * @param path The URL whose path is to be decoded. + * @return The file system path. + * @throws UnsupportedEncodingException + */ + String encodeURLPath(String path) throws UnsupportedEncodingException { + StringTokenizer st = new StringTokenizer(path, "/"); //$NON-NLS-1$ + StringBuilder builder = new StringBuilder(); + while(st.hasMoreTokens()) { + if(builder.length() > 0) { + builder.append("/"); //$NON-NLS-1$ + String segment = st.nextToken(); + builder.append(URLEncoder.encode(segment, "UTF-8")); //$NON-NLS-1$ + } + else { + String segment = st.nextToken(); + if(path.matches(WINPATH_PATTERN)) { + builder.append(segment); + } + else{ + builder.append(URLEncoder.encode(segment, "UTF-8")); //$NON-NLS-1$ + } + } + } + String relative = builder.toString(); + return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$ + } + + /* + * (non-Javadoc) + * @see org.osgi.service.url.AbstractURLStreamHandlerService#toExternalForm(java.net.URL) + */ + @Override + public String toExternalForm(final URL u) { + String peerId = u.getHost(); + StringBuilder builder = new StringBuilder(); + builder.append(TcfURLConnection.PROTOCOL_SCHEMA); + builder.append(":/"); //$NON-NLS-1$ + builder.append(peerId); + final AtomicReference<String> pathRef = new AtomicReference<String>(); + SafeRunner.run(new ISafeRunnable(){ + @Override + public void handleException(Throwable exception) { + // Ignore + } + @Override + public void run() throws Exception { + pathRef.set(encodeURLPath(u.getPath())); + }}); + String path = pathRef.get(); + if(path == null) { + builder.append("/"); //$NON-NLS-1$ + } else if(path.length() == 0) { + builder.append("/"); //$NON-NLS-1$ + } else if(path.matches(WINPATH_PATTERN)) { + builder.append("/"); //$NON-NLS-1$ + builder.append(path); + } else { + builder.append(path); + } + return builder.toString(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java index 99ce3b23e..718dbe24e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java @@ -1,880 +1,880 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
-
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * A blocking call proxy for a file system service. All calls to the service method are blocked
- * until its "Done" handler is invoked.
- * <p>
- * <em>Note that all method call over the proxy must be made <b>OUTSIDE</b> of
- * the dispatching thread.</em> If it is called inside of the dispatching thread, the call will be
- * blocked forever.
- * <p>
- * This class is used to replace BlockingProxyCall for better debugability.
- *
- * @see BlockingCallProxy
- */
-public class BlockingFileSystemProxy implements IFileSystem {
- // The default timeout waiting for blocked invocations.
- private static final long DEFAULT_TIMEOUT = Operation.DEFAULT_TIMEOUT;
- // The actual object that provides file system services.
- IFileSystem service;
-
- /**
- * Constructor with an delegating service.
- *
- * @param service The delegating service.
- */
- public BlockingFileSystemProxy(IFileSystem service) {
- Assert.isNotNull(service);
- this.service = service;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.protocol.IService#getName()
- */
- @Override
- public String getName() {
- return service.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#open(java.lang.String, int, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneOpen)
- */
- @Override
- public IToken open(final String file_name, final int flags, final FileAttrs attrs, final DoneOpen done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.open(file_name, flags, attrs, new DoneOpen() {
- @Override
- public void doneOpen(final IToken token, final FileSystemException error, final IFileHandle handle) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneOpen(token, error, handle);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningFile, file_name));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#close(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneClose)
- */
- @Override
- public IToken close(final IFileHandle handle, final DoneClose done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.close(handle, new DoneClose() {
- @Override
- public void doneClose(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneClose(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutClosingFile, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#read(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, int, org.eclipse.tcf.services.IFileSystem.DoneRead)
- */
- @Override
- public IToken read(final IFileHandle handle, final long offset, final int len, final DoneRead done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.read(handle, offset, len, new DoneRead() {
- @Override
- public void doneRead(final IToken token, final FileSystemException error, final byte[] data, final boolean eof) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRead(token, error, data, eof);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingFile, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#write(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, byte[], int, int, org.eclipse.tcf.services.IFileSystem.DoneWrite)
- */
- @Override
- public IToken write(final IFileHandle handle, final long offset, final byte[] data, final int data_pos, final int data_size, final DoneWrite done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.write(handle, offset, data, data_pos, data_size, new DoneWrite() {
- @Override
- public void doneWrite(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneWrite(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutWritingFile, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#stat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat)
- */
- @Override
- public IToken stat(final String path, final DoneStat done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.stat(path, new DoneStat() {
- @Override
- public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneStat(token, error, attrs);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutStat, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#lstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat)
- */
- @Override
- public IToken lstat(final String path, final DoneStat done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.lstat(path, new DoneStat() {
- @Override
- public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneStat(token, error, attrs);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutLstat, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#fstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneStat)
- */
- @Override
- public IToken fstat(final IFileHandle handle, final DoneStat done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.fstat(handle, new DoneStat() {
- @Override
- public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneStat(token, error, attrs);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFstat, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#setstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat)
- */
- @Override
- public IToken setstat(final String path, final FileAttrs attrs, final DoneSetStat done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.setstat(path, attrs, new DoneSetStat() {
- @Override
- public void doneSetStat(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneSetStat(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSetStat, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#fsetstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat)
- */
- @Override
- public IToken fsetstat(final IFileHandle handle, final FileAttrs attrs, final DoneSetStat done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.fsetstat(handle, attrs, new DoneSetStat() {
- @Override
- public void doneSetStat(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneSetStat(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFSetStat, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#opendir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneOpen)
- */
- @Override
- public IToken opendir(final String path, final DoneOpen done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.opendir(path, new DoneOpen() {
- @Override
- public void doneOpen(final IToken token, final FileSystemException error, final IFileHandle handle) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneOpen(token, error, handle);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningDir, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#readdir(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneReadDir)
- */
- @Override
- public IToken readdir(final IFileHandle handle, final DoneReadDir done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.readdir(handle, new DoneReadDir() {
- @Override
- public void doneReadDir(final IToken token, final FileSystemException error, final DirEntry[] entries, final boolean eof) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneReadDir(token, error, entries, eof);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingDir, handle));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#mkdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneMkDir)
- */
- @Override
- public IToken mkdir(final String path, final FileAttrs attrs, final DoneMkDir done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.mkdir(path, attrs, new DoneMkDir() {
- @Override
- public void doneMkDir(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneMkDir(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutMakingDir, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#rmdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove)
- */
- @Override
- public IToken rmdir(final String path, final DoneRemove done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.rmdir(path, new DoneRemove() {
- @Override
- public void doneRemove(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRemove(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingDir, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#roots(org.eclipse.tcf.services.IFileSystem.DoneRoots)
- */
- @Override
- public IToken roots(final DoneRoots done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.roots(new DoneRoots() {
- @Override
- public void doneRoots(final IToken token, final FileSystemException error, final DirEntry[] entries) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRoots(token, error, entries);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutListingRoots);
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#remove(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove)
- */
- @Override
- public IToken remove(final String file_name, final DoneRemove done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.remove(file_name, new DoneRemove() {
- @Override
- public void doneRemove(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRemove(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingFile, file_name));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#realpath(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRealPath)
- */
- @Override
- public IToken realpath(final String path, final DoneRealPath done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.realpath(path, new DoneRealPath() {
- @Override
- public void doneRealPath(final IToken token, final FileSystemException error, final String path) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRealPath(token, error, path);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutGettingRealPath, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#rename(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRename)
- */
- @Override
- public IToken rename(final String old_path, final String new_path, final DoneRename done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.rename(old_path, new_path, new DoneRename() {
- @Override
- public void doneRename(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneRename(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRenamingFile, old_path, new_path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#readlink(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneReadLink)
- */
- @Override
- public IToken readlink(final String path, final DoneReadLink done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.readlink(path, new DoneReadLink() {
- @Override
- public void doneReadLink(final IToken token, final FileSystemException error, final String path) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneReadLink(token, error, path);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingLink, path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#symlink(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneSymLink)
- */
- @Override
- public IToken symlink(final String link_path, final String target_path, final DoneSymLink done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.symlink(link_path, target_path, new DoneSymLink() {
- @Override
- public void doneSymLink(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneSymLink(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSymLink, link_path, target_path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#copy(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.tcf.services.IFileSystem.DoneCopy)
- */
- @Override
- public IToken copy(final String src_path, final String dst_path, final boolean copy_permissions, final boolean copy_ownership, final DoneCopy done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.copy(src_path, dst_path, copy_permissions, copy_ownership, new DoneCopy() {
- @Override
- public void doneCopy(final IToken token, final FileSystemException error) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneCopy(token, error);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutCopying, src_path, dst_path));
- }
- return ref.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem#user(org.eclipse.tcf.services.IFileSystem.DoneUser)
- */
- @Override
- public IToken user(final DoneUser done) {
- Assert.isTrue(!Protocol.isDispatchThread());
- final Rendezvous rendezvous = new Rendezvous();
- final AtomicReference<IToken> ref = new AtomicReference<IToken>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- IToken token = service.user(new DoneUser() {
- @Override
- public void doneUser(final IToken token, final FileSystemException error, final int real_uid, final int effective_uid, final int real_gid, final int effective_gid, final String home) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable exception) {
- }
-
- @Override
- public void run() throws Exception {
- done.doneUser(token, error, real_uid, effective_uid, real_gid, effective_gid, home);
- }
- });
- rendezvous.arrive();
- }
- });
- ref.set(token);
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch (TimeoutException e) {
- throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutGettingUser);
- }
- return ref.get();
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; + +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * A blocking call proxy for a file system service. All calls to the service method are blocked + * until its "Done" handler is invoked. + * <p> + * <em>Note that all method call over the proxy must be made <b>OUTSIDE</b> of + * the dispatching thread.</em> If it is called inside of the dispatching thread, the call will be + * blocked forever. + * <p> + * This class is used to replace BlockingProxyCall for better debugability. + * + * @see BlockingCallProxy + */ +public class BlockingFileSystemProxy implements IFileSystem { + // The default timeout waiting for blocked invocations. + private static final long DEFAULT_TIMEOUT = Operation.DEFAULT_TIMEOUT; + // The actual object that provides file system services. + IFileSystem service; + + /** + * Constructor with an delegating service. + * + * @param service The delegating service. + */ + public BlockingFileSystemProxy(IFileSystem service) { + Assert.isNotNull(service); + this.service = service; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.protocol.IService#getName() + */ + @Override + public String getName() { + return service.getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#open(java.lang.String, int, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneOpen) + */ + @Override + public IToken open(final String file_name, final int flags, final FileAttrs attrs, final DoneOpen done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.open(file_name, flags, attrs, new DoneOpen() { + @Override + public void doneOpen(final IToken token, final FileSystemException error, final IFileHandle handle) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneOpen(token, error, handle); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningFile, file_name)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#close(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneClose) + */ + @Override + public IToken close(final IFileHandle handle, final DoneClose done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.close(handle, new DoneClose() { + @Override + public void doneClose(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneClose(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutClosingFile, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#read(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, int, org.eclipse.tcf.services.IFileSystem.DoneRead) + */ + @Override + public IToken read(final IFileHandle handle, final long offset, final int len, final DoneRead done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.read(handle, offset, len, new DoneRead() { + @Override + public void doneRead(final IToken token, final FileSystemException error, final byte[] data, final boolean eof) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRead(token, error, data, eof); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingFile, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#write(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, byte[], int, int, org.eclipse.tcf.services.IFileSystem.DoneWrite) + */ + @Override + public IToken write(final IFileHandle handle, final long offset, final byte[] data, final int data_pos, final int data_size, final DoneWrite done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.write(handle, offset, data, data_pos, data_size, new DoneWrite() { + @Override + public void doneWrite(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneWrite(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutWritingFile, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#stat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat) + */ + @Override + public IToken stat(final String path, final DoneStat done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.stat(path, new DoneStat() { + @Override + public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneStat(token, error, attrs); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutStat, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#lstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat) + */ + @Override + public IToken lstat(final String path, final DoneStat done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.lstat(path, new DoneStat() { + @Override + public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneStat(token, error, attrs); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutLstat, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#fstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneStat) + */ + @Override + public IToken fstat(final IFileHandle handle, final DoneStat done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.fstat(handle, new DoneStat() { + @Override + public void doneStat(final IToken token, final FileSystemException error, final FileAttrs attrs) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneStat(token, error, attrs); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFstat, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#setstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat) + */ + @Override + public IToken setstat(final String path, final FileAttrs attrs, final DoneSetStat done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.setstat(path, attrs, new DoneSetStat() { + @Override + public void doneSetStat(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneSetStat(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSetStat, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#fsetstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat) + */ + @Override + public IToken fsetstat(final IFileHandle handle, final FileAttrs attrs, final DoneSetStat done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.fsetstat(handle, attrs, new DoneSetStat() { + @Override + public void doneSetStat(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneSetStat(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFSetStat, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#opendir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneOpen) + */ + @Override + public IToken opendir(final String path, final DoneOpen done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.opendir(path, new DoneOpen() { + @Override + public void doneOpen(final IToken token, final FileSystemException error, final IFileHandle handle) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneOpen(token, error, handle); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningDir, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#readdir(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneReadDir) + */ + @Override + public IToken readdir(final IFileHandle handle, final DoneReadDir done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.readdir(handle, new DoneReadDir() { + @Override + public void doneReadDir(final IToken token, final FileSystemException error, final DirEntry[] entries, final boolean eof) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneReadDir(token, error, entries, eof); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingDir, handle)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#mkdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneMkDir) + */ + @Override + public IToken mkdir(final String path, final FileAttrs attrs, final DoneMkDir done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.mkdir(path, attrs, new DoneMkDir() { + @Override + public void doneMkDir(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneMkDir(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutMakingDir, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#rmdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove) + */ + @Override + public IToken rmdir(final String path, final DoneRemove done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.rmdir(path, new DoneRemove() { + @Override + public void doneRemove(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRemove(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingDir, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#roots(org.eclipse.tcf.services.IFileSystem.DoneRoots) + */ + @Override + public IToken roots(final DoneRoots done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.roots(new DoneRoots() { + @Override + public void doneRoots(final IToken token, final FileSystemException error, final DirEntry[] entries) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRoots(token, error, entries); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutListingRoots); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#remove(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove) + */ + @Override + public IToken remove(final String file_name, final DoneRemove done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.remove(file_name, new DoneRemove() { + @Override + public void doneRemove(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRemove(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingFile, file_name)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#realpath(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRealPath) + */ + @Override + public IToken realpath(final String path, final DoneRealPath done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.realpath(path, new DoneRealPath() { + @Override + public void doneRealPath(final IToken token, final FileSystemException error, final String path) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRealPath(token, error, path); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutGettingRealPath, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#rename(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRename) + */ + @Override + public IToken rename(final String old_path, final String new_path, final DoneRename done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.rename(old_path, new_path, new DoneRename() { + @Override + public void doneRename(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneRename(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRenamingFile, old_path, new_path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#readlink(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneReadLink) + */ + @Override + public IToken readlink(final String path, final DoneReadLink done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.readlink(path, new DoneReadLink() { + @Override + public void doneReadLink(final IToken token, final FileSystemException error, final String path) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneReadLink(token, error, path); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingLink, path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#symlink(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneSymLink) + */ + @Override + public IToken symlink(final String link_path, final String target_path, final DoneSymLink done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.symlink(link_path, target_path, new DoneSymLink() { + @Override + public void doneSymLink(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneSymLink(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSymLink, link_path, target_path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#copy(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.tcf.services.IFileSystem.DoneCopy) + */ + @Override + public IToken copy(final String src_path, final String dst_path, final boolean copy_permissions, final boolean copy_ownership, final DoneCopy done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.copy(src_path, dst_path, copy_permissions, copy_ownership, new DoneCopy() { + @Override + public void doneCopy(final IToken token, final FileSystemException error) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneCopy(token, error); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutCopying, src_path, dst_path)); + } + return ref.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.services.IFileSystem#user(org.eclipse.tcf.services.IFileSystem.DoneUser) + */ + @Override + public IToken user(final DoneUser done) { + Assert.isTrue(!Protocol.isDispatchThread()); + final Rendezvous rendezvous = new Rendezvous(); + final AtomicReference<IToken> ref = new AtomicReference<IToken>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IToken token = service.user(new DoneUser() { + @Override + public void doneUser(final IToken token, final FileSystemException error, final int real_uid, final int effective_uid, final int real_gid, final int effective_gid, final String home) { + SafeRunner.run(new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + } + + @Override + public void run() throws Exception { + done.doneUser(token, error, real_uid, effective_uid, real_gid, effective_gid, home); + } + }); + rendezvous.arrive(); + } + }); + ref.set(token); + } + }); + try { + rendezvous.waiting(DEFAULT_TIMEOUT); + } + catch (TimeoutException e) { + throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutGettingUser); + } + return ref.get(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java index c5749959f..e4c85ab72 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation - * William Chen (Wind River)- [345387] Open the remote files with a proper editor - * William Chen (Wind River)- [345552] Edit the remote files with a proper editor + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java index e4f1a3eb6..8991f9e0d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java @@ -1,120 +1,118 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * William Chen (Wind River)- [345387]Open the remote files with a proper editor
- * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
- * up menu of file system nodes of Target Explorer.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The content type helper used to provide helping methods about the content
- * types of the files in the remote file system.
- */
-public class ContentTypeHelper {
- // The binary content type's id.
- private static final String CONTENT_TYPE_BINARY_ID = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$
-
- /**
- * Judges if the node is a binary file.
- *
- * @param node
- * The file node.
- * @return true if the node is a binary file or else false.
- */
- public static boolean isBinaryFile(FSTreeNode node) {
- IContentType contentType = getContentType(node);
- if (contentType != null) {
- IContentType binaryFile = Platform.getContentTypeManager()
- .getContentType(CONTENT_TYPE_BINARY_ID);
- if (binaryFile != null && contentType.isKindOf(binaryFile))
- return true;
- }
- return false;
- }
-
- /**
- * Get the content type of the specified file node.
- *
- * @param node
- * The file node.
- * @return The content type of the file node.
- */
- public static IContentType getContentType(FSTreeNode node) {
- if (PersistenceManager.getInstance().isUnresovled(node))
- // If it is already known unresolvable.
- return null;
- IContentType contentType = PersistenceManager.getInstance().getResolved(node);
- if (contentType != null)
- // If it is already known to have a certain content type.
- return contentType;
- // First check the content type by its name.
- contentType = Platform.getContentTypeManager().findContentTypeFor(
- node.name);
- if (contentType == null) { // Then find the content type by its stream.
- try {
- contentType = findContentTypeByStream(node);
- } catch (Exception e) {
- }
- }
- if (contentType != null) { // If it is resolved, cache it.
- PersistenceManager.getInstance().addResovled(node, contentType);
- } else { // Or else, remember it as an unresolvable.
- PersistenceManager.getInstance().addUnresolved(node);
- }
- return contentType;
- }
-
- /**
- * Find the content type of the file using its content stream.
- *
- * @param node
- * The file node.
- * @return The content type of the file.
- * @throws CoreException
- * If the path of its local cache file couldn't be found.
- * @throws IOException
- * If something goes wrong during the content type parsing.
- */
- private static IContentType findContentTypeByStream(FSTreeNode node) throws CoreException, IOException {
- InputStream is = null;
- try {
- File file = CacheManager.getCacheFile(node);
- if (file.exists()) {
- // If the local cache file exits.
- IPath path = CacheManager.getCachePath(node);
- IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);
- is = fileStore.openInputStream(EFS.NONE, null);
- } else {
- // Use its URL stream.
- URL url = node.getLocationURL();
- is = url.openStream();
- }
- return Platform.getContentTypeManager().findContentTypeFor(is, node.name);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The content type helper used to provide helping methods about the content + * types of the files in the remote file system. + */ +public class ContentTypeHelper { + // The binary content type's id. + private static final String CONTENT_TYPE_BINARY_ID = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ + + /** + * Judges if the node is a binary file. + * + * @param node + * The file node. + * @return true if the node is a binary file or else false. + */ + public static boolean isBinaryFile(FSTreeNode node) { + IContentType contentType = getContentType(node); + if (contentType != null) { + IContentType binaryFile = Platform.getContentTypeManager() + .getContentType(CONTENT_TYPE_BINARY_ID); + if (binaryFile != null && contentType.isKindOf(binaryFile)) + return true; + } + return false; + } + + /** + * Get the content type of the specified file node. + * + * @param node + * The file node. + * @return The content type of the file node. + */ + public static IContentType getContentType(FSTreeNode node) { + if (PersistenceManager.getInstance().isUnresovled(node)) + // If it is already known unresolvable. + return null; + IContentType contentType = PersistenceManager.getInstance().getResolved(node); + if (contentType != null) + // If it is already known to have a certain content type. + return contentType; + // First check the content type by its name. + contentType = Platform.getContentTypeManager().findContentTypeFor( + node.name); + if (contentType == null) { // Then find the content type by its stream. + try { + contentType = findContentTypeByStream(node); + } catch (Exception e) { + } + } + if (contentType != null) { // If it is resolved, cache it. + PersistenceManager.getInstance().addResovled(node, contentType); + } else { // Or else, remember it as an unresolvable. + PersistenceManager.getInstance().addUnresolved(node); + } + return contentType; + } + + /** + * Find the content type of the file using its content stream. + * + * @param node + * The file node. + * @return The content type of the file. + * @throws CoreException + * If the path of its local cache file couldn't be found. + * @throws IOException + * If something goes wrong during the content type parsing. + */ + private static IContentType findContentTypeByStream(FSTreeNode node) throws CoreException, IOException { + InputStream is = null; + try { + File file = CacheManager.getCacheFile(node); + if (file.exists()) { + // If the local cache file exits. + IPath path = CacheManager.getCachePath(node); + IFileStore fileStore = EFS.getLocalFileSystem().getStore(path); + is = fileStore.openInputStream(EFS.NONE, null); + } else { + // Use its URL stream. + URL url = node.getLocationURL(); + is = url.openStream(); + } + return Platform.getContentTypeManager().findContentTypeFor(is, node.name); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java index ac2a56976..9b6bb4dcb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java @@ -1,257 +1,257 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
-
-import java.beans.PropertyChangeEvent;
-import java.io.File;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCacheFileDigest;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The state object to describe a file's state.
- */
-public class FileState {
- /**
- * The base digest of the file data.
- */
- private byte[] base_digest = null;
-
- /**
- * The message digest of the file data.
- */
- private byte[] target_digest = null;
-
- /**
- * The message digest of the local cache data
- */
- private byte[] cache_digest = null;
-
- /**
- * The cache file's modification time.
- */
- private long cache_mtime;
-
- /**
- * If the job that computes the local cache's digest is running.
- */
- transient boolean cache_digest_running = false;
-
- /**
- * If the job that computes the target file's digest is running.
- */
- transient boolean target_digest_running = false;
-
- /**
- * The file system node whose state is described.
- */
- private transient FSTreeNode node;
-
- /**
- * Create a file state using the node.
- *
- * @param node The file system node.
- */
- public FileState(FSTreeNode node) {
- this.node = node;
- }
-
- /**
- * Create a file state using the specified state data.
- *
- * @param mtime The cache file's modification time.
- * @param cache_digest The cache file's digest.
- * @param target_digest The target file's digest.
- * @param base_digest The baseline digest.
- */
- public FileState(long mtime, byte[] cache_digest, byte[] target_digest, byte[]base_digest) {
- this.cache_mtime = mtime;
- this.cache_digest = cache_digest;
- this.target_digest = target_digest;
- this.base_digest = base_digest;
- }
-
- /**
- * Set the file system node.
- *
- * @param node The file system node.
- */
- void setNode(FSTreeNode node) {
- this.node = node;
- }
-
- /**
- * Get the node's target file digest.
- *
- * @return The target file digest.
- */
- public byte[] getTargetDigest() {
- return target_digest;
- }
-
- /**
- * Get the node's baseline digest.
- *
- * @return The baseline digest.
- */
- public byte[] getBaseDigest() {
- return base_digest;
- }
-
- /**
- * Get the node's cache file modification time.
- *
- * @return The cache file's modification time.
- */
- public long getCacheMTime() {
- return cache_mtime;
- }
-
- /**
- * Get the node's cache file digest.
- *
- * @return The cache file digest.
- */
- public byte[] getCacheDigest() {
- return cache_digest;
- }
-
- /**
- * Update the cache state of this file and invoke callback once the update is done.
- * If the callback is null, then do not invoke any callback.
- *
- * @param callback Callback invoked after updating.
- */
- public synchronized void updateState(final ICallback callback) {
- File file = CacheManager.getCacheFile(node);
- if (file.exists()) {
- long cache_mtime = file.lastModified();
- if (!cache_digest_running && (cache_digest == null || this.cache_mtime != cache_mtime)) {
- cache_digest_running = true;
- this.cache_mtime = cache_mtime;
- final OpCacheFileDigest op = new OpCacheFileDigest(node);
- new JobExecutor(new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- if (status.isOK()) {
- updateCacheDigest(op.getDigest());
- }
- cache_digest_running = false;
- if (status.isOK()) {
- updateState(callback);
- }
- else if(callback != null){
- callback.done(this, status);
- }
- }
- }).execute(op);
- }
- else if (!target_digest_running && target_digest == null) {
- target_digest_running = true;
- node.refresh(new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- target_digest_running = false;
- if (status.isOK()) {
- updateState(callback);
- }
- else if(callback != null){
- callback.done(this, status);
- }
- }
- });
- }
- else if (callback != null) callback.done(this, Status.OK_STATUS);
- }
- else if (callback != null) callback.done(this, Status.OK_STATUS);
- }
-
- /**
- * Get this node's cache state using the current state data.
- *
- * @return The state expressed in a CacheState enum value.
- */
- public synchronized CacheState getCacheState() {
- File file = CacheManager.getCacheFile(node);
- if (!file.exists()) return CacheState.consistent;
- updateState(null);
- if (cache_digest == null || target_digest == null) return CacheState.consistent;
- if(isUnchanged(target_digest, cache_digest)) {
- base_digest = target_digest;
- return CacheState.consistent;
- }
- if(isUnchanged(base_digest, cache_digest)){
- return CacheState.outdated;
- }
- if (isUnchanged(target_digest, base_digest)) {
- return CacheState.modified;
- }
- return CacheState.conflict;
- }
-
- /**
- * Update the node's target digest and fire an event.
- *
- * @param target_digest The new target digest data.
- */
- public void updateTargetDigest(byte[] target_digest) {
- this.target_digest = target_digest;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "target_digest", null, target_digest); //$NON-NLS-1$
- node.firePropertyChange(event);
- }
-
- /**
- * Compare the two digests to see if they are equal to each other.
- *
- * @param digest1 The first digest.
- * @param digest2 The second digest.
- * @return true if they are equal.
- */
- private boolean isUnchanged(byte[] digest1, byte[] digest2){
- if(digest1 != null && digest2 != null && digest1.length == digest2.length) {
- for (int i = 0; i < digest1.length; i++) {
- if(digest1[i] != digest2[i]) return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * Update the cache file digest data and fire an event.
- *
- * @param cache_digest The new cache file digest data.
- */
- public void updateCacheDigest(byte[] cache_digest) {
- byte[] old_digest = cache_digest;
- this.cache_digest = cache_digest;
- PropertyChangeEvent event = new PropertyChangeEvent(node, "cache_digest", old_digest, cache_digest); //$NON-NLS-1$
- node.firePropertyChange(event);
- }
-
- /**
- * Reset all of the node's digest data to a new digest data.
- *
- * @param digest The new digest data.
- */
- public void reset(byte[] digest) {
- cache_digest = digest;
- target_digest = digest;
- base_digest = digest;
- PropertyChangeEvent event = new PropertyChangeEvent(node, "reset_digest", null, digest); //$NON-NLS-1$
- node.firePropertyChange(event);
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; + +import java.beans.PropertyChangeEvent; +import java.io.File; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.runtime.callback.Callback; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCacheFileDigest; +import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * The state object to describe a file's state. + */ +public class FileState { + /** + * The base digest of the file data. + */ + private byte[] base_digest = null; + + /** + * The message digest of the file data. + */ + private byte[] target_digest = null; + + /** + * The message digest of the local cache data + */ + private byte[] cache_digest = null; + + /** + * The cache file's modification time. + */ + private long cache_mtime; + + /** + * If the job that computes the local cache's digest is running. + */ + transient boolean cache_digest_running = false; + + /** + * If the job that computes the target file's digest is running. + */ + transient boolean target_digest_running = false; + + /** + * The file system node whose state is described. + */ + private transient FSTreeNode node; + + /** + * Create a file state using the node. + * + * @param node The file system node. + */ + public FileState(FSTreeNode node) { + this.node = node; + } + + /** + * Create a file state using the specified state data. + * + * @param mtime The cache file's modification time. + * @param cache_digest The cache file's digest. + * @param target_digest The target file's digest. + * @param base_digest The baseline digest. + */ + public FileState(long mtime, byte[] cache_digest, byte[] target_digest, byte[]base_digest) { + this.cache_mtime = mtime; + this.cache_digest = cache_digest; + this.target_digest = target_digest; + this.base_digest = base_digest; + } + + /** + * Set the file system node. + * + * @param node The file system node. + */ + void setNode(FSTreeNode node) { + this.node = node; + } + + /** + * Get the node's target file digest. + * + * @return The target file digest. + */ + public byte[] getTargetDigest() { + return target_digest; + } + + /** + * Get the node's baseline digest. + * + * @return The baseline digest. + */ + public byte[] getBaseDigest() { + return base_digest; + } + + /** + * Get the node's cache file modification time. + * + * @return The cache file's modification time. + */ + public long getCacheMTime() { + return cache_mtime; + } + + /** + * Get the node's cache file digest. + * + * @return The cache file digest. + */ + public byte[] getCacheDigest() { + return cache_digest; + } + + /** + * Update the cache state of this file and invoke callback once the update is done. + * If the callback is null, then do not invoke any callback. + * + * @param callback Callback invoked after updating. + */ + public synchronized void updateState(final ICallback callback) { + File file = CacheManager.getCacheFile(node); + if (file.exists()) { + long cache_mtime = file.lastModified(); + if (!cache_digest_running && (cache_digest == null || this.cache_mtime != cache_mtime)) { + cache_digest_running = true; + this.cache_mtime = cache_mtime; + final OpCacheFileDigest op = new OpCacheFileDigest(node); + new JobExecutor(new Callback() { + @Override + protected void internalDone(Object caller, IStatus status) { + if (status.isOK()) { + updateCacheDigest(op.getDigest()); + } + cache_digest_running = false; + if (status.isOK()) { + updateState(callback); + } + else if(callback != null){ + callback.done(this, status); + } + } + }).execute(op); + } + else if (!target_digest_running && target_digest == null) { + target_digest_running = true; + node.refresh(new Callback(){ + @Override + protected void internalDone(Object caller, IStatus status) { + target_digest_running = false; + if (status.isOK()) { + updateState(callback); + } + else if(callback != null){ + callback.done(this, status); + } + } + }); + } + else if (callback != null) callback.done(this, Status.OK_STATUS); + } + else if (callback != null) callback.done(this, Status.OK_STATUS); + } + + /** + * Get this node's cache state using the current state data. + * + * @return The state expressed in a CacheState enum value. + */ + public synchronized CacheState getCacheState() { + File file = CacheManager.getCacheFile(node); + if (!file.exists()) return CacheState.consistent; + updateState(null); + if (cache_digest == null || target_digest == null) return CacheState.consistent; + if(isUnchanged(target_digest, cache_digest)) { + base_digest = target_digest; + return CacheState.consistent; + } + if(isUnchanged(base_digest, cache_digest)){ + return CacheState.outdated; + } + if (isUnchanged(target_digest, base_digest)) { + return CacheState.modified; + } + return CacheState.conflict; + } + + /** + * Update the node's target digest and fire an event. + * + * @param target_digest The new target digest data. + */ + public void updateTargetDigest(byte[] target_digest) { + this.target_digest = target_digest; + PropertyChangeEvent event = new PropertyChangeEvent(this, "target_digest", null, target_digest); //$NON-NLS-1$ + node.firePropertyChange(event); + } + + /** + * Compare the two digests to see if they are equal to each other. + * + * @param digest1 The first digest. + * @param digest2 The second digest. + * @return true if they are equal. + */ + private boolean isUnchanged(byte[] digest1, byte[] digest2){ + if(digest1 != null && digest2 != null && digest1.length == digest2.length) { + for (int i = 0; i < digest1.length; i++) { + if(digest1[i] != digest2[i]) return false; + } + return true; + } + return false; + } + + /** + * Update the cache file digest data and fire an event. + * + * @param cache_digest The new cache file digest data. + */ + public void updateCacheDigest(byte[] cache_digest) { + byte[] old_digest = cache_digest; + this.cache_digest = cache_digest; + PropertyChangeEvent event = new PropertyChangeEvent(node, "cache_digest", old_digest, cache_digest); //$NON-NLS-1$ + node.firePropertyChange(event); + } + + /** + * Reset all of the node's digest data to a new digest data. + * + * @param digest The new digest data. + */ + public void reset(byte[] digest) { + cache_digest = digest; + target_digest = digest; + base_digest = digest; + PropertyChangeEvent event = new PropertyChangeEvent(node, "reset_digest", null, digest); //$NON-NLS-1$ + node.firePropertyChange(event); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java index cf92a09c4..4564fe049 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java @@ -1,203 +1,202 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
- * up menu of file system nodes of Target Explorer.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * A facility class to load and save persistent data such including resolved content types, file's
- * properties, and time stamps etc.
- */
-public class PersistenceManager {
- // The singleton instance.
- private static volatile PersistenceManager instance;
-
- // The time stamp for each file.
- Map<URI, FileState> digests;
-
- // Already known resolved content type of file nodes specified by their URIs.
- Map<URI, IContentType> resolved;
-
- // Already known unresolvable file nodes specified by their URIs.
- Map<URI, URI> unresolved;
-
- // The persistent properties of the files.
- Map<URI, Map<QualifiedName, String>> properties;
-
- // The file used to store persistent properties of each file.
- private static final String PERSISTENT_FILE = "persistent.ini"; //$NON-NLS-1$
-
- /**
- * Get the singleton cache manager.
- *
- * @return The singleton cache manager.
- */
- public static PersistenceManager getInstance() {
- if (instance == null) {
- instance = new PersistenceManager();
- }
- return instance;
- }
-
- /**
- * Create a Persistent Manager instance.
- */
- private PersistenceManager() {
- digests = new HashMap<URI, FileState>();
- resolved = new HashMap<URI, IContentType>();
- unresolved = new HashMap<URI, URI>();
- properties = new HashMap<URI, Map<QualifiedName, String>>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }
- @Override
- public void run() throws Exception {
- IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- File location = CacheManager.getCacheRoot();
- File persistentFile = new File(location, PERSISTENT_FILE);
- if (persistentFile.exists()) {
- service.read(PersistenceManager.this, persistentFile.getAbsoluteFile().toURI());
- }
- }});
- }
-
- /**
- * If the node is already considered unresolvable.
- *
- * @param node The file node.
- * @return true if it is not resolvable or else false.
- */
- public boolean isUnresovled(FSTreeNode node) {
- return unresolved.get(node.getLocationURI()) != null;
- }
-
- /**
- * Get the resolved content type of the node.
- *
- * @param node The file node.
- * @return the content type of the node if it is resolvable or null.
- */
- public IContentType getResolved(FSTreeNode node) {
- return resolved.get(node.getLocationURI());
- }
-
- /**
- * Add the node and its content type to the resolved list.
- *
- * @param node The file node.
- * @param contentType Its content type.
- */
- public void addResovled(FSTreeNode node, IContentType contentType) {
- resolved.put(node.getLocationURI(), contentType);
- }
-
- /**
- * Add the node as an unresolvable node.
- *
- * @param node The file node.
- */
- public void addUnresolved(FSTreeNode node) {
- unresolved.put(node.getLocationURI(), node.getLocationURI());
- }
-
- /**
- * Set the time stamp of the FSTreeNode with the specified location.
- *
- * @param uri The FSTreeNode's location URI.
- * @param digest The new base time stamp to be set.
- */
- public void setFileDigest(URI uri, FileState digest) {
- digests.put(uri, digest);
- }
-
- /**
- * Remove the time stamp entry with the specified URI.
- *
- * @param uri The URI key.
- */
- public void removeFileDigest(URI uri) {
- digests.remove(uri);
- }
-
- /**
- * Get the time stamp of the FSTreeNode with the specified location.
- *
- * @param uri The FSTreeNode's location URI.
- * @return The FSTreeNode's base time stamp.
- */
- public FileState getFileDigest(FSTreeNode node) {
- URI uri = node.getLocationURI();
- FileState digest = digests.get(uri);
- if(digest == null) {
- digest = new FileState(node);
- digests.put(uri, digest);
- }
- digest.setNode(node);
- return digest;
- }
-
- /**
- * Get the file properties of the specified node from the properties map.
- *
- * @param node The file node.
- * @return The file properties object or empty properties object if it does not exist.
- */
- public Map<QualifiedName, String> getPersistentProperties(FSTreeNode node) {
- Map<QualifiedName, String> nodeProperties = properties.get(node.getLocationURI());
- if (nodeProperties == null) {
- nodeProperties = Collections.synchronizedMap(new HashMap<QualifiedName, String>());
- properties.put(node.getLocationURI(), nodeProperties);
- }
- return nodeProperties;
- }
-
- /**
- * Dispose the cache manager so that it has a chance to save the digests and the persistent
- * properties.
- */
- public void dispose() {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose.
- }
- @Override
- public void run() throws Exception {
- IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- File location = CacheManager.getCacheRoot();
- File persistentFile = new File(location, PERSISTENT_FILE);
- service.write(PersistenceManager.this, persistentFile.getAbsoluteFile().toURI());
- }});
- }
-
- /**
- * Returns if or if not the persistence manager needs to be disposed.
- *
- * @return <code>True</code> if the persistence manager needs disposal, <code>false</code> otherwise.
- */
- public final static boolean needsDisposal() {
- return instance != null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; + +import java.io.File; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; + +/** + * A facility class to load and save persistent data such including resolved content types, file's + * properties, and time stamps etc. + */ +public class PersistenceManager { + // The singleton instance. + private static volatile PersistenceManager instance; + + // The time stamp for each file. + Map<URI, FileState> digests; + + // Already known resolved content type of file nodes specified by their URIs. + Map<URI, IContentType> resolved; + + // Already known unresolvable file nodes specified by their URIs. + Map<URI, URI> unresolved; + + // The persistent properties of the files. + Map<URI, Map<QualifiedName, String>> properties; + + // The file used to store persistent properties of each file. + private static final String PERSISTENT_FILE = "persistent.ini"; //$NON-NLS-1$ + + /** + * Get the singleton cache manager. + * + * @return The singleton cache manager. + */ + public static PersistenceManager getInstance() { + if (instance == null) { + instance = new PersistenceManager(); + } + return instance; + } + + /** + * Create a Persistent Manager instance. + */ + private PersistenceManager() { + digests = new HashMap<URI, FileState>(); + resolved = new HashMap<URI, IContentType>(); + unresolved = new HashMap<URI, URI>(); + properties = new HashMap<URI, Map<QualifiedName, String>>(); + SafeRunner.run(new ISafeRunnable(){ + @Override + public void handleException(Throwable exception) { + // Ignore on purpose + } + @Override + public void run() throws Exception { + IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class); + File location = CacheManager.getCacheRoot(); + File persistentFile = new File(location, PERSISTENT_FILE); + if (persistentFile.exists()) { + service.read(PersistenceManager.this, persistentFile.getAbsoluteFile().toURI()); + } + }}); + } + + /** + * If the node is already considered unresolvable. + * + * @param node The file node. + * @return true if it is not resolvable or else false. + */ + public boolean isUnresovled(FSTreeNode node) { + return unresolved.get(node.getLocationURI()) != null; + } + + /** + * Get the resolved content type of the node. + * + * @param node The file node. + * @return the content type of the node if it is resolvable or null. + */ + public IContentType getResolved(FSTreeNode node) { + return resolved.get(node.getLocationURI()); + } + + /** + * Add the node and its content type to the resolved list. + * + * @param node The file node. + * @param contentType Its content type. + */ + public void addResovled(FSTreeNode node, IContentType contentType) { + resolved.put(node.getLocationURI(), contentType); + } + + /** + * Add the node as an unresolvable node. + * + * @param node The file node. + */ + public void addUnresolved(FSTreeNode node) { + unresolved.put(node.getLocationURI(), node.getLocationURI()); + } + + /** + * Set the time stamp of the FSTreeNode with the specified location. + * + * @param uri The FSTreeNode's location URI. + * @param digest The new base time stamp to be set. + */ + public void setFileDigest(URI uri, FileState digest) { + digests.put(uri, digest); + } + + /** + * Remove the time stamp entry with the specified URI. + * + * @param uri The URI key. + */ + public void removeFileDigest(URI uri) { + digests.remove(uri); + } + + /** + * Get the time stamp of the FSTreeNode with the specified location. + * + * @param uri The FSTreeNode's location URI. + * @return The FSTreeNode's base time stamp. + */ + public FileState getFileDigest(FSTreeNode node) { + URI uri = node.getLocationURI(); + FileState digest = digests.get(uri); + if(digest == null) { + digest = new FileState(node); + digests.put(uri, digest); + } + digest.setNode(node); + return digest; + } + + /** + * Get the file properties of the specified node from the properties map. + * + * @param node The file node. + * @return The file properties object or empty properties object if it does not exist. + */ + public Map<QualifiedName, String> getPersistentProperties(FSTreeNode node) { + Map<QualifiedName, String> nodeProperties = properties.get(node.getLocationURI()); + if (nodeProperties == null) { + nodeProperties = Collections.synchronizedMap(new HashMap<QualifiedName, String>()); + properties.put(node.getLocationURI(), nodeProperties); + } + return nodeProperties; + } + + /** + * Dispose the cache manager so that it has a chance to save the digests and the persistent + * properties. + */ + public void dispose() { + SafeRunner.run(new ISafeRunnable(){ + @Override + public void handleException(Throwable exception) { + // Ignore on purpose. + } + @Override + public void run() throws Exception { + IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class); + File location = CacheManager.getCacheRoot(); + File persistentFile = new File(location, PERSISTENT_FILE); + service.write(PersistenceManager.this, persistentFile.getAbsoluteFile().toURI()); + }}); + } + + /** + * Returns if or if not the persistence manager needs to be disposed. + * + * @return <code>True</code> if the persistence manager needs disposal, <code>false</code> otherwise. + */ + public final static boolean needsDisposal() { + return instance != null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java index 28fd5baa1..f1d76b79f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManagerDelegate.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java index 103ef6293..e17929ca7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.model; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/CacheState.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/CacheState.java index 235a74029..5124e4500 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/CacheState.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/CacheState.java @@ -1,22 +1,21 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.model;
-
-/**
- * The enumeration that defines the states of a file's local cache, including "consistent", "modified",
- * "outdated" and "conflict".
- */
-public enum CacheState {
- consistent, // Neither of the local file and the remote file has been changed since checking out.
- modified, // The local file has changed while the remote file has not since checking out.
- outdated, // The remote file has changed while the local file has not since checking out.
- conflict // Both the local file and the remote file have changed since checking out.
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.model; + +/** + * The enumeration that defines the states of a file's local cache, including "consistent", "modified", + * "outdated" and "conflict". + */ +public enum CacheState { + consistent, // Neither of the local file and the remote file has been changed since checking out. + modified, // The local file has changed while the remote file has not since checking out. + outdated, // The remote file has changed while the local file has not since checking out. + conflict // Both the local file and the remote file have changed since checking out. +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java index 9242a18cb..9549df463 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java @@ -1,14 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation - * William Chen (Wind River) - [345384] Provide property pages for remote file system nodes - * William Chen (Wind River) - [352302]Opening a file in an editor depending on - * the client's permissions. + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.model; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java index cc0a5056e..f5034ab72 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java @@ -5,7 +5,7 @@ * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.model; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java index 359d8c413..bd9725e5d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.model; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java index 1e3924e24..eac8c3d08 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java @@ -1,95 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- * William Chen (Wind River) - [352302]Opening a file in an editor depending on
- * the client's permissions.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.model;
-
-/**
- * The data model of a user account.
- */
-public class UserAccount {
- // The user's id.
- private int uid;
- // The user's group id.
- private int gid;
- // The user's effective id.
- private int euid;
- // The user's effective group id.
- private int egid;
- // The user's home directory.
- private String home;
-
- /**
- * Create a user account with given data.
- *
- * @param uid
- * The user's id
- * @param gid
- * The user's group id
- * @param euid
- * The user's effective id.
- * @param egid
- * The user's effective group id.
- * @param home
- * The user's home directory.
- */
- public UserAccount(int uid, int gid, int euid, int egid, String home) {
- this.uid = uid;
- this.gid = gid;
- this.euid = euid;
- this.egid = egid;
- this.home = home;
- }
-
- /**
- * Get the user's id.
- *
- * @return The user's id.
- */
- public int getUID() {
- return uid;
- }
-
- /**
- * Get the user's group id.
- *
- * @return The user's group id.
- */
- public int getGID() {
- return gid;
- }
-
- /**
- * Get the user's effective id.
- *
- * @return The user's effective id.
- */
- public int getEUID() {
- return euid;
- }
-
- /**
- * Get the user's effective group id.
- *
- * @return The user's effective group id.
- */
- public int getEGID() {
- return egid;
- }
-
- /**
- * Get the user's home directory.
- *
- * @return The user's home directory.
- */
- public String getHome() {
- return home;
- }
-}
+/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.model; + +/** + * The data model of a user account. + */ +public class UserAccount { + // The user's id. + private int uid; + // The user's group id. + private int gid; + // The user's effective id. + private int euid; + // The user's effective group id. + private int egid; + // The user's home directory. + private String home; + + /** + * Create a user account with given data. + * + * @param uid + * The user's id + * @param gid + * The user's group id + * @param euid + * The user's effective id. + * @param egid + * The user's effective group id. + * @param home + * The user's home directory. + */ + public UserAccount(int uid, int gid, int euid, int egid, String home) { + this.uid = uid; + this.gid = gid; + this.euid = euid; + this.egid = egid; + this.home = home; + } + + /** + * Get the user's id. + * + * @return The user's id. + */ + public int getUID() { + return uid; + } + + /** + * Get the user's group id. + * + * @return The user's group id. + */ + public int getGID() { + return gid; + } + + /** + * Get the user's effective id. + * + * @return The user's effective id. + */ + public int getEUID() { + return euid; + } + + /** + * Get the user's effective group id. + * + * @return The user's effective group id. + */ + public int getEGID() { + return egid; + } + + /** + * Get the user's home directory. + * + * @return The user's home directory. + */ + public String getHome() { + return home; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java index b49b665e7..3b79de528 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java @@ -1,12 +1,11 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation - * William Chen (Wind River) - [345384] Provide property pages for remote file system nodes + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.nls; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties index b0a9e5c59..db7abca8a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties @@ -1,100 +1,100 @@ -###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
-# This program and the accompanying materials are made available under the terms
-# of the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Wind River Systems - initial API and implementation
-###############################################################################
-
-BlockingFileSystemProxy_TimeoutOpeningFile=Timeout while opening the file ''{0}''.
-BlockingFileSystemProxy_TimeoutClosingFile=Timeout while closing the handle ''{0}''.
-BlockingFileSystemProxy_TimeoutReadingFile=Timeout while reading the handle ''{0}''.
-BlockingFileSystemProxy_TimeoutWritingFile=Timeout while writing the handle ''{0}''.
-BlockingFileSystemProxy_TimeoutStat=Timeout while getting the stat of ''{0}''.
-BlockingFileSystemProxy_TimeoutLstat=Timeout while getting the lstat of ''{0}''.
-BlockingFileSystemProxy_TimeoutFstat=Timeout while getting the fstat of ''{0}''.
-BlockingFileSystemProxy_TimeoutSetStat=Timeout while setting the stat of ''{0}''.
-BlockingFileSystemProxy_TimeoutFSetStat=Timeout while setting the fstat of ''{0}''.
-BlockingFileSystemProxy_TimeoutOpeningDir=Timeout while opening the directory ''{0}''.
-BlockingFileSystemProxy_TimeoutReadingDir=Timeout while reading the directory ''{0}''.
-BlockingFileSystemProxy_TimeoutMakingDir=Timeout while making the directory ''{0}''.
-BlockingFileSystemProxy_TimeoutRemovingDir=Timeout while removing the directory ''{0}''.
-BlockingFileSystemProxy_TimeoutListingRoots=Timeout while listing root directories.
-BlockingFileSystemProxy_TimeoutRemovingFile=Timeout while removing the file ''{0}''.
-BlockingFileSystemProxy_TimeoutGettingRealPath=Timeout while getting real path for ''{0}''.
-BlockingFileSystemProxy_TimeoutRenamingFile=Timeout while renaming the file from ''{0}'' to ''{1}''.
-BlockingFileSystemProxy_TimeoutReadingLink=Timeout while reading the link for ''{0}''.
-BlockingFileSystemProxy_TimeoutSymLink=Timeout while creating a link ''{0}'' for ''{1}''.
-BlockingFileSystemProxy_TimeoutCopying=Timeout while copying files from ''{0}'' to ''{1}''.
-BlockingFileSystemProxy_TimeoutGettingUser=Timeout while getting the user data.
-FSTreeNodeContentProvider_rootNode_label=File System
-FSTreeNode_TypeFile=File
-FSTreeNode_TypeFileFolder=File Folder
-FSTreeNode_TypeLocalDisk=Local Disk
-FSTreeNode_TypeSystemFile=System file
-FSTreeNode_TypeUnknownFile=Unknown File
-
-Operation_DeletingFileFailed=Deleting {0} failed\!
-Operation_NotResponding=The TCF agent on the target {0} is probably down. It is not responding.
-Operation_OpeningChannelFailureMessage=We cannot open a TCF channel to the target: {0}. It is caused by {1}.
-Operation_NoFileSystemError=This TCF agent, {0}, does not provide a file system service\!
-Operation_CannotOpenDir=Cannot open directory {0} because {1}
-Operation_CopyNOfFile=Copy ({0}) of {1}
-Operation_CopyOfFile=Copy of {0}
-Operation_CannotCreateDirectory=Cannot create the directory {0} because: {1}
-Operation_TimeoutOpeningChannel=Timeout while opening a channel\!
-
-OpCopy_Copying=Copying {0} ...
-OpCopy_CannotCopyFile=Cannot copy file {0} because: {1}
-OpCopy_CopyingFile=Copying files
-
-OpCreate_TaskName=Creating {0}...
-
-TcfURLConnection_NoFileHandleReturned=No file handle returned\!
-TcfURLConnection_NoPeerFound=Could not find the specified target with the ID {0}
-TcfURLConnection_NoSuchTcfAgent=TCF agent is already disconnected\!
-
-OpDelete_Deleting=Deleting files
-OpDelete_PrepareToDelete=Prepare to delete files ...
-OpDelete_RemovingFileFolder=Removing {0} ...
-
-OpDownload_Downloading=Downloading file {0}:{1}/{2}
-OpDownload_DownloadingMultipleFiles=Downloading {0} files...
-OpDownload_DownloadingSingleFile=Downloading file {0}...
-
-OpMove_Moving=Moving {0} ...
-OpMove_FileExistsError=Cannot replace {0}: There is already a file with the same name as the folder you are moving.
-OpMove_FolderExistsError=Cannot replace {0}: There is already a folder with the same name as the file you are moving.
-OpMove_CannotMove=Cannot move {0} because {1}
-OpMove_MovingFile=Moving files
-
-OpOutStreamOp_DownloadingProgress=Downloading {0}/{1}.
-
-OpRefresh_RefreshJobTitle=Refresh {0}
-
-OpRename_CannotRename=Cannot rename {0} because {1}
-OpRename_TitleRename=Rename
-
-OpStreamOp_SetReadOnlyFailed=Setting the read-only attribute of {0} failed\!
-OpStreamOp_Bytes=\ bytes
-OpStreamOp_KBs=\ KBs
-OpStreamOp_MBs=\ MBs
-
-OpUpload_UploadingProgress=Uploading file {0}: {1}/{2}
-OpUpload_UploadNFiles=Uploading {0} files...
-OpUpload_UploadSingleFile=Uploading file {0}...
-
-TcfInputStream_NoDataAvailable=No data available
-TcfInputStream_StreamClosed=Stream is already closed\!
-
-TcfOutputStream_StreamClosed=Stream is already closed\!
-
-TcfURLStreamHandlerService_ErrorURLFormat=Error TCF URL format\!
-TcfURLStreamHandlerService_IllegalCharacter=A Windows path does not permit character {0}.
-TcfURLStreamHandlerService_OnlyDiskPartError=A Windows path should not contain only disk part.
-
-CacheManager_MkdirFailed=Making directory {0} failed
-
+############################################################################### +# Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License v1.0 which accompanies this distribution, and is +# available at http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Wind River Systems - initial API and implementation +############################################################################### + +BlockingFileSystemProxy_TimeoutOpeningFile=Timeout while opening the file ''{0}''. +BlockingFileSystemProxy_TimeoutClosingFile=Timeout while closing the handle ''{0}''. +BlockingFileSystemProxy_TimeoutReadingFile=Timeout while reading the handle ''{0}''. +BlockingFileSystemProxy_TimeoutWritingFile=Timeout while writing the handle ''{0}''. +BlockingFileSystemProxy_TimeoutStat=Timeout while getting the stat of ''{0}''. +BlockingFileSystemProxy_TimeoutLstat=Timeout while getting the lstat of ''{0}''. +BlockingFileSystemProxy_TimeoutFstat=Timeout while getting the fstat of ''{0}''. +BlockingFileSystemProxy_TimeoutSetStat=Timeout while setting the stat of ''{0}''. +BlockingFileSystemProxy_TimeoutFSetStat=Timeout while setting the fstat of ''{0}''. +BlockingFileSystemProxy_TimeoutOpeningDir=Timeout while opening the directory ''{0}''. +BlockingFileSystemProxy_TimeoutReadingDir=Timeout while reading the directory ''{0}''. +BlockingFileSystemProxy_TimeoutMakingDir=Timeout while making the directory ''{0}''. +BlockingFileSystemProxy_TimeoutRemovingDir=Timeout while removing the directory ''{0}''. +BlockingFileSystemProxy_TimeoutListingRoots=Timeout while listing root directories. +BlockingFileSystemProxy_TimeoutRemovingFile=Timeout while removing the file ''{0}''. +BlockingFileSystemProxy_TimeoutGettingRealPath=Timeout while getting real path for ''{0}''. +BlockingFileSystemProxy_TimeoutRenamingFile=Timeout while renaming the file from ''{0}'' to ''{1}''. +BlockingFileSystemProxy_TimeoutReadingLink=Timeout while reading the link for ''{0}''. +BlockingFileSystemProxy_TimeoutSymLink=Timeout while creating a link ''{0}'' for ''{1}''. +BlockingFileSystemProxy_TimeoutCopying=Timeout while copying files from ''{0}'' to ''{1}''. +BlockingFileSystemProxy_TimeoutGettingUser=Timeout while getting the user data. +FSTreeNodeContentProvider_rootNode_label=File System +FSTreeNode_TypeFile=File +FSTreeNode_TypeFileFolder=File Folder +FSTreeNode_TypeLocalDisk=Local Disk +FSTreeNode_TypeSystemFile=System file +FSTreeNode_TypeUnknownFile=Unknown File + +Operation_DeletingFileFailed=Deleting {0} failed\! +Operation_NotResponding=The TCF agent on the target {0} is probably down. It is not responding. +Operation_OpeningChannelFailureMessage=We cannot open a TCF channel to the target: {0}. It is caused by {1}. +Operation_NoFileSystemError=This TCF agent, {0}, does not provide a file system service\! +Operation_CannotOpenDir=Cannot open directory {0} because {1} +Operation_CopyNOfFile=Copy ({0}) of {1} +Operation_CopyOfFile=Copy of {0} +Operation_CannotCreateDirectory=Cannot create the directory {0} because: {1} +Operation_TimeoutOpeningChannel=Timeout while opening a channel\! + +OpCopy_Copying=Copying {0} ... +OpCopy_CannotCopyFile=Cannot copy file {0} because: {1} +OpCopy_CopyingFile=Copying files + +OpCreate_TaskName=Creating {0}... + +TcfURLConnection_NoFileHandleReturned=No file handle returned\! +TcfURLConnection_NoPeerFound=Could not find the specified target with the ID {0} +TcfURLConnection_NoSuchTcfAgent=TCF agent is already disconnected\! + +OpDelete_Deleting=Deleting files +OpDelete_PrepareToDelete=Prepare to delete files ... +OpDelete_RemovingFileFolder=Removing {0} ... + +OpDownload_Downloading=Downloading file {0}:{1}/{2} +OpDownload_DownloadingMultipleFiles=Downloading {0} files... +OpDownload_DownloadingSingleFile=Downloading file {0}... + +OpMove_Moving=Moving {0} ... +OpMove_FileExistsError=Cannot replace {0}: There is already a file with the same name as the folder you are moving. +OpMove_FolderExistsError=Cannot replace {0}: There is already a folder with the same name as the file you are moving. +OpMove_CannotMove=Cannot move {0} because {1} +OpMove_MovingFile=Moving files + +OpOutStreamOp_DownloadingProgress=Downloading {0}/{1}. + +OpRefresh_RefreshJobTitle=Refresh {0} + +OpRename_CannotRename=Cannot rename {0} because {1} +OpRename_TitleRename=Rename + +OpStreamOp_SetReadOnlyFailed=Setting the read-only attribute of {0} failed\! +OpStreamOp_Bytes=\ bytes +OpStreamOp_KBs=\ KBs +OpStreamOp_MBs=\ MBs + +OpUpload_UploadingProgress=Uploading file {0}: {1}/{2} +OpUpload_UploadNFiles=Uploading {0} files... +OpUpload_UploadSingleFile=Uploading file {0}... + +TcfInputStream_NoDataAvailable=No data available +TcfInputStream_StreamClosed=Stream is already closed\! + +TcfOutputStream_StreamClosed=Stream is already closed\! + +TcfURLStreamHandlerService_ErrorURLFormat=Error TCF URL format\! +TcfURLStreamHandlerService_IllegalCharacter=A Windows path does not permit character {0}. +TcfURLStreamHandlerService_OnlyDiskPartError=A Windows path should not contain only disk part. + +CacheManager_MkdirFailed=Making directory {0} failed + FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}.
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java index ec5fcced8..5f46a6451 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation - * Anna Dushistova(Montavista) - [386484]Allow file transfer from target to host into existing directories - * Anna Dushistova(Montavista) - [387819]File Transfer stopped working + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.services; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/DisposeModelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/DisposeModelStep.java index 2f03dde9a..9a016755c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/DisposeModelStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/DisposeModelStep.java @@ -5,7 +5,7 @@ * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.steps; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/FileTransferStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/FileTransferStep.java index f38b862d6..8bcd4f917 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/FileTransferStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/FileTransferStep.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.steps; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/InitializeModelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/InitializeModelStep.java index fa5ea991d..ec3ac35a8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/InitializeModelStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/steps/InitializeModelStep.java @@ -5,7 +5,7 @@ * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Wind River Systems - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.steps; |