mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
initial population
This commit is contained in:
parent
773cc4f622
commit
76eaebbe41
423 changed files with 53110 additions and 0 deletions
8
rse/plugins/org.eclipse.rse.services.dstore/.classpath
Normal file
8
rse/plugins/org.eclipse.rse.services.dstore/.classpath
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="miners"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
rse/plugins/org.eclipse.rse.services.dstore/.cvsignore
Normal file
1
rse/plugins/org.eclipse.rse.services.dstore/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
bin
|
28
rse/plugins/org.eclipse.rse.services.dstore/.project
Normal file
28
rse/plugins/org.eclipse.rse.services.dstore/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.rse.services.dstore</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,29 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: org.eclipse.rse.services.dstore
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: org.eclipse.rse.services.dstore.Activator
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services,
|
||||
org.eclipse.dstore.core,
|
||||
org.eclipse.dstore.extra,
|
||||
org.eclipse.ui
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.dstore.universal.miners,
|
||||
org.eclipse.rse.dstore.universal.miners.command,
|
||||
org.eclipse.rse.dstore.universal.miners.command.patterns,
|
||||
org.eclipse.rse.dstore.universal.miners.environment,
|
||||
org.eclipse.rse.dstore.universal.miners.filesystem,
|
||||
org.eclipse.rse.dstore.universal.miners.processes,
|
||||
org.eclipse.rse.internal.services.dstore.shell,
|
||||
org.eclipse.rse.services.dstore,
|
||||
org.eclipse.rse.services.dstore.files,
|
||||
org.eclipse.rse.services.dstore.processes,
|
||||
org.eclipse.rse.services.dstore.search,
|
||||
org.eclipse.rse.services.dstore.shells,
|
||||
org.eclipse.rse.services.dstore.util
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Bundle-ClassPath: dstore_services.jar,
|
||||
dstore_miners.jar
|
22
rse/plugins/org.eclipse.rse.services.dstore/about.html
Normal file
22
rse/plugins/org.eclipse.rse.services.dstore/about.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>February 24, 2005</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
25
rse/plugins/org.eclipse.rse.services.dstore/about.properties
Normal file
25
rse/plugins/org.eclipse.rse.services.dstore/about.properties
Normal file
|
@ -0,0 +1,25 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
# about.properties
|
||||
# contains externalized strings for about.ini
|
||||
# java.io.Properties file (ISO 8859-1 with "\" escapes)
|
||||
# fill-ins are supplied by about.mappings
|
||||
# This file should be translated.
|
||||
#
|
||||
# Do not translate any values surrounded by {}
|
||||
|
||||
blurb=Remote System Explorer dstore services\n\
|
||||
\n\
|
||||
Version: {featureVersion}\n\
|
||||
Build id: {0}\n\
|
||||
\n\
|
||||
(c) Copyright Eclipse contributors and others 2000, 2006. All rights reserved.\n\
|
||||
Visit http://www.eclipse.org/dsdp/tm/
|
16
rse/plugins/org.eclipse.rse.services.dstore/build.properties
Normal file
16
rse/plugins/org.eclipse.rse.services.dstore/build.properties
Normal file
|
@ -0,0 +1,16 @@
|
|||
bin.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties,\
|
||||
dstore_services.jar,\
|
||||
dstore_miners.jar
|
||||
src.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties
|
||||
source.dstore_services.jar = src/
|
||||
output.dstore_services.jar = bin/
|
||||
jars.compile.order = dstore_miners.jar,\
|
||||
dstore_services.jar
|
||||
source.dstore_miners.jar = miners/
|
||||
output.dstore_miners.jar = bin/
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jardesc>
|
||||
<jar path="D:/servers/800/dstore_core.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.rse.services.dstore/exportDstore.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" useSourceFolders="false"/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=org.eclipse.dstore.core/src"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jardesc>
|
||||
<jar path="D:/servers/800/dstore_miners.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.rse.services.dstore/exportDstoreMiners.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" useSourceFolders="false"/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=org.eclipse.rse.services.dstore/miners"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jardesc>
|
||||
<jar path="D:/servers/800/clientserver.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.rse.services.dstore/exportclientserver.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" useSourceFolders="false"/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=org.eclipse.rse.services/clientserver"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
|
@ -0,0 +1,29 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
||||
|
||||
|
||||
public interface ICancellableHandler
|
||||
{
|
||||
|
||||
public boolean isDone();
|
||||
public boolean isCancelled();
|
||||
|
||||
public void cancel();
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.IServiceConstants;
|
||||
|
||||
public interface IUniversalDataStoreConstants extends IServiceConstants
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Miner names, used for logging
|
||||
*/
|
||||
public static final String UNIVERSAL_FILESYSTEM_MINER = "UniversalFileSystemMiner";
|
||||
|
||||
//
|
||||
// Universal File descriptors for DataStore DataElements
|
||||
//
|
||||
public static final String MESSAGE_DESCRIPTOR = "universal.message";
|
||||
|
||||
public static final String UNIVERSAL_NODE_DESCRIPTOR = "universal.node";
|
||||
public static final String UNIVERSAL_TEMP_DESCRIPTOR = "universal.temp";
|
||||
public static final String UNIVERSAL_FILTER_DESCRIPTOR = "universal.FilterObject";
|
||||
public static final String UNIVERSAL_FILE_DESCRIPTOR = "universal.FileObject";
|
||||
public static final String UNIVERSAL_FOLDER_DESCRIPTOR = "universal.FolderObject";
|
||||
|
||||
public static final String UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR = "universal.ArchiveFileObject";
|
||||
public static final String UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR = "universal.VirtualFileObject";
|
||||
public static final String UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR = "universal.VirtualFolderObject";
|
||||
|
||||
|
||||
//
|
||||
// Universal File Miner Commands
|
||||
//
|
||||
|
||||
public static final String C_QUERY_ROOTS = "C_QUERY_ROOTS";
|
||||
public static final String C_QUERY_VIEW_ALL = "C_QUERY_VIEW_ALL";
|
||||
public static final String C_QUERY_VIEW_FILES = "C_QUERY_VIEW_FILES";
|
||||
public static final String C_QUERY_VIEW_FOLDERS = "C_QUERY_VIEW_FOLDERS";
|
||||
public static final String C_CREATE_FILE = "C_CREATE_FILE";
|
||||
public static final String C_CREATE_FOLDER = "C_CREATE_FOLDER";
|
||||
public static final String C_QUERY_GET_REMOTE_OBJECT="C_QUERY_GET_REMOTE_OBJECT";
|
||||
|
||||
public static final String C_DELETE = "C_DELETE";
|
||||
public static final String C_DELETE_BATCH = "C_DELETE_BATCH";
|
||||
public static final String C_RENAME = "C_RENAME";
|
||||
public static final String C_COPY = "C_COPY";
|
||||
public static final String C_COPY_BATCH = "C_COPY_BATCH";
|
||||
|
||||
// Download file command
|
||||
public static final String C_DOWNLOAD_FILE = "C_DOWNLOAD_FILE";
|
||||
|
||||
// Query system encoding command
|
||||
public static final String C_SYSTEM_ENCODING = "C_SYSTEM_ENCODING";
|
||||
|
||||
// Query unused port
|
||||
public static final String C_QUERY_UNUSED_PORT = "C_QUERY_UNUSED_PORT";
|
||||
|
||||
// Qualified class name command and return type
|
||||
public static final String C_QUERY_QUALIFIED_CLASSNAME = "C_QUERY_QUALIFIED_CLASSNAME";
|
||||
public static final String TYPE_QUALIFIED_CLASSNAME = "fullClassName";
|
||||
|
||||
|
||||
|
||||
// Mode of transfer: text or binary
|
||||
public static final int TEXT_MODE = -1;
|
||||
public static final int BINARY_MODE = -2;
|
||||
|
||||
|
||||
// Download result types and download messages
|
||||
public static final String DOWNLOAD_RESULT_SUCCESS_TYPE = "universal.download.success";
|
||||
public static final String DOWNLOAD_RESULT_SUCCESS_MESSAGE = "successful";
|
||||
public static final String DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION = "FileNotFoundException";
|
||||
public static final String DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION = "UnsupportedEncodingException";
|
||||
public static final String DOWNLOAD_RESULT_IO_EXCEPTION = "IOException";
|
||||
public static final String DOWNLOAD_RESULT_EXCEPTION = "Exception";
|
||||
public static final String DOWNLOAD_RESULT_UNEXPECTED_ERROR = "UnexpectedError";
|
||||
|
||||
|
||||
// Number of bytes in a kilobyte
|
||||
public static final int KB_IN_BYTES = 1024;
|
||||
|
||||
// Number of kilobytes we want
|
||||
public static final int NUM_OF_KB = 40;
|
||||
|
||||
// The size of file segments to read and send across connection (in bytes)
|
||||
public static final int BUFFER_SIZE = NUM_OF_KB * KB_IN_BYTES;
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Date;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
public class ServerLogger {
|
||||
|
||||
|
||||
// Constants for logging - for use in rsecomm.properties
|
||||
private static final String DEBUG_LEVEL = "debug_level";
|
||||
private static final String LOG_LOCATION = "log_location";
|
||||
|
||||
private static final int LOG_WARNING = 1;
|
||||
private static final int LOG_INFO = 2;
|
||||
private static final int LOG_DEBUG = 3;
|
||||
|
||||
private static final String LOG_TO_STDOUT = "Log_To_StdOut";
|
||||
|
||||
private static Object writeLock = new Object();
|
||||
private static PrintWriter _logFileStream = null;
|
||||
|
||||
public static final boolean DEBUG = false;
|
||||
private static int log_level = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ServerLogger(String logPathName) {
|
||||
if (_logFileStream == null) {
|
||||
// Read .properties file to configure
|
||||
boolean logToFile = true;
|
||||
|
||||
try {
|
||||
ResourceBundle properties = ResourceBundle.getBundle("rsecomm");
|
||||
String debug_level = properties.getString(DEBUG_LEVEL).trim();
|
||||
log_level = Integer.parseInt(debug_level);
|
||||
String log_location = properties.getString(LOG_LOCATION).trim();
|
||||
if (log_location.equalsIgnoreCase(LOG_TO_STDOUT)) {
|
||||
logToFile = false;
|
||||
_logFileStream = new PrintWriter(System.out);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Just use logging defaults: log_level = 0, log to file
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
if (logToFile) {
|
||||
try {
|
||||
File _logFile = new File(logPathName, "rsecomm.log");
|
||||
|
||||
if (!_logFile.exists()) {
|
||||
_logFile.createNewFile();
|
||||
}
|
||||
|
||||
_logFileStream = new PrintWriter(new FileOutputStream(_logFile));
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error opening log file " + logPathName + "rsecomm.log");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* logInfo
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public static void logInfo(String minerName, String message) {
|
||||
if (log_level >= LOG_INFO) {
|
||||
if (_logFileStream != null) {
|
||||
synchronized(writeLock) {
|
||||
try {
|
||||
_logFileStream.println(new Date());
|
||||
_logFileStream.println("INFO " + minerName + ": " + message);
|
||||
_logFileStream.println("---------------------------------------------------------------");
|
||||
_logFileStream.flush();
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* logWarning
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public static void logWarning(String minerName, String message) {
|
||||
if (log_level >= LOG_WARNING) {
|
||||
if (_logFileStream != null) {
|
||||
synchronized(writeLock) {
|
||||
try {
|
||||
_logFileStream.println(new Date());
|
||||
_logFileStream.println("WARNING " + minerName + ": " + message);
|
||||
_logFileStream.println("---------------------------------------------------------------");
|
||||
_logFileStream.flush();
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* logError
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*
|
||||
* @param exception Exception that generated the error. Used to print a stack trace.
|
||||
*/
|
||||
public static void logError(String minerName, String message, Throwable exception) {
|
||||
if (_logFileStream != null) {
|
||||
synchronized(writeLock) {
|
||||
try {
|
||||
_logFileStream.println(new Date());
|
||||
_logFileStream.println("ERROR " + minerName + ": " + message);
|
||||
if (exception != null) {
|
||||
exception.printStackTrace(_logFileStream);
|
||||
}
|
||||
_logFileStream.println("---------------------------------------------------------------");
|
||||
_logFileStream.flush();
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* logDebugMessage
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public synchronized static void logDebugMessage(String minerName, String message) {
|
||||
if (DEBUG && log_level == LOG_DEBUG) {
|
||||
if (_logFileStream != null) {
|
||||
synchronized(writeLock) {
|
||||
try {
|
||||
_logFileStream.println(new Date());
|
||||
_logFileStream.println("DEBUG " + minerName + ": " + message);
|
||||
_logFileStream.println("---------------------------------------------------------------");
|
||||
_logFileStream.flush();
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class UniversalServerUtilities {
|
||||
|
||||
|
||||
private static String _userPreferencesDirectory = null;
|
||||
private static ServerLogger log = new ServerLogger(getUserPreferencesDirectory());
|
||||
|
||||
|
||||
/**
|
||||
* getUserPreferencesDirectory() - returns directory on IFS where to store user settings
|
||||
*/
|
||||
public static String getUserPreferencesDirectory()
|
||||
{
|
||||
if (_userPreferencesDirectory == null) {
|
||||
|
||||
_userPreferencesDirectory = System.getProperty("user.home");
|
||||
String userID = System.getProperty("user.name");
|
||||
|
||||
// append a '/' if not there
|
||||
if ( _userPreferencesDirectory.length() == 0 ||
|
||||
_userPreferencesDirectory.charAt( _userPreferencesDirectory.length() -1 ) != File.separatorChar ) {
|
||||
|
||||
_userPreferencesDirectory = _userPreferencesDirectory + File.separator;
|
||||
}
|
||||
|
||||
_userPreferencesDirectory = _userPreferencesDirectory + ".eclipse" + File.separator +
|
||||
"RSE" + File.separator + userID + File.separator;
|
||||
File dirFile = new File(_userPreferencesDirectory);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
return _userPreferencesDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* logInfo
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public static void logInfo(String minerName, String message) {
|
||||
ServerLogger.logInfo(minerName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* logWarning
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public static void logWarning(String minerName, String message) {
|
||||
ServerLogger.logWarning(minerName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* logError
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*
|
||||
* @param exception Exception that generated the error. Used to print a stack trace.
|
||||
*/
|
||||
public static void logError(String minerName, String message, Throwable exception) {
|
||||
ServerLogger.logError(minerName, message, exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* logDebugMessage
|
||||
*
|
||||
* @param minerName
|
||||
*
|
||||
* @param message Message text to be logged.
|
||||
*/
|
||||
public static void logDebugMessage(String minerName, String message) {
|
||||
ServerLogger.logDebugMessage(minerName, message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.dstore.core.miners.miner.Miner;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStoreAttributes;
|
||||
import org.eclipse.dstore.core.model.DataStoreResources;
|
||||
import org.eclipse.rse.dstore.universal.miners.command.patterns.Patterns;
|
||||
import org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The CommandMiner provides the ability to run remote interactive shell
|
||||
* commands via the DataStore.
|
||||
*/
|
||||
public class CommandMiner extends Miner
|
||||
{
|
||||
public static final String MINER_ID = CommandMiner.class.getName();//"org.eclipse.rse.dstore.universal.miners.command.CommandMiner";
|
||||
|
||||
public class CommandMinerDescriptors
|
||||
{
|
||||
public DataElement _stdout;
|
||||
public DataElement _stderr;
|
||||
public DataElement _prompt;
|
||||
public DataElement _grep;
|
||||
public DataElement _pathenvvar;
|
||||
public DataElement _envvar;
|
||||
public DataElement _libenvvar;
|
||||
public DataElement _error;
|
||||
public DataElement _warning;
|
||||
public DataElement _informational;
|
||||
public DataElement _process;
|
||||
|
||||
public DataElement getDescriptorFor(String type)
|
||||
{
|
||||
DataElement descriptor = null;
|
||||
if (type.equals("stdout"))
|
||||
{
|
||||
descriptor = _stdout;
|
||||
}
|
||||
else if (type.equals("pathenvvar"))
|
||||
{
|
||||
descriptor = _pathenvvar;
|
||||
}
|
||||
else if (type.equals("envvar"))
|
||||
{
|
||||
descriptor = _envvar;
|
||||
}
|
||||
else if (type.equals("libenvvar"))
|
||||
{
|
||||
descriptor = _libenvvar;
|
||||
}
|
||||
else if (type.equals("error"))
|
||||
{
|
||||
descriptor = _error;
|
||||
}
|
||||
else if (type.equals("warning"))
|
||||
{
|
||||
descriptor = _warning;
|
||||
}
|
||||
else if (type.equals("informational"))
|
||||
{
|
||||
descriptor = _informational;
|
||||
}
|
||||
else if (type.equals("process"))
|
||||
{
|
||||
descriptor = _process;
|
||||
}
|
||||
else if (type.equals("grep"))
|
||||
{
|
||||
descriptor = _grep;
|
||||
}
|
||||
else if (type.equals("stderr"))
|
||||
{
|
||||
descriptor = _stderr;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap _threads = new HashMap();
|
||||
private Patterns _patterns;
|
||||
private CommandMinerDescriptors _descriptors;
|
||||
|
||||
|
||||
public Patterns getPatterns()
|
||||
{
|
||||
if (_patterns == null)
|
||||
{
|
||||
_patterns = new Patterns(_dataStore);
|
||||
}
|
||||
return _patterns;
|
||||
}
|
||||
|
||||
protected ArrayList getDependencies()
|
||||
{
|
||||
ArrayList dependencies = new ArrayList();
|
||||
dependencies.add(EnvironmentMiner.MINER_ID);
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public void extendSchema(DataElement schemaRoot)
|
||||
{
|
||||
//DataElement fsD = _dataStore.findObjectDescriptor("Filesystem Objects");
|
||||
DataElement fsD= _dataStore.findObjectDescriptor(DataStoreResources.model_directory);
|
||||
DataElement cancellable = _dataStore.findObjectDescriptor(DataStoreResources.model_Cancellable);
|
||||
|
||||
DataElement cmdD = createCommandDescriptor(fsD, "Command", "C_COMMAND", false);
|
||||
_dataStore.createReference(cancellable, cmdD, "abstracts", "abstracted by");
|
||||
|
||||
DataElement shellD = createCommandDescriptor(fsD, "Shell", "C_SHELL", false);
|
||||
_dataStore.createReference(cancellable, shellD, "abstracts", "abstracted by");
|
||||
|
||||
DataElement inputD = _dataStore.createObject(cmdD, "input", "Enter command");
|
||||
DataElement outputD = _dataStore.createObject(cmdD, "output", "Command Output");
|
||||
|
||||
_descriptors = new CommandMinerDescriptors();
|
||||
_descriptors._stdout = _dataStore.createObjectDescriptor(schemaRoot, "stdout");
|
||||
_descriptors._stderr = _dataStore.createObjectDescriptor(schemaRoot, "stderr");
|
||||
_descriptors._prompt = _dataStore.createObjectDescriptor(schemaRoot, "prompt");
|
||||
_descriptors._grep = _dataStore.createObjectDescriptor(schemaRoot, "grep");
|
||||
_descriptors._pathenvvar = _dataStore.createObjectDescriptor(schemaRoot, "pathenvvar");
|
||||
_descriptors._envvar = _dataStore.createObjectDescriptor(schemaRoot, "envvar");
|
||||
_descriptors._libenvvar = _dataStore.createObjectDescriptor(schemaRoot, "libenvvar");
|
||||
_descriptors._error = _dataStore.createObjectDescriptor(schemaRoot, "error");
|
||||
_descriptors._warning = _dataStore.createObjectDescriptor(schemaRoot, "warning");
|
||||
_descriptors._informational = _dataStore.createObjectDescriptor(schemaRoot, "informational");
|
||||
_descriptors._process =_dataStore.createObjectDescriptor(schemaRoot, "process");
|
||||
|
||||
|
||||
DataElement getPossibleCmds = createCommandDescriptor(fsD, "Get Commands", "C_GET_POSSIBLE_COMMANDS", false);
|
||||
_dataStore.refresh(schemaRoot);
|
||||
}
|
||||
|
||||
public DataElement handleCommand(DataElement theElement)
|
||||
{
|
||||
String name = getCommandName(theElement);
|
||||
DataElement status = getCommandStatus(theElement);
|
||||
DataElement subject = getCommandArgument(theElement, 0);
|
||||
|
||||
if (name.equals("C_COMMAND"))
|
||||
{
|
||||
DataElement invArg = getCommandArgument(theElement, 1);
|
||||
if (invArg != null)
|
||||
{
|
||||
String invocation = invArg.getName();
|
||||
//Remove All extra whitespace from the command
|
||||
if (invocation.trim().length() > 0)
|
||||
{
|
||||
if (invocation.equals("?") || invocation.equals("help"))
|
||||
invocation = "cat " + theElement.getDataStore().getAttribute(DataStoreAttributes.A_PLUGIN_PATH) + "/org.eclipse.rse.services.dstore/patterns.dat";
|
||||
launchCommand(subject, invocation, status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
else
|
||||
{
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
}
|
||||
}
|
||||
else if (name.equals("C_SHELL"))
|
||||
{
|
||||
String invocation = ">";
|
||||
launchCommand(subject, invocation, status);
|
||||
}
|
||||
else if (name.equals("C_SEND_INPUT"))
|
||||
{
|
||||
DataElement input = getCommandArgument(theElement, 1);
|
||||
DataElement de = (DataElement) subject.dereference().get(1);
|
||||
sendInputToCommand(input.getName(), getCommandStatus(subject));
|
||||
}
|
||||
else if (name.equals("C_CANCEL"))
|
||||
{
|
||||
DataElement de = (DataElement) subject.dereference().get(1);
|
||||
DataElement cancelStatus = getCommandStatus(subject);
|
||||
cancelCommand(de.getName().trim(), cancelStatus);
|
||||
return status;
|
||||
}
|
||||
else if (name.equals("C_GET_POSSIBLE_COMMANDS"))
|
||||
{
|
||||
getPossibleCommands(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void getPossibleCommands(DataElement status)
|
||||
{
|
||||
QueryPathThread qpt = new QueryPathThread(status);
|
||||
qpt.start();
|
||||
}
|
||||
|
||||
public void launchCommand(DataElement subject, String invocation, DataElement status)
|
||||
{
|
||||
//First Check to make sure that there are no "zombie" threads
|
||||
Iterator iter = _threads.keySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String threadName = (String) iter.next();
|
||||
CommandMinerThread theThread = (CommandMinerThread) _threads.get(threadName);
|
||||
if ((theThread == null) || (!theThread.isAlive()))
|
||||
{
|
||||
_threads.remove(threadName);
|
||||
}
|
||||
}
|
||||
CommandMinerThread newCommand = new CommandMinerThread(subject, invocation, status, getPatterns(), _descriptors);
|
||||
_threads.put(status.getAttribute(DE.A_ID), newCommand);
|
||||
newCommand.start();
|
||||
}
|
||||
|
||||
private void sendInputToCommand(String input, DataElement status)
|
||||
{
|
||||
CommandMinerThread theThread = (CommandMinerThread) _threads.get(status.getAttribute(DE.A_ID));
|
||||
if (theThread != null)
|
||||
{
|
||||
theThread.sendInput(input);
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelCommand(String theCommand, DataElement status)
|
||||
{
|
||||
CommandMinerThread theThread = (CommandMinerThread) _threads.get(status.getAttribute(DE.A_ID));
|
||||
if (theThread != null)
|
||||
{
|
||||
theThread.stopThread();
|
||||
theThread.sendExit();
|
||||
|
||||
boolean done = false;
|
||||
long stopIn = System.currentTimeMillis() + 3000;
|
||||
while (!done)
|
||||
if ((!theThread.isAlive()) || (stopIn < System.currentTimeMillis()))
|
||||
done = true;
|
||||
_dataStore.createObject(status, "stdout", "Command Cancelled by User Request");
|
||||
_dataStore.refresh(status);
|
||||
}
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return "6.4.0";
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,398 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.dstore.core.model.Handler;
|
||||
|
||||
/**
|
||||
* The OutputHandler class is used to listen to a particular output or error stream,
|
||||
* interpret that information and create DataElements for it for use on the client.
|
||||
*/
|
||||
public class OutputHandler extends Handler
|
||||
{
|
||||
|
||||
private DataInputStream _reader;
|
||||
private boolean _isStdError;
|
||||
private boolean _isTerminal;
|
||||
|
||||
private CommandMinerThread _commandThread;
|
||||
private boolean _isShell;
|
||||
private static int MAX_OFFSET = 10000;
|
||||
private boolean _endOfStream = false;
|
||||
|
||||
|
||||
private List _encodings;
|
||||
|
||||
|
||||
public OutputHandler(DataInputStream reader, String qualifier, boolean isTerminal, boolean isStdError, boolean isShell, CommandMinerThread commandThread)
|
||||
{
|
||||
_reader = reader;
|
||||
_isStdError = isStdError;
|
||||
_isTerminal = isTerminal;
|
||||
_commandThread = commandThread;
|
||||
_isShell = isShell;
|
||||
_encodings = new ArrayList();
|
||||
String system = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
if (system.startsWith("z"))
|
||||
{
|
||||
_encodings.add("IBM-1047");
|
||||
/*
|
||||
_encodings.add("Cp1047");
|
||||
_encodings.add("Cp037");
|
||||
_encodings.add("UTF8");
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
String specialEncoding = System.getProperty("dstore.stdin.encoding");
|
||||
if (specialEncoding != null)
|
||||
{
|
||||
_encodings.add(specialEncoding);
|
||||
}
|
||||
_encodings.add(System.getProperty("file.encoding"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void newCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public void handle()
|
||||
{
|
||||
String[] lines = readLines();
|
||||
if (lines != null)
|
||||
{
|
||||
|
||||
/*
|
||||
if (lines.length == 0)
|
||||
{
|
||||
_reader.
|
||||
}
|
||||
|
||||
// don't do anything unless we require output
|
||||
if (_newCommand && !_isTerminal)
|
||||
{
|
||||
doPrompt();
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
String line = lines[i];
|
||||
_commandThread.interpretLine(line, _isStdError);
|
||||
}
|
||||
if (!_isTerminal)
|
||||
doPrompt();
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void doPrompt()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((_reader.available() == 0) && !_isStdError && _isShell)
|
||||
{
|
||||
if (!_isTerminal)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(500);
|
||||
if (_reader.available() == 0)
|
||||
{
|
||||
// create fake prompt
|
||||
_commandThread.createPrompt(_commandThread.getCWD() + '>', _commandThread.getCWD());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void waitForInput()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String[] readLines()
|
||||
{
|
||||
if (_endOfStream)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String[] output = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// find out how many bytes are available to be read
|
||||
int available = _reader.available();
|
||||
int lookahead = 0;
|
||||
|
||||
// if there's none, wait a bit and return true to continue
|
||||
if (available <= 0)
|
||||
{
|
||||
sleep(100);
|
||||
available = _reader.available();
|
||||
|
||||
if (available == 0)
|
||||
{
|
||||
lookahead = _reader.read();
|
||||
if (lookahead == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
available = _reader.available() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] readBytes = new byte[available];
|
||||
|
||||
// read the available bytes
|
||||
int numRead = 0;
|
||||
if (lookahead > 0)
|
||||
{
|
||||
readBytes[0] = (byte)lookahead;
|
||||
numRead = _reader.read(readBytes, 1, available - 1) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
numRead = _reader.read(readBytes, 0, available);
|
||||
}
|
||||
|
||||
// if we've reached end of stream, quit
|
||||
if (numRead == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (readBytes[numRead - 1]== -1)
|
||||
{
|
||||
_endOfStream = true;
|
||||
}
|
||||
|
||||
// use various encodings as a precaution
|
||||
// note that the first encoding will be the encoding that we were given
|
||||
int encodingIndex = 0;
|
||||
|
||||
while (encodingIndex < _encodings.size())
|
||||
{
|
||||
String encoding = (String)(_encodings.get(encodingIndex));
|
||||
|
||||
// get the output using the encoding
|
||||
try
|
||||
{
|
||||
String fullOutput = new String(readBytes, 0, numRead, encoding);
|
||||
|
||||
// if output is not null, we assume the encoding was correct and process the output
|
||||
if (fullOutput != null /*&& fullOutput.length() == numRead*/)
|
||||
{
|
||||
// tokenize the output so that we can get each line of output
|
||||
// the delimiters are therefore set to "\n\r"
|
||||
StringTokenizer tokenizer = new StringTokenizer(fullOutput, "\n\r");
|
||||
int numTokens = tokenizer.countTokens();
|
||||
output = new String[numTokens];
|
||||
int index = 0;
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
output[index] = tokenizer.nextToken();
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/*
|
||||
private String readLine()
|
||||
{
|
||||
|
||||
|
||||
int ch;
|
||||
boolean done = false;
|
||||
int byteArrayOffset = 0;
|
||||
while (!done && !isFinished() && (byteArrayOffset < MAX_OFFSET))
|
||||
{
|
||||
try
|
||||
{
|
||||
//synchronized (_reader)
|
||||
{
|
||||
|
||||
if (byteArrayOffset > 0 && (_reader.available() == 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(_waitIncrement);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
if (_reader.available() == 0)
|
||||
{
|
||||
_isWaiting = true;
|
||||
done = true;
|
||||
//System.out.println("return nothiong");
|
||||
//return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ch = _reader.read();
|
||||
|
||||
_isWaiting = false;
|
||||
switch (ch)
|
||||
{
|
||||
case -1 :
|
||||
case 65535 :
|
||||
if (byteArrayOffset == 0) //End of Reader
|
||||
{
|
||||
return null;
|
||||
}
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case 10 : // new line
|
||||
case 13 : // carriage return
|
||||
done = true; //Newline
|
||||
break;
|
||||
|
||||
case 27:
|
||||
break;
|
||||
|
||||
case 9 :
|
||||
|
||||
|
||||
// DKM - test - can we preserve tabs?
|
||||
_byteArray[byteArrayOffset++] = (byte)ch;
|
||||
|
||||
//theLine.append(" "); //Tab
|
||||
break;
|
||||
|
||||
default :
|
||||
char tch = (char) ch;
|
||||
if (!Character.isISOControl(tch))
|
||||
{
|
||||
//System.out.println("char="+tch);
|
||||
_byteArray[byteArrayOffset++] = (byte)ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("ignoring:"+ch);
|
||||
// ignore next char too
|
||||
if (_reader.available() > 0)
|
||||
_reader.read();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//Check to see if the BufferedReader is still ready which means there are more characters
|
||||
//in the Buffer...If not, then we assume it is waiting for input.
|
||||
if (_reader.available() == 0)
|
||||
{
|
||||
//wait to make sure
|
||||
try
|
||||
{
|
||||
Thread.sleep(_waitIncrement);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
if (_reader.available() == 0)
|
||||
{
|
||||
_isWaiting = true;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String lineObject = null;
|
||||
if (byteArrayOffset > 0)
|
||||
{
|
||||
|
||||
int encodingIndex = 0;
|
||||
//printEncodedLines(_byteArray, 0, byteArrayOffset);
|
||||
|
||||
|
||||
while (lineObject == null && encodingIndex < _encodings.size())
|
||||
{
|
||||
lineObject = getEncodedLine(_byteArray, 0, byteArrayOffset, (String) _encodings.get(encodingIndex));
|
||||
encodingIndex++;
|
||||
}
|
||||
|
||||
if (lineObject == null)
|
||||
{
|
||||
lineObject = new String(_byteArray, 0, byteArrayOffset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lineObject ="";
|
||||
}
|
||||
|
||||
|
||||
return lineObject;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,441 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.dstore.core.model.Handler;
|
||||
|
||||
|
||||
public class ProcessTracker extends Handler
|
||||
{
|
||||
|
||||
private class ProcessDescriptor
|
||||
{
|
||||
private String _pid;
|
||||
private String _cmd;
|
||||
|
||||
public ProcessDescriptor(String pid, String cmd)
|
||||
{
|
||||
_pid = pid;
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
public String getPID()
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
|
||||
public String getCMD()
|
||||
{
|
||||
return _cmd;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String result = getPID() + " " + getCMD();
|
||||
if (ProcessDescriptor.this == _newestProcess)
|
||||
{
|
||||
result += " *";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasCMD(String cmdname)
|
||||
{
|
||||
StringTokenizer tokenizer = new StringTokenizer(_cmd, "/");
|
||||
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
String token = tokenizer.nextToken();
|
||||
if (!tokenizer.hasMoreElements())
|
||||
{
|
||||
if (token.equals(cmdname))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof ProcessDescriptor)
|
||||
{
|
||||
ProcessDescriptor des = (ProcessDescriptor) obj;
|
||||
if (des.getPID().equals(_pid))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Process _psShell;
|
||||
|
||||
private BufferedReader _psReader;
|
||||
private BufferedWriter _psWriter;
|
||||
|
||||
private boolean _updateFlag;
|
||||
private ProcessDescriptor _newestProcess;
|
||||
private String _psCommand;
|
||||
private boolean _isEnabled;
|
||||
|
||||
private List _currentProcesses = new ArrayList();
|
||||
|
||||
public ProcessTracker()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private String getFormatOptions(String theOS)
|
||||
{
|
||||
String formatOptions = "";
|
||||
if (theOS.startsWith("z"))
|
||||
{
|
||||
formatOptions = "-o pid,comm";
|
||||
}
|
||||
else if (theOS.startsWith("linux"))
|
||||
{
|
||||
formatOptions = "--format pid,ucomm";
|
||||
}
|
||||
else if (theOS.startsWith("aix"))
|
||||
{
|
||||
formatOptions = "-F pid,ucomm";
|
||||
}
|
||||
return formatOptions;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
String userID = System.getProperty("user.name");
|
||||
String userOptions = "-u " + userID;
|
||||
|
||||
String theOS = System.getProperty("os.name").toLowerCase();
|
||||
String formatOptions = getFormatOptions(theOS);
|
||||
if (formatOptions.length() == 0)
|
||||
{
|
||||
_isEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isEnabled = true;
|
||||
}
|
||||
if (_isEnabled)
|
||||
{
|
||||
|
||||
_psCommand = "ps " + userOptions + " " + formatOptions;
|
||||
try
|
||||
{
|
||||
|
||||
if (_psShell == null)
|
||||
{
|
||||
_psShell = Runtime.getRuntime().exec("sh");
|
||||
|
||||
String specialEncoding = System.getProperty("dstore.stdin.encoding");
|
||||
if (specialEncoding != null)
|
||||
{
|
||||
_psReader = new BufferedReader(new InputStreamReader(_psShell.getInputStream(), specialEncoding));
|
||||
try
|
||||
{
|
||||
_psWriter = new BufferedWriter(new OutputStreamWriter(_psShell.getOutputStream(), specialEncoding));
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
_psWriter = new BufferedWriter(new OutputStreamWriter(_psShell.getOutputStream()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_psReader = new BufferedReader(new InputStreamReader(_psShell.getInputStream()));
|
||||
_psWriter = new BufferedWriter(new OutputStreamWriter(_psShell.getOutputStream()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String readLine(BufferedReader reader)
|
||||
{
|
||||
StringBuffer theLine = new StringBuffer();
|
||||
int ch;
|
||||
boolean done = false;
|
||||
while (!done)
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (reader)
|
||||
{
|
||||
if (!reader.ready())
|
||||
{
|
||||
return theLine.toString();
|
||||
}
|
||||
ch = reader.read();
|
||||
switch (ch)
|
||||
{
|
||||
case -1 :
|
||||
if (theLine.length() == 0) //End of Reader
|
||||
return null;
|
||||
done = true;
|
||||
break;
|
||||
case 65535 :
|
||||
if (theLine.length() == 0)
|
||||
return null;
|
||||
done = true;
|
||||
break;
|
||||
case 10 :
|
||||
done = true; //Newline
|
||||
break;
|
||||
case 13 :
|
||||
done = true;
|
||||
break; //Carriage Return
|
||||
default :
|
||||
char tch = (char) ch;
|
||||
if (!Character.isISOControl(tch))
|
||||
{
|
||||
theLine.append(tch); //Any other character
|
||||
}
|
||||
else
|
||||
{
|
||||
// ignore next char too
|
||||
if (reader.ready())
|
||||
reader.read();
|
||||
}
|
||||
break;
|
||||
//Any other character
|
||||
}
|
||||
//Check to see if the BufferedReader is still ready which means there are more characters
|
||||
//in the Buffer...If not, then we assume it is waiting for input.
|
||||
if (!reader.ready())
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return theLine.toString();
|
||||
}
|
||||
|
||||
private void getCurrentProcesses()
|
||||
{
|
||||
try
|
||||
{
|
||||
_psWriter.write(_psCommand);
|
||||
_psWriter.write("\n");
|
||||
_psWriter.flush();
|
||||
|
||||
// skip first line
|
||||
String line = _psReader.readLine();
|
||||
ArrayList newPIDs = new ArrayList();
|
||||
line = readLine(_psReader);
|
||||
while (line != null && line.length() > 0)
|
||||
{
|
||||
line = line.trim();
|
||||
int firstBlank = line.indexOf(' ');
|
||||
if (firstBlank != -1)
|
||||
{
|
||||
String pid = line.substring(0, firstBlank);
|
||||
String cmd = line.substring(firstBlank + 1, line.length());
|
||||
ProcessDescriptor descriptor = new ProcessDescriptor(pid, cmd);
|
||||
if (!descriptor.hasCMD("ps"))
|
||||
{
|
||||
newPIDs.add(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
line = readLine(_psReader);
|
||||
}
|
||||
updateProcesses(newPIDs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
//listProcesses();
|
||||
}
|
||||
|
||||
public void finish()
|
||||
{
|
||||
_updateFlag = false;
|
||||
if (_isEnabled)
|
||||
{
|
||||
endTrackerProcess();
|
||||
}
|
||||
super.finish();
|
||||
}
|
||||
|
||||
private void updateProcesses(ArrayList newPIDs)
|
||||
{
|
||||
boolean firstRun = _currentProcesses.size() == 0;
|
||||
// remove finished pids
|
||||
for (int c = _currentProcesses.size() - 1; c >= 0; c--)
|
||||
{
|
||||
ProcessDescriptor p = (ProcessDescriptor) _currentProcesses.get(c);
|
||||
if (newPIDs.contains(p))
|
||||
{
|
||||
newPIDs.remove(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentProcesses.remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
// add new pids
|
||||
for (int i = 0; i < newPIDs.size(); i++)
|
||||
{
|
||||
ProcessDescriptor p = (ProcessDescriptor) newPIDs.get(i);
|
||||
_currentProcesses.add(p);
|
||||
if (!firstRun)
|
||||
{
|
||||
_newestProcess = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endTrackerProcess()
|
||||
{
|
||||
if (_isEnabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
_psWriter.write("exit");
|
||||
_psWriter.write("\n");
|
||||
_psWriter.flush();
|
||||
|
||||
_psReader.close();
|
||||
_psWriter.close();
|
||||
_psShell.waitFor();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProcessDescriptor getNewestProcess()
|
||||
{
|
||||
return _newestProcess;
|
||||
}
|
||||
|
||||
private ProcessDescriptor findLast(String cmd)
|
||||
{
|
||||
if (_newestProcess != null && _newestProcess.hasCMD(cmd))
|
||||
{
|
||||
return _newestProcess;
|
||||
}
|
||||
for (int i = _currentProcesses.size() - 1; i > 0; i--)
|
||||
{
|
||||
ProcessDescriptor descriptor = (ProcessDescriptor) _currentProcesses.get(i);
|
||||
if (descriptor.hasCMD(cmd))
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void killCommand(String cmd)
|
||||
{
|
||||
ProcessDescriptor descriptor = findLast(cmd);
|
||||
if (descriptor != null)
|
||||
{
|
||||
kill(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
public void killLastest()
|
||||
{
|
||||
if (_newestProcess != null)
|
||||
{
|
||||
kill(_newestProcess);
|
||||
}
|
||||
}
|
||||
|
||||
private void kill(ProcessDescriptor descriptor)
|
||||
{
|
||||
if (_isEnabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
_psWriter.write("kill " + descriptor.getPID());
|
||||
_psWriter.write("\n");
|
||||
_psWriter.flush();
|
||||
_psReader.reset();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
doUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public void handle()
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
if (_updateFlag)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
getCurrentProcesses();
|
||||
_updateFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void doUpdate()
|
||||
{
|
||||
if (_isEnabled)
|
||||
_updateFlag = true;
|
||||
else
|
||||
_updateFlag = false;
|
||||
}
|
||||
|
||||
public synchronized void waitForInput()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner;
|
||||
|
||||
/**
|
||||
* QueryPathThread is used to determine available command completions
|
||||
*/
|
||||
public class QueryPathThread extends Thread
|
||||
{
|
||||
|
||||
private DataStore _dataStore;
|
||||
private DataElement _status;
|
||||
|
||||
public QueryPathThread(DataElement status)
|
||||
{
|
||||
super();
|
||||
_status = status;
|
||||
_dataStore = status.getDataStore();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
getPossibleCommands(_status);
|
||||
|
||||
}
|
||||
|
||||
public List getPathEnvironment()
|
||||
{
|
||||
DataElement envMinerData = _dataStore.findMinerInformation(EnvironmentMiner.MINER_ID);
|
||||
if (envMinerData != null)
|
||||
{
|
||||
DataElement systemEnvironment = _dataStore.find(envMinerData, DE.A_NAME, "System Environment", 1);
|
||||
if (systemEnvironment != null)
|
||||
{
|
||||
// d54675
|
||||
// for Windows, ignore the case sensitiveness of PATH variable
|
||||
boolean isIgnoreCase = System.getProperty("os.name").toLowerCase().startsWith("win");
|
||||
ArrayList vars = _dataStore.searchForPattern(systemEnvironment, DE.A_NAME, "PATH=*", isIgnoreCase);
|
||||
|
||||
if (vars == null || vars.size() == 0) {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
DataElement pathVariable = (DataElement) vars.get(0);
|
||||
if (pathVariable != null)
|
||||
{
|
||||
String varStr = pathVariable.getValue();
|
||||
int separatorIndex = varStr.indexOf("=");
|
||||
if (separatorIndex > 0)
|
||||
{
|
||||
varStr = varStr.substring(separatorIndex + 1, varStr.length());
|
||||
}
|
||||
|
||||
return parsePathEnvironmentVariable(varStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected List parsePathEnvironmentVariable(String path)
|
||||
{
|
||||
ArrayList addedPaths = new ArrayList();
|
||||
ArrayList addedFolders = new ArrayList();
|
||||
|
||||
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win");
|
||||
char separator = isWindows ? ';' : ':';
|
||||
StringTokenizer tokenizer = new StringTokenizer(path, separator + "");
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
String token = tokenizer.nextToken();
|
||||
if (!addedPaths.contains(token))
|
||||
{
|
||||
addedPaths.add(token);
|
||||
|
||||
File folder = new File(token);
|
||||
if (folder.exists() && folder.isDirectory())
|
||||
{
|
||||
addedFolders.add(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
return addedFolders;
|
||||
}
|
||||
|
||||
public void getPossibleCommands(DataElement status)
|
||||
{
|
||||
List resolvedPaths = new ArrayList();
|
||||
List paths = getPathEnvironment();
|
||||
for (int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
File folder = (File) paths.get(i);
|
||||
String abspath = folder.getAbsolutePath().toLowerCase();
|
||||
if (!resolvedPaths.contains(abspath))
|
||||
{
|
||||
resolveCommandsInPath(folder, status);
|
||||
resolvedPaths.add(abspath);
|
||||
}
|
||||
}
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
_dataStore.refresh(status);
|
||||
}
|
||||
|
||||
private void resolveCommandsInPath(File file, DataElement status)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
File[] files = file.listFiles();
|
||||
for (int i = 0; i < files.length; i++)
|
||||
{
|
||||
File afile = files[i];
|
||||
if (afile.isFile() && !afile.isHidden())
|
||||
{
|
||||
String name = afile.getName();
|
||||
DataElement fileObj = _dataStore.createObject(status, "file", name);
|
||||
fileObj.setAttribute(DE.A_SOURCE, afile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command.patterns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This class represents a command pattern. It contains a list of
|
||||
* output patterns representing the types of output expected from
|
||||
* running a command. CommandPattern is used to produce <code>ParsedOutput</code>,
|
||||
* enabling output interpretation.
|
||||
*/
|
||||
public class CommandPattern
|
||||
{
|
||||
|
||||
|
||||
private Pattern _pattern;
|
||||
private ArrayList _outputPatterns;
|
||||
|
||||
public CommandPattern(Pattern theCommandPattern)
|
||||
{
|
||||
_pattern = theCommandPattern;
|
||||
_outputPatterns = new ArrayList();
|
||||
}
|
||||
|
||||
public String getPattern()
|
||||
{
|
||||
return _pattern.pattern();
|
||||
}
|
||||
|
||||
public void addOutputPattern(OutputPattern op)
|
||||
{
|
||||
_outputPatterns.add(op);
|
||||
}
|
||||
|
||||
public boolean matchCommand(String theLine)
|
||||
{
|
||||
return _pattern.matcher(theLine).matches();
|
||||
}
|
||||
|
||||
public ParsedOutput matchLine(String theLine)
|
||||
{
|
||||
|
||||
int patterns = _outputPatterns.size();
|
||||
ParsedOutput matchedOutput;
|
||||
OutputPattern curPattern;
|
||||
for (int i = 0; i < patterns; i++)
|
||||
{
|
||||
curPattern = (OutputPattern) _outputPatterns.get(i);
|
||||
|
||||
|
||||
matchedOutput = curPattern.matchLine(theLine);
|
||||
|
||||
if (matchedOutput != null)
|
||||
return matchedOutput;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2001, 2006 IBM Corporation and International Business Machines Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command.patterns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class OutputPattern
|
||||
{
|
||||
|
||||
|
||||
private Pattern _pattern;
|
||||
private String _objType;
|
||||
private ArrayList _matchOrder;
|
||||
|
||||
public OutputPattern(String objType, String matchOrder, Pattern thePattern)
|
||||
{
|
||||
_objType = objType;
|
||||
_pattern = thePattern;
|
||||
|
||||
_matchOrder = new ArrayList();
|
||||
//Here we add a dummy first element to the ArrayList, to mimick how the PatternMatcher stores it's
|
||||
//matches (starting with group 1).
|
||||
_matchOrder.add(null);
|
||||
|
||||
int index = 0;
|
||||
int nextSpace = 0;
|
||||
//Walk the matchOrder string parsing out words and adding them to _matchOrder...Could use StringTokenizer
|
||||
//but this seem much simpler.
|
||||
while ((nextSpace = matchOrder.indexOf(" ", index)) > 0)
|
||||
{
|
||||
_matchOrder.add(matchOrder.substring(index, nextSpace).toLowerCase());
|
||||
index = nextSpace;
|
||||
while ((index < matchOrder.length()) && (matchOrder.charAt(index) == ' '))
|
||||
index++;
|
||||
}
|
||||
_matchOrder.add(matchOrder.substring(index, matchOrder.length()).toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
public ParsedOutput matchLine(String theLine)
|
||||
{
|
||||
Matcher matcher = null;
|
||||
try
|
||||
{
|
||||
matcher = _pattern.matcher(theLine);
|
||||
if (!matcher.matches())
|
||||
return null;
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
//Getting an exception here, when theLine is an empty line for some patterns..should probably investigate,
|
||||
//but for now we'll just handle it...
|
||||
return null;
|
||||
}
|
||||
|
||||
String fileString = "";
|
||||
String lineString = "";
|
||||
|
||||
//Groups start at 1 (group 0 is the entire match).
|
||||
for (int i = 1; i < _matchOrder.size(); i++)
|
||||
{
|
||||
String mStr = (String)_matchOrder.get(i);
|
||||
if (mStr.equals("file"))
|
||||
{
|
||||
fileString = matcher.group(i);
|
||||
}
|
||||
else if (mStr.equals("line"))
|
||||
{
|
||||
lineString = matcher.group(i);
|
||||
}
|
||||
}
|
||||
int line = 1;
|
||||
if (lineString.length() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
line = Integer.parseInt(lineString);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return new ParsedOutput(_objType, theLine, fileString, line, 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command.patterns;
|
||||
|
||||
/*
|
||||
* This is a convenience object for storing information parsed out of a line of output.
|
||||
*/
|
||||
public class ParsedOutput
|
||||
{
|
||||
|
||||
|
||||
public String type;
|
||||
public String text;
|
||||
public String file;
|
||||
public int line;
|
||||
public int col;
|
||||
|
||||
public ParsedOutput(String theType, String theText, String theFile, int theLine, int theColumn)
|
||||
{
|
||||
type = theType;
|
||||
text = theText;
|
||||
file = theFile;
|
||||
line = theLine;
|
||||
col = theColumn;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,314 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.command.patterns;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.DataStoreAttributes;
|
||||
|
||||
/**
|
||||
* This class is used for interpretting standard error and standard output.
|
||||
*/
|
||||
public class Patterns
|
||||
{
|
||||
|
||||
private ArrayList _theCommands;
|
||||
private DataStore _dataStore;
|
||||
|
||||
private String _currentCommand = null;
|
||||
private List _currentCommandPatterns = null;
|
||||
|
||||
//private String _previousCommand = null;
|
||||
private long _timeStamp = 0;
|
||||
private File _thePatternsFile;
|
||||
private boolean _isTerminal = false;
|
||||
private String _pluginPath;
|
||||
|
||||
private static String MINERS_PACKAGE = "org.eclipse.rse.services.dstore";
|
||||
private static String PATTERNS_FILE = "patterns.dat";
|
||||
|
||||
// HACK - too late in cycle to deal with version properly - for now this has to be fixed
|
||||
private String _version = "8.0.0";
|
||||
|
||||
public Patterns(DataStore ds)
|
||||
{
|
||||
_dataStore = ds;
|
||||
_theCommands = new ArrayList();
|
||||
_currentCommandPatterns = new ArrayList();
|
||||
_pluginPath = ds.getAttribute(DataStoreAttributes.A_ROOT_PATH);
|
||||
parsePatternsFile();
|
||||
}
|
||||
|
||||
public Patterns(DataStore ds, String pluginsPath)
|
||||
{
|
||||
_dataStore = ds;
|
||||
_theCommands = new ArrayList();
|
||||
_currentCommandPatterns = new ArrayList();
|
||||
_pluginPath = pluginsPath;
|
||||
parsePatternsFile();
|
||||
}
|
||||
|
||||
public void setIsTerminal(boolean isTerminal)
|
||||
{
|
||||
_isTerminal = isTerminal;
|
||||
}
|
||||
|
||||
private String cleanCmdString(String theCommand)
|
||||
{
|
||||
String result = theCommand;
|
||||
|
||||
// for multi commands
|
||||
int semiIndex = result.indexOf(";");
|
||||
if (semiIndex > 0)
|
||||
{
|
||||
result = result.substring(0, semiIndex);
|
||||
}
|
||||
|
||||
// for qualified commands
|
||||
int spaceIndex = result.indexOf(" ");
|
||||
if (spaceIndex > -1)
|
||||
{
|
||||
int slashIndex = result.lastIndexOf("/", spaceIndex);
|
||||
if ((slashIndex > 0))
|
||||
{
|
||||
result = result.substring(slashIndex + 1, result.length());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int slashIndex = result.lastIndexOf("/");
|
||||
if ((slashIndex > 0))
|
||||
{
|
||||
result = result.substring(slashIndex + 1, result.length());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void refresh(String theCommand)
|
||||
{
|
||||
// _previousCommand = _currentCommand;
|
||||
_currentCommand = cleanCmdString(theCommand);
|
||||
_currentCommandPatterns.clear();
|
||||
parsePatternsFile();
|
||||
}
|
||||
|
||||
public void update(String theCommand)
|
||||
{
|
||||
// _previousCommand = _currentCommand;
|
||||
_currentCommand = cleanCmdString(theCommand);
|
||||
_currentCommandPatterns.clear();
|
||||
|
||||
// don't reparse patterns file
|
||||
}
|
||||
|
||||
private File getPatternsFile()
|
||||
{
|
||||
if (_thePatternsFile == null)
|
||||
{
|
||||
|
||||
File thePatternsFile = new File(_pluginPath + "/" + MINERS_PACKAGE + "/" + PATTERNS_FILE);
|
||||
if (!thePatternsFile.exists())
|
||||
{
|
||||
thePatternsFile = new File(_pluginPath + "/" + PATTERNS_FILE);
|
||||
if (!thePatternsFile.exists())
|
||||
{
|
||||
thePatternsFile = new File(_pluginPath + "/" + MINERS_PACKAGE + "_" + _version + "/" + PATTERNS_FILE);
|
||||
|
||||
if (!thePatternsFile.exists())
|
||||
{
|
||||
File parentFile = new File(_pluginPath);
|
||||
if (parentFile.exists())
|
||||
{
|
||||
// now we're really desparate!
|
||||
// search for a file that looks like it
|
||||
File[] files = parentFile.listFiles();
|
||||
for (int i = 0; i < files.length && !thePatternsFile.exists(); i++)
|
||||
{
|
||||
File c = files[i];
|
||||
|
||||
if (c.getName().startsWith(MINERS_PACKAGE))
|
||||
{
|
||||
thePatternsFile = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_thePatternsFile = thePatternsFile;
|
||||
}
|
||||
return _thePatternsFile;
|
||||
}
|
||||
|
||||
private void parsePatternsFile()
|
||||
{
|
||||
if (_dataStore == null)
|
||||
return;
|
||||
|
||||
//Check the timestamp of the patterns.dat file to make sure we need to read it.
|
||||
File thePatternsFile = getPatternsFile();
|
||||
|
||||
long newTimeStamp = 0;
|
||||
if (!thePatternsFile.exists() || ((newTimeStamp = thePatternsFile.lastModified()) == _timeStamp))
|
||||
return;
|
||||
|
||||
_timeStamp = newTimeStamp;
|
||||
|
||||
//If we get here, we are actually going to read\parse the file.
|
||||
try
|
||||
{
|
||||
readPatternsFile(thePatternsFile, DE.ENCODING_UTF_8);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_dataStore.trace(e);
|
||||
_dataStore.trace("failed to load patterns.dat with UTF-8. Trying with native encoding");
|
||||
|
||||
try
|
||||
{
|
||||
readPatternsFile(thePatternsFile, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dataStore.trace(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readPatternsFile(File thePatternsFile, String encoding) throws Exception
|
||||
{
|
||||
FileInputStream fileStream = new FileInputStream(thePatternsFile);
|
||||
InputStreamReader inReader = null;
|
||||
if (encoding == null)
|
||||
{
|
||||
inReader = new InputStreamReader(fileStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
inReader = new InputStreamReader(fileStream, encoding);
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(inReader);
|
||||
|
||||
_theCommands.clear();
|
||||
|
||||
String curLine;
|
||||
CommandPattern curCommand = null;
|
||||
|
||||
//Main Loop that reads each line.
|
||||
while ((curLine = reader.readLine()) != null)
|
||||
{
|
||||
curLine = curLine.trim();
|
||||
//Skip the current line if it is empty or starts with a #
|
||||
if ((curLine.length() == 0) || (curLine.charAt(0) == '#'))
|
||||
continue;
|
||||
|
||||
//Check if this line is the start of a new command section
|
||||
if (curLine.startsWith("command"))
|
||||
{
|
||||
int colon = curLine.indexOf(":");
|
||||
//Check that there is something after the colon
|
||||
if (colon == (curLine.length() - 1))
|
||||
continue;
|
||||
String cmdStr = curLine.substring(colon + 1, curLine.length()).trim();
|
||||
|
||||
Pattern thePattern = Pattern.compile(cmdStr);
|
||||
curCommand = new CommandPattern(thePattern);
|
||||
_theCommands.add(curCommand);
|
||||
}
|
||||
|
||||
//If we get here, the line must be an output pattern
|
||||
else
|
||||
{
|
||||
int firstSpace = curLine.indexOf(" ");
|
||||
int patternWord = curLine.indexOf("pattern");
|
||||
int firstEquals = curLine.indexOf("=");
|
||||
if ((firstEquals == -1) || (firstEquals == (curLine.length() - 1)))
|
||||
continue;
|
||||
String objType = curLine.substring(0, firstSpace);
|
||||
String matchOrder = curLine.substring(firstSpace + 1, patternWord).trim();
|
||||
String patternString = curLine.substring(firstEquals + 1, curLine.length());
|
||||
Pattern thePattern = Pattern.compile(patternString.trim());
|
||||
|
||||
if (curCommand != null)
|
||||
curCommand.addOutputPattern(new OutputPattern(objType, matchOrder, thePattern));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List getCurrentCommandPatterns()
|
||||
{
|
||||
|
||||
if (_currentCommandPatterns.size() == 0)
|
||||
{
|
||||
int commands = _theCommands.size();
|
||||
|
||||
for (int i = 0; i < commands; i++)
|
||||
{
|
||||
CommandPattern curCommand = (CommandPattern) _theCommands.get(i);
|
||||
|
||||
if (curCommand.matchCommand(_currentCommand))
|
||||
{
|
||||
_currentCommandPatterns.add(curCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _currentCommandPatterns;
|
||||
}
|
||||
|
||||
|
||||
public ParsedOutput matchLine(String theLine)
|
||||
{
|
||||
|
||||
CommandPattern curCommand;
|
||||
ParsedOutput matchedOutput = null;
|
||||
|
||||
List cmdPatterns = getCurrentCommandPatterns();
|
||||
for (int i = 0; i < cmdPatterns.size(); i++)
|
||||
{
|
||||
curCommand = (CommandPattern) cmdPatterns.get(i);
|
||||
|
||||
if (curCommand.matchCommand(_currentCommand))
|
||||
{
|
||||
if (_currentCommand.equals("ls") && _isTerminal && !curCommand.getPattern().equals(".*"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
matchedOutput = curCommand.matchLine(theLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedOutput != null)
|
||||
{
|
||||
return matchedOutput;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.environment;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.dstore.core.miners.miner.Miner;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
|
||||
public class EnvironmentMiner extends Miner
|
||||
{
|
||||
public static final String MINER_ID = EnvironmentMiner.class.getName();//"org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner";
|
||||
|
||||
private DataElement _system;
|
||||
|
||||
|
||||
public void load()
|
||||
{
|
||||
getSystemNode();
|
||||
}
|
||||
|
||||
protected ArrayList getDependencies()
|
||||
{
|
||||
ArrayList dependencies = new ArrayList();
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
private DataElement getSystemNode()
|
||||
{
|
||||
if (_system == null)
|
||||
{
|
||||
_system = _dataStore.createObject(_minerData, "Environment Variable", "System Environment");
|
||||
_dataStore.refresh(_minerData);
|
||||
}
|
||||
return _system;
|
||||
}
|
||||
|
||||
public void extendSchema(DataElement schemaRoot)
|
||||
{
|
||||
DataElement envVar = _dataStore.createObjectDescriptor(schemaRoot, "Environment Variable");
|
||||
_dataStore.createReference(envVar, _dataStore.createRelationDescriptor(schemaRoot,"Parent Environment"));
|
||||
DataElement containerObjectD = _dataStore.findObjectDescriptor("Container Object");
|
||||
_dataStore.createReference(containerObjectD, envVar, "abstracts", "abstracted by");
|
||||
|
||||
createCommandDescriptor(containerObjectD, "Set Environment Variables", "C_SET_ENVIRONMENT_VARIABLES", false);
|
||||
createCommandDescriptor(containerObjectD, "Set Environment Variables", "C_SET_ENVIRONMENT_VARIABLES_NO_SYSTEM", false);
|
||||
|
||||
DataElement fsObj = _dataStore.findObjectDescriptor("Filesystem Objects");
|
||||
DataElement inhabits = _dataStore.createRelationDescriptor(schemaRoot, "inhabits");
|
||||
DataElement sustains = _dataStore.createRelationDescriptor(schemaRoot, "sustains");
|
||||
|
||||
_dataStore.createReference(envVar, sustains);
|
||||
_dataStore.createReference(fsObj, inhabits);
|
||||
|
||||
|
||||
/*
|
||||
* DY: Retreive environment values required by user define actions
|
||||
* - temp directory (user.temp)
|
||||
* - user's home directory (user.home)
|
||||
*/
|
||||
DataElement systemInfo = _dataStore.createObject(_minerData, "dstore.structureNode", "systemInfo");
|
||||
|
||||
_dataStore.createObject(systemInfo, "system.property", "user.home", System.getProperty("user.home"));
|
||||
_dataStore.createObject(systemInfo, "system.property", "temp.dir", System.getProperty("java.io.tmpdir"));
|
||||
|
||||
_dataStore.createObject(systemInfo, "system.property", "os.name", System.getProperty("os.name"));
|
||||
_dataStore.createObject(systemInfo, "system.property", "os.version", System.getProperty("os.version"));
|
||||
|
||||
getSystemNode();
|
||||
_dataStore.refresh(_minerData);
|
||||
getSystemEnvironment();
|
||||
}
|
||||
|
||||
public DataElement handleCommand (DataElement theElement)
|
||||
{
|
||||
String name = getCommandName(theElement);
|
||||
DataElement status = getCommandStatus(theElement);
|
||||
DataElement subject = getCommandArgument(theElement, 0);
|
||||
DataElement env = getCommandArgument(theElement, 1);
|
||||
|
||||
|
||||
if (name.equals("C_SET_ENVIRONMENT_VARIABLES"))
|
||||
{
|
||||
if (_system.getNestedSize() == 0)
|
||||
{
|
||||
getSystemEnvironment();
|
||||
}
|
||||
handleSetEnvironment(subject, env);
|
||||
}
|
||||
else if (name.equals("C_SET_ENVIRONMENT_VARIABLES_NO_SYSTEM"))
|
||||
{
|
||||
handleSetEnvironment(subject, env);
|
||||
}
|
||||
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
return status;
|
||||
}
|
||||
|
||||
public void handleSetEnvironment(DataElement theElement, DataElement environment)
|
||||
{
|
||||
String envName = theElement.getValue() + ".env";
|
||||
|
||||
//First check to see if we already have an Environment for theElement..and get rid of it if we do.
|
||||
DataElement envRoot = _dataStore.find(_minerData, DE.A_NAME, envName, 1);
|
||||
if (envRoot != null)
|
||||
{
|
||||
_dataStore.deleteObject(_minerData, envRoot);
|
||||
_dataStore.refresh(_minerData);
|
||||
List theReferences = theElement.getAssociated("inhabits");
|
||||
if (theReferences.size() > 0)
|
||||
{
|
||||
_dataStore.deleteObject(theElement, (DataElement)theReferences.get(0));
|
||||
_dataStore.refresh(theElement);
|
||||
}
|
||||
}
|
||||
|
||||
environment.setAttribute(DE.A_NAME, envName);
|
||||
environment.setAttribute(DE.A_VALUE, envName);
|
||||
|
||||
_minerData.addNestedData(environment, false);
|
||||
environment.setParent(_minerData);
|
||||
_dataStore.refresh(_minerData);
|
||||
_dataStore.createReference(theElement, environment, "inhabits", "sustains");
|
||||
_dataStore.refresh(environment);
|
||||
_dataStore.refresh(theElement);
|
||||
}
|
||||
|
||||
//This sucks, but the best way to get the current list of environment variables is to run the "env" (or "set" on
|
||||
//windows), and grab the output. Can't use System.properties since this list only includes environment variables
|
||||
//that you passed in as parameters when you started the VM.
|
||||
private void getSystemEnvironment()
|
||||
{
|
||||
|
||||
String envCommand = "sh -c env";
|
||||
|
||||
String theOS = System.getProperty("os.name").toLowerCase();
|
||||
//If we're on windows, change the envCommand.
|
||||
if (theOS.startsWith("win"))
|
||||
envCommand = "cmd /c set";
|
||||
|
||||
if (theOS.startsWith("os/400"))
|
||||
{
|
||||
envCommand = "/QOpenSys/usr/bin/sh -c env";
|
||||
}
|
||||
|
||||
String specialEncoding= System.getProperty("dstore.stdin.encoding");
|
||||
try
|
||||
{
|
||||
Process _process = Runtime.getRuntime().exec(envCommand);
|
||||
|
||||
BufferedReader _output = null;
|
||||
if (specialEncoding != null)
|
||||
{
|
||||
_output = new BufferedReader(new InputStreamReader(_process.getInputStream(), specialEncoding));
|
||||
}
|
||||
else
|
||||
{
|
||||
_output = new BufferedReader(new InputStreamReader(_process.getInputStream()));
|
||||
}
|
||||
|
||||
String curLine;
|
||||
while ( (curLine = _output.readLine()) != null)
|
||||
{
|
||||
int eqIndex = curLine.indexOf("=");
|
||||
if (eqIndex > 0)
|
||||
{
|
||||
if (curLine.indexOf("=()") > 0)
|
||||
{
|
||||
String multiLine =new String(curLine);
|
||||
|
||||
if (!curLine.endsWith("}"))
|
||||
{
|
||||
boolean complete = false;
|
||||
String subLine = null;
|
||||
while (!complete && (subLine = _output.readLine()) != null)
|
||||
{
|
||||
multiLine += subLine;
|
||||
if (subLine.indexOf('}') > -1)
|
||||
{
|
||||
complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//String name = curLine.substring(0, eqIndex);
|
||||
DataElement var = _dataStore.createObject(_system, "Environment Variable", curLine, multiLine);
|
||||
var.setAttribute(DE.A_VALUE, multiLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (curLine.startsWith("PATH="))
|
||||
{
|
||||
curLine += ":.";
|
||||
}
|
||||
_dataStore.createObject(_system, "Environment Variable", curLine, curLine);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
_dataStore.refresh(_system);
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.err.println("Error getting System Environment Variables\n" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return "6.4.0";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.filesystem;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ClassFileParser {
|
||||
|
||||
|
||||
private static final int CONSTANT_Class = 7;
|
||||
private static final int CONSTANT_Fieldref = 9;
|
||||
private static final int CONSTANT_Methodref = 10;
|
||||
private static final int CONSTANT_InterfaceMethodref = 11;
|
||||
private static final int CONSTANT_String = 8;
|
||||
private static final int CONSTANT_Integer = 3;
|
||||
private static final int CONSTANT_Float = 4;
|
||||
private static final int CONSTANT_Long = 5;
|
||||
private static final int CONSTANT_Double = 6;
|
||||
private static final int CONSTANT_NameAndType = 12;
|
||||
private static final int CONSTANT_Utf8 = 1;
|
||||
|
||||
private DataInputStream in;
|
||||
|
||||
private ArrayList classes = new ArrayList();
|
||||
private ArrayList utf8s = new ArrayList();
|
||||
|
||||
private class _Class {
|
||||
public int pool_index;
|
||||
public int name_index;
|
||||
|
||||
public _Class(int pIndx, int nIndx) {
|
||||
pool_index = pIndx;
|
||||
name_index = nIndx;
|
||||
}
|
||||
}
|
||||
|
||||
private class _Utf8 {
|
||||
public int pool_index;
|
||||
public byte[] bytes;
|
||||
|
||||
public _Utf8(int pIndx, byte[] bytes) {
|
||||
pool_index = pIndx;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ClassFileParser(InputStream stream)
|
||||
{
|
||||
in = new DataInputStream(stream);
|
||||
}
|
||||
|
||||
public String getPackageName()
|
||||
{
|
||||
String packageName = null;
|
||||
try {
|
||||
// Skip magic / miner / major
|
||||
in.skipBytes(8);
|
||||
|
||||
int constPoolCount = in.readUnsignedShort();
|
||||
|
||||
// Read in the constant_pool storing Class and Utf8 entries
|
||||
int tag;
|
||||
int index;
|
||||
int len;
|
||||
byte[] data;
|
||||
for (int loop = 1; loop < constPoolCount; loop++) {
|
||||
tag = in.readUnsignedByte();
|
||||
switch (tag) {
|
||||
case CONSTANT_Class:
|
||||
index = in.readUnsignedShort();
|
||||
classes.add(new _Class(loop, index));
|
||||
break;
|
||||
|
||||
case CONSTANT_Utf8:
|
||||
len = in.readUnsignedShort();
|
||||
data = new byte[len];
|
||||
in.read(data, 0, len);
|
||||
utf8s.add(new _Utf8(loop, data));
|
||||
break;
|
||||
|
||||
case CONSTANT_Fieldref:
|
||||
case CONSTANT_Methodref:
|
||||
case CONSTANT_InterfaceMethodref:
|
||||
case CONSTANT_Integer:
|
||||
case CONSTANT_Float:
|
||||
case CONSTANT_NameAndType:
|
||||
in.skipBytes(4);
|
||||
break;
|
||||
|
||||
case CONSTANT_String:
|
||||
in.skipBytes(2);
|
||||
break;
|
||||
|
||||
case CONSTANT_Long:
|
||||
case CONSTANT_Double:
|
||||
in.skipBytes(8);
|
||||
// these take two entries in constant pool
|
||||
loop++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip access flags
|
||||
in.skipBytes(2);
|
||||
int classNameIndex = in.readUnsignedShort();
|
||||
|
||||
boolean found = false;
|
||||
int utf8Index = -1;
|
||||
for(int loop = 0; loop < classes.size() && !found; loop++) {
|
||||
if (((_Class)classes.get(loop)).pool_index == classNameIndex) {
|
||||
found = true;
|
||||
utf8Index = ((_Class)classes.get(loop)).name_index;
|
||||
}
|
||||
}
|
||||
|
||||
found = false;
|
||||
for (int loop = 0; loop < utf8s.size() && !found; loop++) {
|
||||
if (((_Utf8)utf8s.get(loop)).pool_index == utf8Index) {
|
||||
packageName = new String(((_Utf8)utf8s.get(loop)).bytes);
|
||||
packageName = packageName.replace('/', '.');
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return packageName;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,348 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.filesystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import org.eclipse.dstore.core.model.ByteStreamHandler;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.rse.services.clientserver.IClientServerConstants;
|
||||
import org.eclipse.rse.services.clientserver.IServiceConstants;
|
||||
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class overrides ByteStreamHandler to handle cases where
|
||||
* virtual files are being transfered to the host
|
||||
*/
|
||||
public class UniversalByteStreamHandler extends ByteStreamHandler
|
||||
{
|
||||
|
||||
public UniversalByteStreamHandler(DataStore dataStore, DataElement log)
|
||||
{
|
||||
super(dataStore, log);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save a file in the specified location. This method is called by the
|
||||
* DataStore when the communication layer receives a file transfer
|
||||
*
|
||||
* @param remotePath the path where to save the file
|
||||
* @param buffer the bytes to insert in the file
|
||||
* @param size the number of bytes to insert
|
||||
* @param binary indicates whether to save the bytes as binary or text
|
||||
*/
|
||||
public void receiveBytes(String remotePath, byte[] buffer, int size, boolean binary)
|
||||
{
|
||||
boolean isVirtual = ArchiveHandlerManager.isVirtual(remotePath);
|
||||
|
||||
if (!isVirtual)
|
||||
{
|
||||
super.receiveBytes(remotePath, buffer, size, binary);
|
||||
return;
|
||||
}
|
||||
|
||||
remotePath = ArchiveHandlerManager.cleanUpVirtualPath(remotePath);
|
||||
DataElement status = findStatusFor(remotePath);
|
||||
String fileName = _dataStore.mapToLocalPath(remotePath);
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
String virtualFileName = fileName;
|
||||
|
||||
ArchiveHandlerManager mgr = ArchiveHandlerManager.getInstance();
|
||||
VirtualChild child = mgr.getVirtualObject(virtualFileName);
|
||||
ISystemArchiveHandler handler = child.getHandler();
|
||||
|
||||
try
|
||||
{
|
||||
File file = child.getExtractedFile();
|
||||
fileName = file.getAbsolutePath();
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
File parent = new File(file.getParent());
|
||||
parent.mkdirs();
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
File newFile = new File(fileName);
|
||||
FileOutputStream fileStream = new FileOutputStream(newFile);
|
||||
|
||||
if (binary)
|
||||
{
|
||||
fileStream.write(buffer, 0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
String bufferString = new String(buffer, 0, size, SystemEncodingUtil.ENCODING_UTF_8);
|
||||
|
||||
// hack for zOS
|
||||
String theOS = System.getProperty("os.name");
|
||||
if (theOS.toLowerCase().startsWith("z"))
|
||||
{
|
||||
bufferString = bufferString.replace('\r', ' ');
|
||||
}
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(fileStream);
|
||||
writer.write(bufferString, 0, size);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
|
||||
// write the temp file to the archive
|
||||
if (handler == null)
|
||||
{
|
||||
int virtualIndex = virtualFileName.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR);
|
||||
String filePath = virtualFileName.substring(0, virtualIndex);
|
||||
handler = mgr.getRegisteredHandler(new File(filePath));
|
||||
}
|
||||
boolean success = handler != null && handler.add(newFile, child.path, child.name);
|
||||
if (!success)
|
||||
{
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_VALUE, IClientServerConstants.FILEMSG_REMOTE_SAVE_FAILED);
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_dataStore.trace(e);
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_VALUE, IClientServerConstants.FILEMSG_REMOTE_SAVE_FAILED);
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_dataStore.trace(e);
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_VALUE, IClientServerConstants.FILEMSG_REMOTE_SAVE_FAILED);
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a bytes to a file at a specified location. This method is called by the
|
||||
* DataStore when the communication layer receives a file transfer append.
|
||||
*
|
||||
* @param remotePath the path where to save the file
|
||||
* @param buffer the bytes to append in the file
|
||||
* @param size the number of bytes to append in the file
|
||||
* @param binary indicates whether to save the bytes as binary or text
|
||||
*/
|
||||
public void receiveAppendedBytes(String remotePath, byte[] buffer, int size, boolean binary)
|
||||
{
|
||||
|
||||
boolean isVirtual = ArchiveHandlerManager.isVirtual(remotePath);
|
||||
if (!isVirtual)
|
||||
{
|
||||
super.receiveAppendedBytes(remotePath, buffer, size, binary);
|
||||
return;
|
||||
}
|
||||
|
||||
remotePath = ArchiveHandlerManager.cleanUpVirtualPath(remotePath);
|
||||
DataElement status = findStatusFor(remotePath);
|
||||
String fileName = _dataStore.mapToLocalPath(remotePath);
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
String virtualFileName = fileName;
|
||||
|
||||
ArchiveHandlerManager mgr = ArchiveHandlerManager.getInstance();
|
||||
VirtualChild child = mgr.getVirtualObject(virtualFileName);
|
||||
if (!child.exists())
|
||||
{
|
||||
System.out.println(virtualFileName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
ISystemArchiveHandler handler = child.getHandler();
|
||||
|
||||
try
|
||||
{
|
||||
boolean success;
|
||||
|
||||
File file = child.getExtractedFile();
|
||||
fileName = file.getAbsolutePath();
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
File parent = new File(file.getParent());
|
||||
parent.mkdirs();
|
||||
|
||||
File newFile = new File(fileName);
|
||||
FileOutputStream fileStream = new FileOutputStream(newFile);
|
||||
|
||||
//boolean binary = false;
|
||||
if (binary)
|
||||
{
|
||||
fileStream.write(buffer, 0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
String bufferString = new String(buffer, 0, size, SystemEncodingUtil.ENCODING_UTF_8);
|
||||
|
||||
// hack for zOS
|
||||
String theOS = System.getProperty("os.name");
|
||||
if (theOS.toLowerCase().startsWith("z"))
|
||||
{
|
||||
bufferString = bufferString.replace('\r', ' ');
|
||||
}
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(fileStream);
|
||||
writer.write(bufferString, 0, size);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
// write the temp file to the archive
|
||||
if (handler == null)
|
||||
{
|
||||
int virtualIndex = virtualFileName.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR);
|
||||
String filePath = virtualFileName.substring(0, virtualIndex);
|
||||
handler = mgr.getRegisteredHandler(new File(filePath));
|
||||
}
|
||||
success = handler != null && handler.add(newFile, child.path, child.name);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to reorganize this so that we don't use up all the memory
|
||||
// divide appendedBuffer into chunks
|
||||
// at > 50M this kills Eclipse
|
||||
File oldFile = new File(fileName);
|
||||
File newFile = new File(fileName + ".new");
|
||||
newFile.createNewFile();
|
||||
|
||||
FileInputStream oldFileStream = new FileInputStream(oldFile);
|
||||
FileOutputStream newFileStream = new FileOutputStream(newFile);
|
||||
|
||||
// write old file to new file
|
||||
int maxSize = 5000000;
|
||||
int written = 0;
|
||||
int oldSize = (int) oldFile.length();
|
||||
int bufferSize = (oldSize > maxSize) ? maxSize : oldSize;
|
||||
byte[] subBuffer = new byte[bufferSize];
|
||||
|
||||
while (written < oldSize)
|
||||
{
|
||||
int subWritten = 0;
|
||||
|
||||
while (written < oldSize && subWritten < bufferSize)
|
||||
{
|
||||
int available = oldFileStream.available();
|
||||
available = (bufferSize > available) ? available : bufferSize;
|
||||
int read = oldFileStream.read(subBuffer, subWritten, available);
|
||||
subWritten += read;
|
||||
written += subWritten;
|
||||
}
|
||||
|
||||
newFileStream.write(subBuffer, 0, subWritten);
|
||||
}
|
||||
|
||||
oldFileStream.close();
|
||||
|
||||
// write new buffer to new file
|
||||
if (binary)
|
||||
{
|
||||
newFileStream.write(buffer, 0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
String bufferString = new String(buffer, 0, size, SystemEncodingUtil.ENCODING_UTF_8);
|
||||
|
||||
// hack for zOS
|
||||
String theOS = System.getProperty("os.name");
|
||||
if (theOS.toLowerCase().startsWith("z"))
|
||||
{
|
||||
bufferString = bufferString.replace('\r', ' ');
|
||||
}
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(newFileStream);
|
||||
writer.write(bufferString, 0, size);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
newFileStream.close();
|
||||
|
||||
// remote old file
|
||||
oldFile.delete();
|
||||
|
||||
// rename new file
|
||||
newFile.renameTo(oldFile);
|
||||
|
||||
// write the temp file to the archive
|
||||
if (handler == null)
|
||||
{
|
||||
int virtualIndex = virtualFileName.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR);
|
||||
String filePath = virtualFileName.substring(0, virtualIndex);
|
||||
handler = mgr.getRegisteredHandler(new File(filePath));
|
||||
}
|
||||
success = handler != null && handler.add(newFile, child.path, child.name);
|
||||
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_VALUE, IClientServerConstants.FILEMSG_REMOTE_SAVE_FAILED);
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_dataStore.trace(e);
|
||||
if (status == null) return;
|
||||
status.setAttribute(DE.A_VALUE, IClientServerConstants.FILEMSG_REMOTE_SAVE_FAILED);
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
_dataStore.refresh(status.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.filesystem;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IByteConverter;
|
||||
import org.eclipse.rse.dstore.universal.miners.ICancellableHandler;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
|
||||
import org.eclipse.rse.services.clientserver.IServiceConstants;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
|
||||
|
||||
|
||||
public class UniversalDownloadHandler extends Thread implements ICancellableHandler
|
||||
{
|
||||
|
||||
private boolean _isDone = false;
|
||||
private DataStore _dataStore;
|
||||
private UniversalFileSystemMiner _miner;
|
||||
private DataElement _status;
|
||||
private DataElement _cmdElement;
|
||||
private boolean _isCancelled= false;
|
||||
|
||||
public UniversalDownloadHandler(DataStore dataStore, UniversalFileSystemMiner miner, DataElement cmdElement, DataElement status)
|
||||
{
|
||||
_miner = miner;
|
||||
_dataStore = dataStore;
|
||||
_status = status;
|
||||
_cmdElement = cmdElement;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
handleDownload(_cmdElement, _status);
|
||||
_isDone = true;
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
public void cancel()
|
||||
{
|
||||
_dataStore.trace("cancelling download");
|
||||
_isCancelled = true;
|
||||
}
|
||||
|
||||
|
||||
protected DataElement handleDownload(DataElement theElement, DataElement status)
|
||||
{
|
||||
DataElement arg1 = _miner.getCommandArgument(theElement, 1);
|
||||
String elementType = arg1.getType();
|
||||
String remotePath = arg1.getName();
|
||||
|
||||
int buffer_size = IUniversalDataStoreConstants.BUFFER_SIZE;
|
||||
DataElement bufferSizeElement = _dataStore.find(theElement, DE.A_TYPE, "buffer_size", 1);
|
||||
if (bufferSizeElement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
buffer_size = Integer.parseInt(bufferSizeElement.getName());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
String resultType = null;
|
||||
String resultMessage = null;
|
||||
|
||||
|
||||
FileInputStream inputStream = null;
|
||||
BufferedInputStream bufInputStream = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (elementType.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || elementType.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR) || elementType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR))
|
||||
{
|
||||
|
||||
_dataStore.trace("download:" + remotePath + "," + elementType);
|
||||
|
||||
File file = new File(remotePath);
|
||||
|
||||
|
||||
if (elementType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR))
|
||||
{
|
||||
AbsoluteVirtualPath vpath = _miner.getAbsoluteVirtualPath(remotePath);
|
||||
|
||||
ISystemArchiveHandler handler = _miner.getArchiveHandlerFor(vpath.getContainingArchiveString());
|
||||
if (handler == null)
|
||||
{
|
||||
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION;
|
||||
resultMessage = "Corrupted archive.";
|
||||
_isDone = true;
|
||||
_dataStore.createObject(arg1, resultType, resultMessage);
|
||||
_dataStore.refresh(arg1);
|
||||
return _miner.statusDone(status);
|
||||
}
|
||||
VirtualChild vChild = handler.getVirtualFile(vpath.getVirtualPart());
|
||||
file = vChild.getExtractedFile();
|
||||
|
||||
}
|
||||
|
||||
DataElement arg2 = _miner.getCommandArgument(theElement, 2);
|
||||
DataElement arg3 = _miner.getCommandArgument(theElement, 3);
|
||||
|
||||
int mode = (Integer.valueOf(arg1.getSource())).intValue();
|
||||
String localPath = arg2.getName();
|
||||
|
||||
boolean isText = (mode == IUniversalDataStoreConstants.TEXT_MODE);
|
||||
|
||||
String clientEncoding = null;
|
||||
|
||||
if (isText)
|
||||
{
|
||||
clientEncoding = arg2.getSource();
|
||||
}
|
||||
|
||||
// Read in the file
|
||||
inputStream = new FileInputStream(file);
|
||||
bufInputStream = new BufferedInputStream(inputStream, buffer_size);
|
||||
|
||||
int totalBytes = (int)file.length();
|
||||
int totalWritten = 0;
|
||||
|
||||
boolean first = true;
|
||||
byte[] buffer = new byte[buffer_size];
|
||||
byte[] convBytes;
|
||||
int numToRead = 0;
|
||||
|
||||
IByteConverter byteConverter = _dataStore.getByteConverter();
|
||||
byteConverter.setContext(file);
|
||||
|
||||
int available = bufInputStream.available();
|
||||
|
||||
while (available > 0 && !_isCancelled)
|
||||
{
|
||||
numToRead = (available < buffer_size) ? available : buffer_size;
|
||||
|
||||
int bytesRead = bufInputStream.read(buffer, 0, numToRead);
|
||||
|
||||
if (bytesRead == -1)
|
||||
break;
|
||||
if (isText)
|
||||
{
|
||||
convBytes = byteConverter.convertHostBytesToClientBytes(buffer, 0, bytesRead);
|
||||
|
||||
if (first)
|
||||
{ // send first set of bytes
|
||||
first = false;
|
||||
_dataStore.updateFile(localPath, convBytes, convBytes.length, true);
|
||||
}
|
||||
else
|
||||
{ // append subsequent segments
|
||||
_dataStore.updateAppendFile(localPath, convBytes, convBytes.length, true);
|
||||
}
|
||||
totalWritten += convBytes.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (first)
|
||||
{ // send first set of bytes
|
||||
first = false;
|
||||
_dataStore.updateFile(localPath, buffer, bytesRead, true);
|
||||
}
|
||||
else
|
||||
{ // append subsequent segments
|
||||
_dataStore.updateAppendFile(localPath, buffer, bytesRead, true);
|
||||
}
|
||||
totalWritten +=bytesRead;
|
||||
}
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, "sent "+totalWritten + " of "+totalBytes);
|
||||
_dataStore.refresh(status);
|
||||
available = bufInputStream.available();
|
||||
}
|
||||
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_TYPE;
|
||||
resultMessage = IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_MESSAGE;
|
||||
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "handleDownload: error reading file " + remotePath, e);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION;
|
||||
resultMessage = e.getLocalizedMessage();
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "handleDownload: error reading file " + remotePath, e);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION;
|
||||
resultMessage = e.getLocalizedMessage();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "handleDownload: error reading file " + remotePath, e);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION;
|
||||
resultMessage = e.getLocalizedMessage();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "handleDownload: error reading file " + remotePath, e);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_EXCEPTION;
|
||||
resultMessage = e.getLocalizedMessage();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (bufInputStream != null)
|
||||
bufInputStream.close();
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "handleDownload: error closing reader on " + remotePath, e);
|
||||
resultType = IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION;
|
||||
resultMessage = e.getMessage();
|
||||
}
|
||||
}
|
||||
_isDone = true;
|
||||
|
||||
_dataStore.createObject(arg1, resultType, resultMessage);
|
||||
_dataStore.refresh(arg1);
|
||||
|
||||
return _miner.statusDone(status);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.filesystem;
|
||||
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||
import org.eclipse.rse.services.clientserver.IClientServerConstants;
|
||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
|
||||
|
||||
public class UniversalFileSystemFilter implements java.io.FilenameFilter, IUniversalDataStoreConstants, IClientServerConstants{
|
||||
|
||||
|
||||
protected String filter;
|
||||
protected boolean allowDirs;
|
||||
protected boolean allowFiles;
|
||||
protected boolean caseSensitive = true;
|
||||
protected IMatcher matcher = null;
|
||||
protected NamePatternMatcher folderNameMatcher = null;
|
||||
protected int includeFilesOrFolders;
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* Creation date: (2/22/01 1:15:54 PM)
|
||||
* @param filter java.lang.String
|
||||
*/
|
||||
public UniversalFileSystemFilter(String fString, boolean files, boolean folders, boolean caseSensitive) {
|
||||
this.filter = fString;
|
||||
this.allowFiles = files;
|
||||
this.allowDirs = folders;
|
||||
this.caseSensitive = caseSensitive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a specified file should be included in a file list.
|
||||
*
|
||||
* @param dir the directory in which the file was found.
|
||||
* @param name the name of the file.
|
||||
* @return <code>true</code> if and only if the name should be
|
||||
* included in the file list; <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean accept(java.io.File dir, String nameFilter) {
|
||||
|
||||
boolean match = true;
|
||||
java.io.File file = new java.io.File(dir, nameFilter);
|
||||
if (!allowDirs && file.isDirectory())
|
||||
return false;
|
||||
|
||||
if (allowDirs && (file.isDirectory() || ArchiveHandlerManager.getInstance().isArchive(file)))
|
||||
return true;
|
||||
|
||||
if (!allowFiles && file.isFile())
|
||||
return false;
|
||||
|
||||
if (allowDirs && allowFiles)
|
||||
setListValues(INCLUDE_ALL, filter);
|
||||
else if (allowDirs)
|
||||
setListValues(INCLUDE_FOLDERS_ONLY, filter);
|
||||
else if (allowFiles)
|
||||
setListValues(INCLUDE_FILES_ONLY, filter);
|
||||
else
|
||||
return false;
|
||||
|
||||
if ((matcher == null) && (folderNameMatcher == null))
|
||||
return true;
|
||||
if (includeFilesOrFolders != INCLUDE_ALL)
|
||||
match = matcher.matches(nameFilter);
|
||||
else {
|
||||
if (file.isFile()) {
|
||||
if (matcher!=null)
|
||||
match = matcher.matches(nameFilter);
|
||||
} else {
|
||||
if (folderNameMatcher!=null)
|
||||
match = folderNameMatcher.matches(nameFilter);
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
protected void setListValues(int includeFilesOrFolders, String nameFilter)
|
||||
{
|
||||
this.includeFilesOrFolders = includeFilesOrFolders;
|
||||
if ((nameFilter!=null) && !nameFilter.equals("*"))
|
||||
{
|
||||
if (nameFilter.endsWith(","))
|
||||
matcher = new FileTypeMatcher(FileTypeMatcher.parseTypes(nameFilter), true);
|
||||
else
|
||||
matcher = new NamePatternMatcher(nameFilter, true, caseSensitive);
|
||||
}
|
||||
else
|
||||
matcher = null;
|
||||
folderNameMatcher = null;
|
||||
}
|
||||
/**
|
||||
* Overloaded method to set variables to affect the folder content subsetting,
|
||||
* when there is separate filters for both folder names and filter names.
|
||||
* @param includeFilesOrFolders A constant from {IFileConstants}
|
||||
* @param folderNameFilter The pattern to filter the folder names by. Can be null to include all folders
|
||||
* @param nameFilter The pattern to filter the file names by. Can be null to include all files
|
||||
*/
|
||||
protected void setListValues(int includeFilesOrFolders, String folderNameFilter, String fileNameFilter)
|
||||
{
|
||||
setListValues(includeFilesOrFolders, fileNameFilter);
|
||||
if ((folderNameFilter!=null) && !folderNameFilter.equals("*"))
|
||||
folderNameMatcher = new NamePatternMatcher(folderNameFilter, true, caseSensitive);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,382 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.filesystem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.util.StringCompare;
|
||||
import org.eclipse.rse.dstore.universal.miners.ICancellableHandler;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
|
||||
import org.eclipse.rse.services.clientserver.SystemFileClassifier;
|
||||
import org.eclipse.rse.services.clientserver.SystemSearchString;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
|
||||
import org.eclipse.rse.services.clientserver.search.SystemSearchFileNameMatcher;
|
||||
import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch;
|
||||
import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatchLocator;
|
||||
import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher;
|
||||
|
||||
public class UniversalSearchHandler extends Thread implements ICancellableHandler
|
||||
{
|
||||
protected HashSet _alreadySearched;
|
||||
|
||||
private File _rootFile;
|
||||
|
||||
protected boolean _isCancelled;
|
||||
protected boolean _isDone;
|
||||
protected int _depth = -1;
|
||||
|
||||
protected DataStore _dataStore;
|
||||
protected UniversalFileSystemMiner _miner;
|
||||
protected DataElement _status;
|
||||
|
||||
protected SystemSearchString _searchString;
|
||||
protected SystemSearchStringMatcher _stringMatcher;
|
||||
protected boolean _isFileSearch;
|
||||
protected SystemSearchFileNameMatcher _fileNameMatcher;
|
||||
protected String _classificationString;
|
||||
|
||||
protected DataElement _deGrep;
|
||||
protected DataElement _deFile;
|
||||
protected DataElement _deFolder;
|
||||
protected DataElement _deArchiveFile;
|
||||
protected DataElement _deVirtualFile;
|
||||
|
||||
protected boolean _fsCaseSensitive;
|
||||
|
||||
public UniversalSearchHandler(DataStore dataStore, UniversalFileSystemMiner miner, SystemSearchString searchString, boolean fsCaseSensitive, File theFile, DataElement status) {
|
||||
_dataStore = dataStore;
|
||||
_miner = miner;
|
||||
_searchString = searchString;
|
||||
_fsCaseSensitive = fsCaseSensitive;
|
||||
_alreadySearched = new HashSet();
|
||||
|
||||
_deGrep = _dataStore.findObjectDescriptor("grep");
|
||||
_deFile = _dataStore.findObjectDescriptor(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR);
|
||||
_deFolder = _dataStore.findObjectDescriptor(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR);
|
||||
_deArchiveFile = _dataStore.findObjectDescriptor(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR);
|
||||
_deVirtualFile = _dataStore.findObjectDescriptor(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR);
|
||||
boolean includeSubfolders = searchString.isIncludeSubfolders();
|
||||
|
||||
if (includeSubfolders) {
|
||||
_depth = -1;
|
||||
}
|
||||
else {
|
||||
_depth = 1;
|
||||
}
|
||||
|
||||
_rootFile = theFile;
|
||||
_status = status;
|
||||
|
||||
_isCancelled = false;
|
||||
_isDone = false;
|
||||
|
||||
_stringMatcher = new SystemSearchStringMatcher(_searchString.getTextString(), _searchString.isCaseSensitive(), _searchString.isTextStringRegex());
|
||||
|
||||
// if the search string is empty or if it is an asterisk, then we are doing a file search
|
||||
// i.e. we do not want to look inside files
|
||||
_isFileSearch = _stringMatcher.isSearchStringEmpty() || _stringMatcher.isSearchStringAsterisk();
|
||||
|
||||
_fileNameMatcher = new SystemSearchFileNameMatcher(_searchString.getFileNamesString(), fsCaseSensitive, _searchString.isFileNamesRegex());
|
||||
|
||||
// classification of files to restrict the search to
|
||||
_classificationString = _searchString.getClassificationString();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
internalSearch(_rootFile, _depth);
|
||||
}
|
||||
catch (Exception e) {
|
||||
UniversalServerUtilities.logError(_miner.getName(), "Error occured when calling internal search", e);
|
||||
}
|
||||
|
||||
_isDone = true;
|
||||
|
||||
if (_isCancelled) {
|
||||
_miner.statusCancelled(_status);
|
||||
}
|
||||
else {
|
||||
// NOTE: do not call miner statusDone() method since we want to
|
||||
// update the status immediately.
|
||||
// Otherwise we don't get an event on the client corresponding
|
||||
// to status refresh. As a result client thinks
|
||||
// search isn't finished.
|
||||
// _miner.statusDone(_status);
|
||||
_status.setAttribute(DE.A_NAME, "done");
|
||||
_dataStore.refresh(_status, true); // true indicates refresh immediately
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
_isCancelled = true;
|
||||
}
|
||||
|
||||
protected boolean hasSearchedDirectory(File file) {
|
||||
return _alreadySearched.contains(file);
|
||||
}
|
||||
|
||||
protected void internalSearch(File theFile, int depth) {
|
||||
|
||||
// is it a directory?
|
||||
boolean isDirectory = theFile.isDirectory();
|
||||
|
||||
// is it an archive?
|
||||
boolean isArchive = ArchiveHandlerManager.getInstance().isArchive(theFile);
|
||||
|
||||
String absPath = theFile.getAbsolutePath();
|
||||
String compareStr = theFile.getName();
|
||||
|
||||
// is it a virtual file?
|
||||
boolean isVirtual = ArchiveHandlerManager.isVirtual(absPath);
|
||||
|
||||
// is it a virtual directory?
|
||||
boolean isVirtualDirectory = false;
|
||||
|
||||
// if it is a virtual object, then get a reference to it
|
||||
if (isVirtual) {
|
||||
VirtualChild vc = ArchiveHandlerManager.getInstance().getVirtualObject(absPath);
|
||||
isVirtualDirectory = isVirtual && vc.isDirectory;
|
||||
}
|
||||
|
||||
// base case for the recursive method call
|
||||
// if the file is not a directory, an archive or a virtual directory,
|
||||
// and we get a match with the file name, then we can search for match within the file
|
||||
if (!isDirectory &&
|
||||
(!isArchive || _isFileSearch) &&
|
||||
!isVirtualDirectory &&
|
||||
doesFilePatternMatch(compareStr) &&
|
||||
doesClassificationMatch(absPath))
|
||||
{
|
||||
DataElement deObj = null;
|
||||
|
||||
// if the file is a virtual file, then get matches from the archive handler
|
||||
if (ArchiveHandlerManager.isVirtual(absPath)) {
|
||||
VirtualChild vc = ArchiveHandlerManager.getInstance().getVirtualObject(absPath);
|
||||
|
||||
if (!vc.isDirectory) {
|
||||
deObj = _dataStore.createObject(null, _deVirtualFile, compareStr);
|
||||
|
||||
// if parent of virtual child is archive, then create it this way
|
||||
if (vc.path.equals("")) {
|
||||
deObj.setAttribute(DE.A_VALUE, vc.getContainingArchive().getAbsolutePath());
|
||||
}
|
||||
else {
|
||||
deObj.setAttribute(DE.A_VALUE, vc.getContainingArchive().getAbsolutePath() +
|
||||
ArchiveHandlerManager.VIRTUAL_SEPARATOR + vc.path);
|
||||
}
|
||||
|
||||
deObj.setAttribute(DE.A_SOURCE, _miner.setProperties(vc));
|
||||
|
||||
SystemSearchLineMatch[] results = null;
|
||||
|
||||
// if it's not a file search, call the handler method to search
|
||||
if (!_isFileSearch) {
|
||||
results = vc.getHandler().search(vc.fullName, _stringMatcher);
|
||||
|
||||
// if at least one match found, then send back the remote file with matches
|
||||
if (results != null && results.length > 0) {
|
||||
convert(deObj, absPath, results);
|
||||
deObj.setParent(_status);
|
||||
_status.addNestedData(deObj, false);
|
||||
}
|
||||
}
|
||||
// otherwise if it is a file search, return the remote file back with no children
|
||||
else {
|
||||
deObj.setParent(_status);
|
||||
_status.addNestedData(deObj, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise, search the file
|
||||
else {
|
||||
|
||||
if (!isArchive) {
|
||||
deObj = _dataStore.createObject(null, _deFile, compareStr);
|
||||
}
|
||||
else {
|
||||
deObj = _dataStore.createObject(null, _deArchiveFile, compareStr);
|
||||
}
|
||||
|
||||
deObj.setAttribute(DE.A_VALUE, theFile.getParentFile().getAbsolutePath());
|
||||
deObj.setAttribute(DE.A_SOURCE, _miner.setProperties(theFile));
|
||||
|
||||
// if it is a file search, we send the remote file back
|
||||
// otherwise search within the file and see if there is at least one match
|
||||
if (_isFileSearch || internalSearchWithinFile(deObj, absPath, theFile)) {
|
||||
deObj.setParent(_status);
|
||||
_status.addNestedData(deObj, false);
|
||||
}
|
||||
}
|
||||
|
||||
// do a refresh
|
||||
_dataStore.refresh(_status, true);
|
||||
}
|
||||
|
||||
// if the depth is not 0, then we need to recursively search
|
||||
if (depth != 0) {
|
||||
|
||||
// if it is a directory, or an archive, or a virtual directory, then we need to get the
|
||||
// children and search those
|
||||
if (isDirectory || ((isArchive || isVirtualDirectory) && _searchString.isIncludeArchives()))
|
||||
{
|
||||
|
||||
if (!hasSearchedDirectory(theFile)) {
|
||||
|
||||
_alreadySearched.add(theFile);
|
||||
|
||||
File[] children = null;
|
||||
|
||||
// if the file is an archive or a virtual directory, then get the children from
|
||||
// the archive handler
|
||||
if (isArchive || isVirtualDirectory) {
|
||||
|
||||
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(absPath);
|
||||
File archive = new File(avp.getContainingArchiveString());
|
||||
String virtualPath = avp.getVirtualPart();
|
||||
|
||||
VirtualChild[] virtualchildren = null;
|
||||
|
||||
try {
|
||||
virtualchildren = ArchiveHandlerManager.getInstance().getContents(archive, virtualPath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
UniversalServerUtilities.logError(_miner.getName(), "Error occured trying to get the canonical file", e);
|
||||
}
|
||||
|
||||
if (virtualchildren != null) {
|
||||
|
||||
children = new File[virtualchildren.length];
|
||||
|
||||
for (int i = 0; i < virtualchildren.length; i++) {
|
||||
AbsoluteVirtualPath newAvp = new AbsoluteVirtualPath(absPath);
|
||||
newAvp.setVirtualPart(virtualchildren[i].fullName);
|
||||
children[i] = new File(newAvp.toString());
|
||||
}
|
||||
|
||||
if (virtualchildren.length == 0) {
|
||||
children = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise, get the list of children
|
||||
else {
|
||||
children = theFile.listFiles();
|
||||
}
|
||||
|
||||
if (children != null) {
|
||||
|
||||
for (int i = 0; i < children.length && !_isCancelled; i++) {
|
||||
|
||||
File child = children[i];
|
||||
internalSearch(child, depth - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean internalSearchWithinFile(DataElement remoteFile, String absPath, File theFile) {
|
||||
|
||||
// if search string is empty, no need to look for matches within file
|
||||
if (_isFileSearch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
FileInputStream inputStream = null;
|
||||
|
||||
try {
|
||||
inputStream = new FileInputStream(theFile);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream);
|
||||
BufferedReader bufReader = new BufferedReader(reader);
|
||||
|
||||
SystemSearchStringMatchLocator locator = new SystemSearchStringMatchLocator(bufReader, _stringMatcher);
|
||||
|
||||
SystemSearchLineMatch[] matches = locator.locateMatches();
|
||||
|
||||
boolean foundMatches = ((matches != null) && (matches.length > 0));
|
||||
|
||||
if (foundMatches) {
|
||||
convert(remoteFile, absPath, matches);
|
||||
}
|
||||
|
||||
return foundMatches;
|
||||
}
|
||||
catch (Exception e) {
|
||||
UniversalServerUtilities.logError(_miner.getName(), "Error occured when trying to locate matches", e);
|
||||
remoteFile.setAttribute(DE.A_VALUE, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean doesFilePatternMatch(String compareStr) {
|
||||
return _fileNameMatcher.matches(compareStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether classification matches.
|
||||
* @param absolutePath the absolute path of the file for which we want to check classification.
|
||||
* @return <code>true</code> if the classification matches, <code>false</code> otherwise.
|
||||
*/
|
||||
protected boolean doesClassificationMatch(String absolutePath) {
|
||||
|
||||
if (_classificationString == null || _classificationString.equals("")) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
String classification = SystemFileClassifier.getInstance().classifyFile(absolutePath);
|
||||
return StringCompare.compare(_classificationString, classification, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from system line matches to data elements that will be sent back.
|
||||
* @param deObj the element representing the file for which matches have been found.
|
||||
* @param absPath the absolute path of the file.
|
||||
* @param lineMatches an array of line matches, or empty if no matches.
|
||||
*/
|
||||
protected void convert(DataElement deObj, String absPath, SystemSearchLineMatch[] lineMatches) {
|
||||
|
||||
SystemSearchLineMatch match = null;
|
||||
|
||||
for (int i = 0; i < lineMatches.length; i++) {
|
||||
match = lineMatches[i];
|
||||
DataElement obj = _dataStore.createObject(deObj, _deGrep, match.getLine(), absPath);
|
||||
obj.setAttribute(DE.A_SOURCE, obj.getSource() + ':'+ match.getLineNumber());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.processes;
|
||||
|
||||
public interface IUniversalProcessDataStoreConstants
|
||||
{
|
||||
|
||||
/*
|
||||
* Miner name, used for logging
|
||||
*/
|
||||
public static final String UNIVERSAL_PROCESS_MINER = "UniversalProcessMiner";
|
||||
|
||||
//
|
||||
// Universal Process descriptors for DataStore DataElements
|
||||
//
|
||||
public static final String UNIVERSAL_PROCESS_ROOT = "universal.process.root";
|
||||
public static final String UNIVERSAL_PROCESS_FILTER = "universal.process.filter";
|
||||
public static final String UNIVERSAL_PROCESS_DESCRIPTOR = "universal.process.descriptor";
|
||||
|
||||
//
|
||||
// Universal Process Miner Commands
|
||||
//
|
||||
public static final String C_PROCESS_FILTER_QUERY_ALL = "C_PROCESS_FILTER_QUERY_ALL";
|
||||
public static final String C_PROCESS_KILL = "C_PROCESS_KILL";
|
||||
public static final String C_PROCESS_QUERY_ALL_PROPERTIES = "C_PROCESS_QUERY_ALL_PROPERTIES";
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.processes;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
|
||||
/**
|
||||
* Compares two DataElements representing processes by extracting
|
||||
* their PID's and comparing numerically based on the PID's.
|
||||
* @author mjberger
|
||||
*
|
||||
*/
|
||||
public class ProcessDEComparator implements Comparator
|
||||
{
|
||||
public ProcessDEComparator()
|
||||
{
|
||||
}
|
||||
|
||||
public int compare(Object obj1, Object obj2)
|
||||
{
|
||||
DataElement de1 = (DataElement) obj1;
|
||||
DataElement de2 = (DataElement) obj2;
|
||||
long pid1 = 0;
|
||||
long pid2 = 0;
|
||||
try
|
||||
{
|
||||
pid1 = Long.parseLong(de1.getName());
|
||||
pid2 = Long.parseLong(de2.getName());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return de1.toString().compareTo(de2.toString());
|
||||
}
|
||||
return (int) (pid1 - pid2);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return this.equals(obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,397 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners.processes;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.dstore.core.miners.miner.Miner;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
|
||||
import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.IRemoteServerProcess;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.ProcessComparator;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandler;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.UniversalServerProcessImpl;
|
||||
|
||||
/**
|
||||
* Miner for getting process information from a remote system.
|
||||
* @author mjberger
|
||||
*/
|
||||
public class UniversalProcessMiner extends Miner implements IUniversalProcessDataStoreConstants, IUniversalDataStoreConstants, ISystemProcessRemoteConstants
|
||||
{
|
||||
|
||||
public static final String MINER_ID = UniversalProcessMiner.class.getName();
|
||||
|
||||
private ProcessHandler handler;
|
||||
|
||||
private static final String _minerVersion = "7.0.0";
|
||||
|
||||
private DataElement deUniversalProcessObject, deUniversalProcessFilter, deKillInfoNode;
|
||||
private ProcessDEComparator _processDEcomparator;
|
||||
|
||||
public UniversalProcessMiner()
|
||||
{
|
||||
handler = ProcessHandlerManager.getInstance().getNewProcessHandler();
|
||||
}
|
||||
|
||||
private ProcessDEComparator getProcessDEComparator()
|
||||
{
|
||||
if (_processDEcomparator == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_processDEcomparator = new ProcessDEComparator();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
err.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return _processDEcomparator;
|
||||
}
|
||||
|
||||
public DataElement handleCommand(DataElement theCommand)
|
||||
{
|
||||
String name = getCommandName(theCommand);
|
||||
DataElement status = getCommandStatus(theCommand);
|
||||
DataElement subject = getCommandArgument(theCommand, 0);
|
||||
|
||||
//UniversalServerUtilities.logInfo(getMinerName(), name + ":" + subject);
|
||||
|
||||
if (subject == null) {
|
||||
|
||||
UniversalServerUtilities.logError(UNIVERSAL_PROCESS_MINER, "Subject for UniversalProcessMiner command " + name + " is null", null);
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
return status;
|
||||
}
|
||||
|
||||
String subjectType = (String) subject.getElementProperty(DE.P_TYPE);
|
||||
|
||||
if (subjectType.equals(UNIVERSAL_PROCESS_FILTER))
|
||||
{
|
||||
if (name.equals(C_PROCESS_FILTER_QUERY_ALL))
|
||||
{
|
||||
status = handleQuery(subject, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
UniversalServerUtilities.logError(UNIVERSAL_PROCESS_MINER, "Unknown filter command: " + name, null);
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
}
|
||||
}
|
||||
else if (subjectType.equals(UNIVERSAL_PROCESS_DESCRIPTOR))
|
||||
{
|
||||
if (name.equals(C_PROCESS_QUERY_ALL_PROPERTIES))
|
||||
{
|
||||
handleQueryJobAllProperties(subject, status);
|
||||
}
|
||||
else if (name.equals(C_PROCESS_KILL))
|
||||
{
|
||||
status = handleKill(subject, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
UniversalServerUtilities.logError(UNIVERSAL_PROCESS_MINER, "Unsupported process command: " + name, null);
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UniversalServerUtilities.logError(UNIVERSAL_PROCESS_MINER, "Unsupported subject for command: " + subject, null);
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void extendSchema(DataElement schemaRoot)
|
||||
{
|
||||
|
||||
// define process descriptors
|
||||
deUniversalProcessFilter = createObjectDescriptor(schemaRoot,
|
||||
UNIVERSAL_PROCESS_FILTER);
|
||||
deUniversalProcessObject = createObjectDescriptor(schemaRoot,
|
||||
UNIVERSAL_PROCESS_DESCRIPTOR);
|
||||
|
||||
// define command descriptors
|
||||
createCommandDescriptor(deUniversalProcessFilter, "Filter", C_PROCESS_FILTER_QUERY_ALL);
|
||||
createCommandDescriptor(deUniversalProcessObject, "Kill", C_PROCESS_KILL);
|
||||
createCommandDescriptor(deUniversalProcessObject, "ProcessQueryAllProperties", C_PROCESS_QUERY_ALL_PROPERTIES);
|
||||
|
||||
_dataStore.refresh(schemaRoot);
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
deKillInfoNode = _dataStore.createObject(_minerData, UNIVERSAL_NODE_DESCRIPTOR, "universal.killinfo");
|
||||
deKillInfoNode.setAttribute(DE.A_VALUE, getSignalTypes());
|
||||
_dataStore.refresh(_minerData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String with a list of signal types that can be sent to processes on this
|
||||
* system, separated by newline characters.
|
||||
*/
|
||||
protected String getSignalTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
Process kill = Runtime.getRuntime().exec("kill -l");
|
||||
InputStreamReader isr = new InputStreamReader(kill.getInputStream());
|
||||
if (isr == null) return "";
|
||||
BufferedReader reader = new BufferedReader(isr);
|
||||
if (reader == null) return "";
|
||||
String nextLine = reader.readLine();
|
||||
String output = "";
|
||||
while (nextLine != null)
|
||||
{
|
||||
output = output + nextLine + "\n";
|
||||
nextLine = reader.readLine();
|
||||
}
|
||||
reader.close();
|
||||
isr.close();
|
||||
return output;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle process queries
|
||||
*/
|
||||
private DataElement handleQuery(DataElement subject, DataElement status)
|
||||
{
|
||||
try
|
||||
{
|
||||
HostProcessFilterImpl pfs = new HostProcessFilterImpl(subject.getSource());
|
||||
lookupProcesses(pfs, subject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
UniversalServerUtilities.logError("UniversalProcessMiner", "handleQuery()", e);
|
||||
status.setAttribute(DE.A_VALUE, e.getMessage());
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
_dataStore.refresh(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
_dataStore.refresh(subject);
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
status.setAttribute(DE.A_VALUE, PROCESS_MINER_SUCCESS);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
private void lookupProcesses(HostProcessFilterImpl fsObj, DataElement subject) throws Exception
|
||||
{
|
||||
// we need to synchronize the list of data elements with the fresh
|
||||
// results coming back from the query
|
||||
if (handler == null) throw new Exception(PROCESS_MINER_ERROR_NO_HANDLER);
|
||||
SortedSet processes = handler.lookupProcesses(fsObj);
|
||||
SortedSet sortedDEs = null;
|
||||
// sort the data elements
|
||||
List nested = subject.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
Object[] oldDEs = nested.toArray();
|
||||
if (oldDEs != null && oldDEs.length > 0)
|
||||
{
|
||||
sortedDEs = new TreeSet(getProcessDEComparator());
|
||||
for (int i = 0; i < oldDEs.length; i++)
|
||||
{
|
||||
if (fsObj.allows(((DataElement)oldDEs[i]).getValue()))
|
||||
sortedDEs.add(oldDEs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// take care of the special cases where one of the lists has no
|
||||
// elements
|
||||
if (processes == null || processes.size() == 0)
|
||||
{
|
||||
deleteDataElements(fsObj, subject);
|
||||
return;
|
||||
}
|
||||
if (sortedDEs == null || sortedDEs.size() == 0)
|
||||
{
|
||||
createDataElements(processes.toArray(), subject);
|
||||
return;
|
||||
}
|
||||
|
||||
// now we merge the lists
|
||||
Iterator pIter = processes.iterator();
|
||||
Iterator deIter = sortedDEs.iterator();
|
||||
|
||||
DataElement nextDE = null;
|
||||
IRemoteServerProcess nextP = null;
|
||||
IRemoteServerProcess nextDEP = null;
|
||||
try
|
||||
{
|
||||
// pop the first two elements off the lists
|
||||
ProcessComparator comparator = new ProcessComparator();
|
||||
nextDE = (DataElement) deIter.next();
|
||||
nextDEP = new UniversalServerProcessImpl(nextDE.getValue());
|
||||
nextP = (IRemoteServerProcess) pIter.next();
|
||||
do
|
||||
{
|
||||
// compare the pid's of the elements
|
||||
int comparison = comparator.compare(nextDEP, nextP);
|
||||
|
||||
// data element exists in datastore but no longer returned in query,
|
||||
// so delete it, and pop it off the list
|
||||
if (comparison < 0)
|
||||
{
|
||||
_dataStore.deleteObject(subject, nextDE);
|
||||
deIter.remove();
|
||||
nextDE = (DataElement) deIter.next();
|
||||
nextDEP = new UniversalServerProcessImpl(nextDE.getValue());
|
||||
|
||||
}
|
||||
|
||||
// data element exists in both the query and datastore, so refresh its properties
|
||||
// and then pop both top items off their lists
|
||||
if (comparison == 0)
|
||||
{
|
||||
nextDE.setAttribute(DE.A_VALUE, nextP.getAllProperties());
|
||||
deIter.remove();
|
||||
pIter.remove();
|
||||
nextDE = (DataElement) deIter.next();
|
||||
nextDEP = new UniversalServerProcessImpl(nextDE.getValue());
|
||||
nextP = (IRemoteServerProcess) pIter.next();
|
||||
}
|
||||
|
||||
// data element does not exist in the data store, so create it
|
||||
if (comparison > 0)
|
||||
{
|
||||
createDataElement(nextP, subject);
|
||||
pIter.remove();
|
||||
nextP = (IRemoteServerProcess) pIter.next();
|
||||
}
|
||||
}
|
||||
while(true);
|
||||
}
|
||||
catch (NoSuchElementException e) // we have reached the tail of one of the lists, add or delete the rest
|
||||
{
|
||||
if (!pIter.hasNext() && !deIter.hasNext()) return;
|
||||
if (deIter.hasNext()) deleteRemainingElements(deIter, subject);
|
||||
else createDataElements(processes.toArray(), subject);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRemainingElements(Iterator iter, DataElement subject)
|
||||
{
|
||||
while (iter.hasNext())
|
||||
{
|
||||
DataElement next = (DataElement) iter.next();
|
||||
_dataStore.deleteObject(subject, next);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDataElements(HostProcessFilterImpl fsObj, DataElement subject)
|
||||
{
|
||||
List nested = subject.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
Object[] oldDEs = nested.toArray();
|
||||
if (oldDEs == null || oldDEs.length == 0) return;
|
||||
for (int i = 0; i < oldDEs.length; i++)
|
||||
{
|
||||
DataElement currentDE = (DataElement) oldDEs[i];
|
||||
if (fsObj.allows(currentDE.getValue()))
|
||||
_dataStore.deleteObject(subject, currentDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createDataElements(Object[] processes, DataElement subject)
|
||||
{
|
||||
if (processes == null || processes.length == 0) return;
|
||||
for (int i = 0; i < processes.length; i++)
|
||||
{
|
||||
createDataElement((IRemoteServerProcess)processes[i], subject);
|
||||
}
|
||||
}
|
||||
|
||||
private void createDataElement(IRemoteServerProcess process, DataElement subject)
|
||||
{
|
||||
DataElement dsObj = null;
|
||||
dsObj = _dataStore.createObject(subject, deUniversalProcessObject, "" + process.getPid());
|
||||
dsObj.setAttribute(DE.A_VALUE, process.getAllProperties());
|
||||
}
|
||||
/**
|
||||
* Query all properties of the process.
|
||||
*/
|
||||
private void handleQueryJobAllProperties(DataElement subject, DataElement status)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill a process.
|
||||
*/
|
||||
private DataElement handleKill(DataElement subject, DataElement status)
|
||||
{
|
||||
try
|
||||
{
|
||||
String statusLine = subject.getValue();
|
||||
UniversalServerProcessImpl usp = new UniversalServerProcessImpl(statusLine);
|
||||
if (handler == null) throw new Exception(PROCESS_MINER_ERROR_NO_HANDLER);
|
||||
IHostProcess result = handler.kill(usp, subject.getSource());
|
||||
|
||||
if (result == null) _dataStore.deleteObject(subject.getParent(), subject);
|
||||
else
|
||||
{
|
||||
subject.setAttribute(DE.A_SOURCE, "");
|
||||
subject.setAttribute(DE.A_VALUE, result.getAllProperties());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
UniversalServerUtilities.logError("UniversalProcessMiner", "handleQuery()", e);
|
||||
status.setAttribute(DE.A_VALUE, e.getMessage());
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
_dataStore.refresh(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
_dataStore.refresh(subject.getParent());
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
status.setAttribute(DE.A_VALUE, PROCESS_MINER_SUCCESS);
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return _minerVersion;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
plugin.name = RSE Dstore Services
|
|
@ -0,0 +1 @@
|
|||
rseserver.jar
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use Shell;
|
||||
|
||||
if (!defined($ARGV[0]) || !defined($ARGV[1]) || !defined($ARGV[2]) || !defined($ARGV[3]) || !defined($ARGV[4]))
|
||||
{
|
||||
print("command usage:\n");
|
||||
print("auth.pl USER, PATH, PORT, TIMEOUT, TICKET\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$userIN = $ARGV[0];
|
||||
$pathIN = $ARGV[1];
|
||||
$portIN = $ARGV[2];
|
||||
$timeoutIN = $ARGV[3];
|
||||
$ticketIN = $ARGV[4];
|
||||
|
||||
$pwdIN = <STDIN>;
|
||||
chomp($pwdIN);
|
||||
|
||||
|
||||
@passwdStruct = getpwnam($userIN);
|
||||
|
||||
if (@passwdStruct == 0)
|
||||
{
|
||||
print("invalid user name\n");
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$passwd=$passwdStruct[1];
|
||||
$encryptedPWD = crypt($pwdIN, $passwd);
|
||||
$classpath=$ENV{CLASSPATH};
|
||||
$suOptions="-lp";
|
||||
|
||||
if ($passwd eq $encryptedPWD)
|
||||
{
|
||||
print("success\n");
|
||||
|
||||
$os = uname();
|
||||
chomp($os);
|
||||
|
||||
if (lc($os) eq "aix")
|
||||
{
|
||||
$suOptions="-";
|
||||
}
|
||||
|
||||
system("su $suOptions $userIN -c 'java -cp $classpath -DA_PLUGIN_PATH=$pathIN com.ibm.etools.systems.dstore.core.server.Server $portIN $timeoutIN $ticketIN'");
|
||||
1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print("incorrect password\n");
|
||||
0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
|
||||
$port = "4800";
|
||||
$helpFlag = "-h";
|
||||
|
||||
if (defined($ARGV[0]))
|
||||
{
|
||||
$port = $ARGV[0];
|
||||
}
|
||||
|
||||
|
||||
$isHelp = $helpFlag cmp $port;
|
||||
if ($isHelp == 0)
|
||||
{
|
||||
print("command usage:\n");
|
||||
print("daemon.linux [<port> | <low port>-<high port>]\n");
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$trace = $ENV{DSTORE_TRACING_ON};
|
||||
$user=`whoami`; chomp($user);
|
||||
$match = $user cmp "root";
|
||||
|
||||
if ($match != 0)
|
||||
{
|
||||
print("To run the server daemon, you must be root\n");
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dir= $ENV{PWD};
|
||||
$plugins_dir=$dir;
|
||||
|
||||
$ENV{A_PLUGIN_PATH}="$plugins_dir/";
|
||||
|
||||
$oldClasspath = $ENV{CLASSPATH};
|
||||
|
||||
$ENV{"CLASSPATH"}="$plugins_dir:$plugins_dir/dstore_extra_server.jar:$plugins_dir/dstore_core.jar:$plugins_dir/dstore_miners.jar:$plugins_dir/clientserver.jar:$oldClasspath";
|
||||
|
||||
system("java -DA_PLUGIN_PATH=\$A_PLUGIN_PATH -DDSTORE_TRACING_ON=$trace org.eclipse.dstore.core.server.ServerLauncher $port");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
|
||||
if (defined($ARGV[0]))
|
||||
{
|
||||
$port = $ARGV[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = "4035";
|
||||
}
|
||||
|
||||
#$user = $ENV{USER};
|
||||
|
||||
$trace = $ENV{DSTORE_TRACING_ON};
|
||||
$user=`whoami`; chomp($user);
|
||||
$match = $user cmp "root";
|
||||
|
||||
if ($match != 0)
|
||||
{
|
||||
print("To run the server daemon, you must be root\n");
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dir= $ENV{PWD};
|
||||
|
||||
$plugins_dir=$dir;
|
||||
|
||||
$ENV{A_PLUGIN_PATH}="$plugins_dir/";
|
||||
|
||||
$oldClasspath = $ENV{CLASSPATH};
|
||||
|
||||
$ENV{"CLASSPATH"}="$plugins_dir:$plugins_dir/dstore_extra_server.jar:$plugins_dir/dstore_core.jar:$plugins_dir/dstore_miners.jar:$plugins_dir/universalminers.jar:$plugins_dir/clientserver.jar:$oldClasspath";
|
||||
|
||||
|
||||
|
||||
system("java -DA_PLUGIN_PATH=\$A_PLUGIN_PATH -DDSTORE_TRACING_ON=$trace com.ibm.etools.systems.dstore.core.server.ServerLauncher $port");
|
||||
$ENV{CLASSPATH}=$oldClasspath;
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
java -DA_PLUGIN_PATH=%A_PLUGIN_PATH% com.ibm.etools.systems.dstore.core.server.ServerLauncher
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
org.eclipse.rse.dstore.universal.miners.command.CommandMiner
|
||||
org.eclipse.rse.dstore.universal.miners.filesystem.UniversalFileSystemMiner
|
||||
org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner
|
||||
org.eclipse.rse.dstore.universal.miners.processes.UniversalProcessMiner
|
|
@ -0,0 +1,269 @@
|
|||
#
|
||||
# parse command line output.
|
||||
#
|
||||
# CLICK THIS LINE TO EDIT THIS FILE (PATTERNS.DAT). (When viewing from the Output view)
|
||||
|
||||
command: grep -n.*
|
||||
grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.*
|
||||
|
||||
command: grep -.*n.*
|
||||
grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.*
|
||||
|
||||
command: grep .*
|
||||
grep file pattern =([\w,.,/,(,)\\,\-,\+,\d]*):.*
|
||||
|
||||
|
||||
command: pwd
|
||||
directory file pattern=([\w,.,/,(,),\\,\-,\+,\d,:]*)
|
||||
|
||||
command: nmake.*
|
||||
error pattern=NMAKE : .*
|
||||
error file line pattern =([\w,.,\-,\+,(,),\\,:]*)\((\d*):(\d*)\) : error EDC.*
|
||||
error file pattern =[\w,.,\-,\+,(,),\\,:]*\(([\w,.,/,\\]*)\) : error LNK.*
|
||||
error file line pattern=([\w,.,/,\-,\+,(,),\\]*):(\d*):\d*\) : error .*
|
||||
warning file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : warning .*
|
||||
informational file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : informational .*
|
||||
|
||||
command: make.*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(E\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
#iseries c compiler
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
#makefile errors
|
||||
error file line pattern=\"([\w,\.,/,(,),\-,\+,\\]*)\", line (\d*): make:.*
|
||||
#xlc Options warnings
|
||||
warning pattern=\(W\) Option .*
|
||||
#c89 errors
|
||||
error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
informational pattern=CBC\d*\(I\) .*
|
||||
|
||||
command: gmake.*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
# ixlc compiler
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
# icc compiler
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.*
|
||||
error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.*
|
||||
#generic
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: gcc\s.*
|
||||
error file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
warning file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
|
||||
command: cc\s.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: CC\s.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: c89.*
|
||||
error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
informational pattern=CBC\d*\(I\) .*
|
||||
|
||||
command: icc.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.*
|
||||
error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.*
|
||||
|
||||
command: javac.*
|
||||
warning file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*): warning.*
|
||||
error file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*):.*
|
||||
|
||||
command: .*bat\s.*
|
||||
error file line pattern=\[javac\]\s([\w,.,/,\\,:]*):(\d*):.*
|
||||
error file line pattern=file:([\w,.,/,\\,:]*):(\d*):.*
|
||||
|
||||
command: dir.*
|
||||
directory file pattern=\d{2}/\d{2}/\d*\s\d{2}:\d{2}[a,p,AM,PM,\s].*\s*<DIR>\s*([\w,.,/,\\,\s,\-,\+\+,\d]*).*
|
||||
file file pattern=\d{2}/\d{2}/\d*\s\d{2}:\d{2}[a,p,AM,PM,\s].*\s*[\d,,]* ([\w,.,/,\\,\s,\-,\+\+,\d]*).*
|
||||
directory file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*<DIR>\s*([\w,.,/,\\,\s,\-,\+\+,\d]*)
|
||||
file file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*[\d,,,.]*\s*([\w,.,/,\\,\s,\-,\+\+,\d]*)
|
||||
|
||||
command: ls -l.*
|
||||
file file pattern=-[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
file file pattern=l[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
file file pattern=l.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
file file pattern=l.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
|
||||
command: ls -a.*
|
||||
file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
|
||||
command: ls
|
||||
file file pattern=([\w,\d,.,(,),\-,\+\s]+)
|
||||
|
||||
command: ls\s.*
|
||||
file file pattern=([\w,\d,.,(,),\-,\+\s]+)
|
||||
|
||||
command: .*
|
||||
prompt file pattern=([\w,.,/,(,),\\,\-,\+,\d,:,\s]*)>.*
|
||||
|
||||
command: find .*
|
||||
file file pattern=([\w,.,/,\\,(,),\-]+)
|
||||
|
||||
command: env
|
||||
pathenvvar file pattern=PATH\=(.*)
|
||||
libpathenvvar file pattern=LIBPATH\=(.*)
|
||||
libpathenvvar file pattern=LIB\=(.*)
|
||||
envvar pattern=[\w\d]+\=.*
|
||||
|
||||
command: ps
|
||||
process pattern=[\s]*[\d]+\s.*
|
||||
|
||||
command: ps .*
|
||||
process pattern=[\s]*[\d]+\s.*
|
||||
|
||||
command: xl[C,c].*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(E\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
|
||||
command: ixlc.*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
|
||||
command: cat.*patterns.*
|
||||
warning file pattern=# .*(PATTERNS.DAT).*
|
||||
Output pattern=command: .*
|
||||
#statement pattern=#.*
|
||||
statement pattern=.* pattern.*=.*
|
||||
|
||||
# special for autoconf
|
||||
command: ./bootstrap.sc.*
|
||||
error file line pattern=aclocal: ([\w,.,/,\\]*): (\d*):.*
|
||||
warning file line pattern=([\w,.,/,\\]*):(\d*):.*
|
||||
|
||||
command: ./configure.*
|
||||
error file line pattern=./(configure): line (\d*): .*
|
||||
|
||||
# How Patterns Work
|
||||
# -----------------
|
||||
#
|
||||
# Patterns are used by the Output View to allow lines that contain file names and
|
||||
# perhaps line numbers to be clicked to cause the file location to be opened in an Editor.
|
||||
# A line in this file can be 1 of 3 things:
|
||||
# 1. An empty line or a comment line (denoted by a # in column 1)
|
||||
# 2. The start of a command description (denoted by a 'command:' at the beginning of the line)
|
||||
# 3. A pattern description.
|
||||
# A formal description of the syntax of this file is included at the bottom of this file.
|
||||
#
|
||||
#
|
||||
# Command Descriptions
|
||||
# --------------------
|
||||
#
|
||||
# A Command Description consists of 2 things: A regular expression that describes the
|
||||
# command invocation, and a list of Pattern Descriptions. The regular expression
|
||||
# is used to determine what set of Pattern Descriptons to use when parsing command output.
|
||||
# For example, if you type the command 'gmake clean', the Command Descriptions are checked and
|
||||
# .*make.* would match that command. Therefore the Pattern Descriptions for .*make.* would
|
||||
# be used to parse the output of the 'gmake clean'.
|
||||
# Note: The first Command Description that is found to match the command is used, so make
|
||||
# sure you put the most specific patterns first. For example, if the nmake.* Command
|
||||
# Description appeared after .*make.*, then 'nmake install' would be matched by the .*make.*
|
||||
# Command Descripton, which is probably not what was intended.
|
||||
#
|
||||
#
|
||||
# Pattern Descriptions
|
||||
# --------------------
|
||||
#
|
||||
# A Pattern Description has the following form:
|
||||
# <obj-name> <match-info> "pattern="<reg-ex>
|
||||
#
|
||||
# where:
|
||||
# <obj-name>: The type of object that will be created in the Output View if
|
||||
# a line of output matches this pattern. If you have put an
|
||||
# icon called "<object-name>.gif" in the com.ibm.etools.systems.dstore.core/icons
|
||||
# directory, then the icon will be displayed in the view.
|
||||
#
|
||||
# <match-info>: This is some combination of the words "file" and "line" or nothing
|
||||
# at all. This is used to define how the backreferences in the
|
||||
# regular expression are to be interpreted. So "file line" means
|
||||
# that the first back-reference is a file, and the second is a
|
||||
# line number. This may seem unnecessary, but we added this capability
|
||||
# in the event that future releases support other types of information
|
||||
# that may be useful, such as column info (once we support it).
|
||||
#
|
||||
# <reg-ex>: A regular expression that describes a line of output. Backreferences
|
||||
# are used to store (instead of just match) the filename and line
|
||||
# number. To store a filename use the backreference ([\w,.,/,\\]*), and
|
||||
# to store a line number, use (\d*)
|
||||
#
|
||||
#
|
||||
# Note: The patterns are checked against command output and only exact matches are dealt with
|
||||
# So as an example, if you forget the .* (match everything) at the end of a pattern,
|
||||
# the match will fail if there are trailing characters in the output not accounted for by
|
||||
# the pattern
|
||||
#
|
||||
#
|
||||
# Pattern File Syntax
|
||||
# -------------------
|
||||
#
|
||||
# The pattern file syntax should be easy to grasp by looking at the ones
|
||||
# above, but for those of you who like formal grammars, here it is:
|
||||
#
|
||||
# patterns-file:
|
||||
# commands
|
||||
#
|
||||
# commands:
|
||||
# command
|
||||
# commands new-line command
|
||||
#
|
||||
# command:
|
||||
# "command:" reg-ex new-line patterns
|
||||
#
|
||||
# patterns:
|
||||
# pattern
|
||||
# patterns new-line pattern
|
||||
#
|
||||
# pattern:
|
||||
# command-name match-list "pattern=" reg-ex
|
||||
#
|
||||
# command-name:
|
||||
# String that denotes what type of object will be created if some output matches this pattern
|
||||
#
|
||||
# match-list:
|
||||
# file-or-line
|
||||
# match-list space file-or-line
|
||||
#
|
||||
# file-or-line:
|
||||
# "file" | "line"
|
||||
#
|
||||
# reg-ex:
|
||||
# A regular expression
|
||||
#
|
||||
# new-line:
|
||||
# The new-line character \n
|
||||
#
|
||||
# space:
|
||||
# The space character
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
# server.version - DO NOT MODIFY!
|
||||
#
|
||||
server.version=5.0.0
|
||||
|
||||
#
|
||||
# Logging level
|
||||
# 0 - Log error messages
|
||||
# 1 - Log error and warning messages
|
||||
# 2 - Log error, warning and info messages
|
||||
# 3 - Log error, warning, info and debug messages
|
||||
#
|
||||
debug_level=0
|
||||
|
||||
#
|
||||
# Log location
|
||||
# Log_To_StdOut
|
||||
# Log_To_File
|
||||
#
|
||||
log_location=Log_To_File
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set PORT=%1
|
||||
set TIMEOUT=%2
|
||||
set TICKET=%3
|
||||
|
||||
if xxx%1 == xxx set PORT=4033
|
||||
if xxx%2 == xxx set TIMEOUT=120000
|
||||
if xxx%3 == xxx goto runNoTicket
|
||||
|
||||
@echo on
|
||||
|
||||
java -DA_PLUGIN_PATH=%A_PLUGIN_PATH% com.ibm.etools.systems.dstore.core.server.Server %PORT% %TIMEOUT% %TICKET%
|
||||
goto done
|
||||
|
||||
:runNoTicket
|
||||
@echo on
|
||||
java -DA_PLUGIN_PATH=%A_PLUGIN_PATH% com.ibm.etools.systems.dstore.core.server.Server %PORT% %TIMEOUT%
|
||||
goto done
|
||||
|
||||
:usage
|
||||
@echo Usage: run.win ^<port^> ^<timeout^>
|
||||
|
||||
:done
|
||||
endlocal
|
|
@ -0,0 +1,7 @@
|
|||
# Shell script to starat RSE communications server
|
||||
# This script will start the datastore listening on an available socket
|
||||
|
||||
export serverpath=.;
|
||||
export PATH=/usr/java131/jre/bin:$PATH
|
||||
export CLASSPATH=/usr/java131/jre/lib/rt.jar:/usr/jdk_base/lib/classes.zip:$CLASSPATH
|
||||
export CLASSPATH=.:dstore_extra_server.jar:dstore_core.jar:dstore_miners.jar:universalminers.jar:clientserver.jar:$CLASSPATH;java -DA_PLUGIN_PATH=$serverpath -DDSTORE_TRACING_ON=false com.ibm.etools.systems.dstore.core.server.Server 0 60000 &
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$port = $ARGV[0];
|
||||
$timeout = $ARGV[1];
|
||||
$packaged_as = $ARGV[2];
|
||||
|
||||
|
||||
$dir= $ENV{PWD};
|
||||
#print("path $dir");
|
||||
|
||||
#$plugins_dir=substr($dir,0,rindex($dir,"/"));
|
||||
$plugins_dir=$dir;
|
||||
|
||||
$ENV{A_PLUGIN_PATH}="$plugins_dir/";
|
||||
|
||||
$oldClasspath = $ENV{CLASSPATH};
|
||||
|
||||
|
||||
if ($packaged_as == "jar")
|
||||
{
|
||||
$ENV{"CLASSPATH"}="$plugins_dir:$plugins_dir/dstore_extra_server.jar:$plugins_dir/dstore_core.jar:$plugins_dir/dstore_miners.jar:$plugins_dir/universalminers.jar:$plugins_dir/clientserver.jar:$oldClasspath";
|
||||
}
|
||||
if ($packaged_as == "src")
|
||||
{
|
||||
$ENV{"CLASSPATH"}="$plugins_dir:$oldClasspath";
|
||||
}
|
||||
if (!defined($packaged_as))
|
||||
{
|
||||
$ENV{"CLASSPATH"}="$plugins_dir:$plugins_dir/dstore_extra_server.jar:$plugins_dir/dstore_core.jar:$plugins_dir/dstore_miners.jar:$plugins_dir/universalminers.jar:$plugins_dir/clientserver.jar:$oldClasspath";
|
||||
}
|
||||
|
||||
if (!defined($timeout))
|
||||
{
|
||||
system("java -DA_PLUGIN_PATH=\$A_PLUGIN_PATH com.ibm.etools.systems.dstore.core.server.Server $port");
|
||||
}
|
||||
else
|
||||
{
|
||||
system("java -DA_PLUGIN_PATH=\$A_PLUGIN_PATH com.ibm.etools.systems.dstore.core.server.Server $port $timeout");
|
||||
}
|
||||
|
||||
$ENV{CLASSPATH}=$oldClasspath;
|
|
@ -0,0 +1,5 @@
|
|||
# Shell script to starat RSE communications server
|
||||
# This script will start the datastore listening on an available socket
|
||||
export serverpath=.;
|
||||
export CLASSPATH=.:dstore_extra_server.jar:dstore_core.jar:dstore_miners.jar:universalminers.jar:clientserver.jar:$CLASSPATH;
|
||||
java -DA_PLUGIN_PATH=$serverpath -DDSTORE_TRACING_ON=false com.ibm.etools.systems.dstore.core.server.Server 0 60000 &
|
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# Shell script to start RSE communications server
|
||||
# This script will start the datastore listening on any socket
|
||||
# that's available.
|
||||
#
|
||||
. setup.env.zseries
|
||||
export serverpath=.;
|
||||
|
||||
export CLASSPATH=.:dstore_extra_server.jar:dstore_core.jar:dstore_miners.jar:universalminers.jar:clientserver.jar:$CLASSPATH;
|
||||
|
||||
java -DA_PLUGIN_PATH=$serverpath com.ibm.etools.systems.dstore.core.server.Server 0 60000 &
|
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# QShell script to start RSE communications server
|
||||
# Usage: runServer portNumber socketTimeOut
|
||||
#
|
||||
|
||||
export JAVA_HOME=/sysroot/usr/lpp/java/IBM/J1.3
|
||||
SHELL=/bin/sh
|
||||
TZ=EST5EDT
|
||||
LANG=C
|
||||
export PATH=$PATH:/bin:.:/usr/sbin:/sysroot/usr/lpp/internet/bin:/sysroot/usr/lpp/internet/sbin:$JAVA_HOME/bin:$JAVA_HOME/bin/
|
||||
|
||||
export _CEE_RUNOPTS="ALL31(ON) HEAP(32M,32K,ANYWHERE,KEEP)"
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
set ECLIPSEDIR=.
|
||||
set CORE=%ECLIPSEDIR%\dstore_core.jar
|
||||
set MINERS=%ECLIPSEDIR%\dstore_miners.jar
|
||||
set EXTRA=%ECLIPSEDIR%\dstore_extra_server.jar
|
||||
set UNIVERSALJAR=%ECLIPSEDIR%\universalminers.jar
|
||||
set CLIENTSERVER=%ECLIPSEDIR%\clientserver.jar
|
||||
set A_PLUGIN_PATH=%ECLIPSEDIR%
|
||||
set CLASSPATH=%CORE%;%MINERS%;%UNIVERSAL%;%UNIVERSALJAR%;%CLIENTSERVER%;%EXTRA%;%CLASSPATH%
|
|
@ -0,0 +1,156 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.shell;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.extra.internal.extra.DomainEvent;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainListener;
|
||||
import org.eclipse.rse.services.shells.AbstractHostShellOutputReader;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IHostShellOutputReader;
|
||||
|
||||
public class DStoreShellOutputReader extends AbstractHostShellOutputReader implements IHostShellOutputReader, IDomainListener
|
||||
{
|
||||
protected DataElement _status;
|
||||
protected int _statusOffset = 0;
|
||||
|
||||
public DStoreShellOutputReader(IHostShell hostShell, DataElement status, boolean isErrorReader)
|
||||
{
|
||||
super(hostShell, isErrorReader);
|
||||
_status = status;
|
||||
if (status != null)
|
||||
{
|
||||
_status.getDataStore().getDomainNotifier().addDomainListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getWorkingDirectory()
|
||||
{
|
||||
String pwd = _status.getSource();
|
||||
return pwd;
|
||||
}
|
||||
|
||||
protected Object internalReadLine()
|
||||
{
|
||||
if (_status != null)
|
||||
{
|
||||
int newSize = _status.getNestedSize();
|
||||
while (newSize > _statusOffset)
|
||||
{
|
||||
DataElement line = _status.get(_statusOffset++);
|
||||
|
||||
|
||||
|
||||
String type = line.getType();
|
||||
boolean isError = type.equals("error") || type.equals("stderr");
|
||||
if (_isErrorReader && isError)
|
||||
{
|
||||
return line;
|
||||
}
|
||||
else if (!_isErrorReader && !isError)
|
||||
{
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
waitForResponse();
|
||||
return internalReadLine();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean listeningTo(DomainEvent e)
|
||||
{
|
||||
return e.getParent() == _status;
|
||||
}
|
||||
|
||||
public void domainChanged(DomainEvent event)
|
||||
{
|
||||
if (_status.getValue().equals("done"))
|
||||
{
|
||||
|
||||
if (_status == event.getParent())
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now, this is pulled via internalReadLine()
|
||||
notifyResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the current thread to wait until this class request has been
|
||||
* fulfilled.
|
||||
*/
|
||||
public synchronized void waitForResponse()
|
||||
{
|
||||
try
|
||||
{
|
||||
wait();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes all threads waiting for this class request to be filled
|
||||
* to wake up.
|
||||
*/
|
||||
public synchronized void notifyResponse()
|
||||
{
|
||||
try
|
||||
{
|
||||
notifyAll();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void handleInput()
|
||||
{
|
||||
// append new results to existing results
|
||||
ArrayList results = _status.getNestedData();
|
||||
int totalSize = results.size();
|
||||
int currentSize = _linesOfOutput.size();
|
||||
|
||||
for (int loop = currentSize; loop < totalSize; loop++)
|
||||
{
|
||||
DataElement result = (DataElement) results.get(loop);
|
||||
addLine(result.getName());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.shell;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.DataStoreSchema;
|
||||
import org.eclipse.rse.dstore.universal.miners.command.CommandMiner;
|
||||
import org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner;
|
||||
|
||||
|
||||
|
||||
public class DStoreShellThread
|
||||
{
|
||||
protected DataElement _runCmdDescriptor;
|
||||
protected DataElement _runShellDescriptor;
|
||||
protected DataElement _setEnvironmentDescriptor;
|
||||
protected DataElement _sendInputDescriptor;
|
||||
protected DataElement _cmdMinerElement;
|
||||
protected DataElement _envMinerElement;
|
||||
|
||||
private String _encoding;
|
||||
private String _cwd;
|
||||
private String[] _envVars;
|
||||
private DataStore _dataStore;
|
||||
private DataElement _status;
|
||||
|
||||
/**
|
||||
* @param cwd initial working directory
|
||||
* @param invocation launch shell command
|
||||
* @param encoding
|
||||
* @param patterns patterns file for output interpretation
|
||||
* @param envVars user and system environment variables to launch shell with
|
||||
*/
|
||||
public DStoreShellThread(DataStore dataStore, String cwd, String invocation, String encoding, String[] envVars)
|
||||
{
|
||||
super();
|
||||
_dataStore = dataStore;
|
||||
_encoding = encoding;
|
||||
_cwd = cwd;
|
||||
_envVars = envVars;
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
// make this subsystem a communications listener
|
||||
DataElement contextDir = _dataStore.createObject(null, "directory", (new File(_cwd)).getName(), _cwd);
|
||||
_dataStore.setObject(contextDir);
|
||||
setRemoteEnvironment(contextDir);
|
||||
|
||||
sendShellToMiner(contextDir);
|
||||
}
|
||||
|
||||
public DataElement getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
protected void sendShellToMiner(DataElement contextDir)
|
||||
{
|
||||
DataElement cmdD = getRunShellDescriptor(contextDir);
|
||||
|
||||
if (cmdD != null)
|
||||
{
|
||||
String encoding = _encoding;
|
||||
if (encoding != null && encoding.length() > 0)
|
||||
{
|
||||
DataElement arg = _dataStore.createObject(null, "shell.encoding", encoding);
|
||||
_status = _dataStore.command(cmdD, arg, contextDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
_status = _dataStore.command(cmdD, contextDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the environment variables for this connection. For universal this sets them in the
|
||||
* DataStore tree. When a new shell is launched the environment variables are passed to the
|
||||
* shell.
|
||||
*/
|
||||
public void setRemoteEnvironment(DataElement theObject)
|
||||
{
|
||||
|
||||
if (_envVars != null && _envVars.length > 0)
|
||||
{
|
||||
DataElement theEnvironment = _dataStore.createObject(null, "Environment Variable", theObject.getName());
|
||||
for (int i = 0; i < _envVars.length; i++)
|
||||
{
|
||||
String var = _envVars[i];
|
||||
_dataStore.createObject(theEnvironment, "Environment Variable", var, var);
|
||||
}
|
||||
|
||||
theEnvironment.setAttribute(DE.A_NAME, theObject.getId());
|
||||
DataElement contObj = _dataStore.findObjectDescriptor("Container Object");
|
||||
DataElement setD = getSetEnvironmentDescriptor(contObj);
|
||||
if (setD != null)
|
||||
{
|
||||
_dataStore.command(setD, theEnvironment, theObject, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getRunCommandDescriptor(DataElement remoteObject)
|
||||
{
|
||||
if (_runCmdDescriptor == null || _dataStore != remoteObject.getDataStore())
|
||||
{
|
||||
_runCmdDescriptor = _dataStore.localDescriptorQuery(remoteObject.getDescriptor(), getRunCommandId());
|
||||
}
|
||||
return _runCmdDescriptor;
|
||||
}
|
||||
|
||||
protected DataElement getRunShellDescriptor(DataElement remoteObject)
|
||||
{
|
||||
if (_runShellDescriptor == null || _dataStore != remoteObject.getDataStore())
|
||||
{
|
||||
_runShellDescriptor = _dataStore.localDescriptorQuery(remoteObject.getDescriptor(), getRunShellId(), 2);
|
||||
}
|
||||
return _runShellDescriptor;
|
||||
}
|
||||
|
||||
protected DataElement getSetEnvironmentDescriptor(DataElement remoteObject)
|
||||
{
|
||||
if (_setEnvironmentDescriptor == null || _dataStore != remoteObject.getDataStore())
|
||||
{
|
||||
_setEnvironmentDescriptor = _dataStore.localDescriptorQuery(remoteObject.getDescriptor(), getSetEnvironmentId(), 2);
|
||||
}
|
||||
return _setEnvironmentDescriptor;
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getSendInputDescriptor(DataElement remoteObject)
|
||||
{
|
||||
if (_sendInputDescriptor == null || _dataStore != remoteObject.getDataStore())
|
||||
{
|
||||
_sendInputDescriptor = _dataStore.findCommandDescriptor(DataStoreSchema.C_SEND_INPUT);
|
||||
}
|
||||
|
||||
return _sendInputDescriptor;
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getCmdSystemMinerElement()
|
||||
{
|
||||
|
||||
if (_cmdMinerElement == null || _cmdMinerElement.getDataStore() != _dataStore)
|
||||
{
|
||||
_cmdMinerElement = _dataStore.findMinerInformation(getCmdSystemMinerId());
|
||||
if (_cmdMinerElement == null)
|
||||
{
|
||||
_cmdMinerElement = _dataStore.findMinerInformation(getOldCmdSystemMinerId());
|
||||
}
|
||||
}
|
||||
return _cmdMinerElement;
|
||||
}
|
||||
|
||||
protected DataElement getEnvSystemMinerElement()
|
||||
{
|
||||
|
||||
if (_envMinerElement == null || _envMinerElement.getDataStore() != _dataStore)
|
||||
{
|
||||
_envMinerElement = _dataStore.findMinerInformation(getEnvSystemMinerId());
|
||||
|
||||
if (_envMinerElement == null)
|
||||
{
|
||||
_envMinerElement = _dataStore.findMinerInformation(getOldEnvSystemMinerId());
|
||||
}
|
||||
}
|
||||
return _envMinerElement;
|
||||
}
|
||||
|
||||
|
||||
protected String getCmdSystemMinerId()
|
||||
{
|
||||
return CommandMiner.MINER_ID;
|
||||
}
|
||||
|
||||
protected String getOldCmdSystemMinerId()
|
||||
{
|
||||
return "com.ibm.etools.systems.dstore.miners.command.CommandMiner";
|
||||
}
|
||||
|
||||
protected String getEnvSystemMinerId()
|
||||
{
|
||||
return EnvironmentMiner.MINER_ID;
|
||||
}
|
||||
|
||||
protected String getRunShellId()
|
||||
{
|
||||
return "C_SHELL";
|
||||
}
|
||||
|
||||
protected String getRunCommandId()
|
||||
{
|
||||
return "C_COMMAND";
|
||||
}
|
||||
|
||||
protected String getSetEnvironmentId()
|
||||
{
|
||||
return "C_SET_ENVIRONMENT_VARIABLES";
|
||||
}
|
||||
|
||||
protected String getOldEnvSystemMinerId()
|
||||
{
|
||||
return "com.ibm.etools.systems.dstore.miners.environment.EnvironmentMiner";
|
||||
}
|
||||
|
||||
public void writeToShell(String command)
|
||||
{
|
||||
DataElement commandElement = _status.getParent();
|
||||
DataStore dataStore = commandElement.getDataStore();
|
||||
|
||||
if (command.equals("") || command.equals("#break"))
|
||||
{
|
||||
String cmd = command;
|
||||
if (cmd.equals(""))
|
||||
cmd = "#enter";
|
||||
DataElement commandDescriptor = getSendInputDescriptor(commandElement);
|
||||
if (commandDescriptor != null)
|
||||
{
|
||||
DataElement in = dataStore.createObject(null, "input", cmd);
|
||||
dataStore.command(commandDescriptor, in, commandElement);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] tokens = command.split("\n\r");
|
||||
for (int i = 0; i <tokens.length; i++)
|
||||
{
|
||||
String cmd = tokens[i];
|
||||
|
||||
if (cmd != null)
|
||||
{
|
||||
DataElement commandDescriptor = getSendInputDescriptor(commandElement);
|
||||
if (commandDescriptor != null)
|
||||
{
|
||||
DataElement in = dataStore.createObject(null, "input", cmd);
|
||||
dataStore.command(commandDescriptor, in, commandElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,304 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
|
||||
public abstract class AbstractDStoreService implements IDStoreService
|
||||
{
|
||||
protected IDataStoreProvider _dataStoreProvider;
|
||||
protected DataElement _minerElement;
|
||||
protected DStoreStatusMonitor _statusMonitor;
|
||||
protected Map _cmdDescriptorMap;
|
||||
protected DataElement _initializeStatus;
|
||||
|
||||
public AbstractDStoreService(IDataStoreProvider dataStoreProvider)
|
||||
{
|
||||
_dataStoreProvider = dataStoreProvider;
|
||||
_cmdDescriptorMap = new HashMap();
|
||||
}
|
||||
|
||||
public DStoreStatusMonitor getStatusMonitor(DataStore dataStore)
|
||||
{
|
||||
if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore)
|
||||
{
|
||||
_statusMonitor = new DStoreStatusMonitor(dataStore);
|
||||
}
|
||||
return _statusMonitor;
|
||||
}
|
||||
|
||||
public DataStore getDataStore()
|
||||
{
|
||||
return _dataStoreProvider.getDataStore();
|
||||
}
|
||||
|
||||
protected DataElement getMinerElement()
|
||||
{
|
||||
if (_minerElement == null || _minerElement.getDataStore() != getDataStore())
|
||||
{
|
||||
_minerElement = getMinerElement(getMinerId());
|
||||
}
|
||||
return _minerElement;
|
||||
}
|
||||
|
||||
protected DataElement getMinerElement(String id)
|
||||
{
|
||||
return getDataStore().findMinerInformation(id);
|
||||
}
|
||||
|
||||
protected DataElement[] dsQueryCommand(IProgressMonitor monitor, DataElement subject, ArrayList args, String command)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataElement status = getDataStore().command(queryCmd, args, subject, true);
|
||||
try
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status, monitor);
|
||||
int resultSize = subject.getNestedSize();
|
||||
if (resultSize == 0)
|
||||
{
|
||||
System.out.println("status="+status);
|
||||
System.out.println("subject="+subject);
|
||||
}
|
||||
checkHostJVM();
|
||||
// get results
|
||||
List nested = subject.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
return (DataElement[])nested.toArray(new DataElement[resultSize]);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return new DataElement[0];
|
||||
}
|
||||
|
||||
protected DataElement dsStatusCommand(IProgressMonitor monitor, DataElement subject, ArrayList args, String command)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataElement status = getDataStore().command(queryCmd, args, subject, true);
|
||||
try
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return status;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected DataElement[] dsQueryCommand(IProgressMonitor monitor, DataElement subject, String command)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
DataElement status = ds.command(queryCmd, subject, true);
|
||||
try
|
||||
{
|
||||
getStatusMonitor(ds).waitForUpdate(status, monitor);
|
||||
checkHostJVM();
|
||||
// get results
|
||||
List nested = subject.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
return (DataElement[])nested.toArray(new DataElement[subject.getNestedSize()]);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return new DataElement[0];
|
||||
}
|
||||
|
||||
protected DataElement dsStatusCommand(IProgressMonitor monitor, DataElement subject, String command)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
DataElement status = ds.command(queryCmd, subject, true);
|
||||
try
|
||||
{
|
||||
getStatusMonitor(ds).waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return status;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected DataElement getCommandDescriptor(DataElement subject, String command)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
DataElement cmd = (DataElement)_cmdDescriptorMap.get(command);
|
||||
if (cmd == null || ds != cmd.getDataStore())
|
||||
{
|
||||
cmd = getDataStore().localDescriptorQuery(subject.getDescriptor(), command);
|
||||
_cmdDescriptorMap.put(command, cmd);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public int getServerVersion()
|
||||
{
|
||||
return getDataStore().getServerVersion();
|
||||
}
|
||||
|
||||
public int getServerMinor()
|
||||
{
|
||||
return getDataStore().getServerMinor();
|
||||
}
|
||||
|
||||
protected void checkHostJVM()
|
||||
{
|
||||
/*
|
||||
DataElement status = getDataStore().queryHostJVM();
|
||||
String source = status.getSource();
|
||||
String[] tokens = source.split(",");
|
||||
|
||||
long freeMem = Long.parseLong(tokens[0]);
|
||||
long totalMem = Long.parseLong(tokens[1]);
|
||||
|
||||
int numElements = Integer.parseInt(tokens[3]);
|
||||
|
||||
System.out.println("Host JVM Stats:");
|
||||
System.out.println("\tfreeMem="+freeMem);
|
||||
System.out.println("\ttotalMem="+totalMem);
|
||||
|
||||
System.out.println("\tnumber of elements="+numElements);
|
||||
|
||||
String[] lastCreated = tokens[4].split(";");
|
||||
System.out.println("\tlast created:");
|
||||
for (int i = 0; i < lastCreated.length; i++)
|
||||
{
|
||||
System.out.println("\t\t" + lastCreated[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
return smon.determineStatusDone(_initializeStatus);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(_initializeStatus, monitor, 100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getMinerElement();
|
||||
}
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
initMiner(monitor);
|
||||
}
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
{
|
||||
DataElement fsElement = getMinerElement();
|
||||
if (fsElement == null)
|
||||
{
|
||||
if (getServerVersion() >= 8)
|
||||
{
|
||||
String minerId = getMinerId();
|
||||
String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId);
|
||||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_minerElement == null || _minerElement.getDataStore() != ds)
|
||||
{
|
||||
if (ds != null)
|
||||
{
|
||||
_initializeStatus = ds.activateMiner(minerId);
|
||||
/*
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(status, monitor, 50);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getMinerElement();
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
protected abstract String getMinerId();
|
||||
|
||||
/**
|
||||
* For now just a dummy method
|
||||
* @param messageID
|
||||
* @return
|
||||
*/
|
||||
public SystemMessage getMessage(String messageID)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The main plugin class to be used in the desktop.
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
//The shared instance.
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public Activator() {
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon plug-in activation
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the plug-in is stopped
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
super.stop(context);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance.
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given
|
||||
* plug-in relative path.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.services.files.dstore", path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
||||
public interface IDStoreService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class ServiceResources extends NLS
|
||||
{
|
||||
private static String BUNDLE_NAME = "org.eclipse.rse.services.dstore.ServiceResources";//$NON-NLS-1$
|
||||
|
||||
public static String DStore_Shell_Service_Label;
|
||||
public static String DStore_Search_Service_Label;
|
||||
public static String DStore_File_Service_Label;
|
||||
public static String DStore_Process_Service_Label;
|
||||
|
||||
public static String DStore_Shell_Service_Description;
|
||||
public static String DStore_Search_Service_Description;
|
||||
public static String DStore_File_Service_Description;
|
||||
public static String DStore_Process_Service_Description;
|
||||
|
||||
public static String DStore_Service_ProgMon_Initializing_Message;
|
||||
public static String DStore_Service_Percent_Complete_Message;
|
||||
|
||||
static {
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, ServiceResources.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2006 IBM Corporation. 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
|
||||
#
|
||||
# Initial Contributors:
|
||||
# The following IBM employees contributed to the Remote System Explorer
|
||||
# component that contains this file: David McKnight, Kushal Munir,
|
||||
# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
#
|
||||
# Contributors:
|
||||
# {Name} (company) - description of contribution.
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
DStore_Shell_Service_Label=DStore Shell Service
|
||||
DStore_Search_Service_Label=DStore Search Service
|
||||
DStore_File_Service_Label=DStore File Service
|
||||
DStore_Process_Service_Label=DStore Process Service
|
||||
|
||||
DStore_Service_ProgMon_Initializing_Message=Initializing &1...
|
||||
DStore_Service_Percent_Complete_Message=&0 of &1 complete (&2)
|
||||
|
||||
DStore_Shell_Service_Description=The DStore Shell Service uses the RSE DataStore to provide service for the Shells subsystem. It requires a DataStore server or daemon to be running on the host machine.
|
||||
DStore_Search_Service_Description=The DStore Search Service uses the RSE DataStore to provide service for remote searches. It requires a DataStore server or daemon to be running on the host machine.
|
||||
DStore_File_Service_Description=The DStore File Service uses the RSE DataStore to provide service for the Files subsystem. It requires a DataStore server or daemon to be running on the host machine.
|
||||
DStore_Process_Service_Description=The DStore Process Service uses the RSE DataStore to provide service for the Processes subsystem. It requires a DataStore server or daemon to be running on the host machine.
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,276 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.files;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.services.clientserver.IServiceConstants;
|
||||
import org.eclipse.rse.services.clientserver.PathUtility;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
|
||||
public class DStoreHostFile implements IHostFile
|
||||
{
|
||||
public static final int ATTRIBUTE_MODIFIED_DATE=1;
|
||||
public static final int ATTRIBUTE_SIZE = 2;
|
||||
public static final int ATTRIBUTE_CLASSIFICATION =11;
|
||||
|
||||
|
||||
protected DataElement _element;
|
||||
protected boolean _isArchive;
|
||||
|
||||
public DStoreHostFile(DataElement element)
|
||||
{
|
||||
_element = element;
|
||||
_isArchive = internalIsArchive();
|
||||
}
|
||||
|
||||
public DataElement getDataElement()
|
||||
{
|
||||
return _element;
|
||||
}
|
||||
|
||||
public static String getNameFromPath(String path)
|
||||
{
|
||||
int lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash > 0 && lastSlash != path.length() - 1)
|
||||
{
|
||||
return path.substring(lastSlash);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String getParentPathFromPath(String path)
|
||||
{
|
||||
int lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash > 0 && lastSlash != path.length() - 1)
|
||||
{
|
||||
return path.substring(0, lastSlash);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
|
||||
{
|
||||
// filter doesn't separate path from name
|
||||
String path = _element.getName();
|
||||
return getNameFromPath(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = _element.getName();
|
||||
String parentPath = getParentPath();
|
||||
if (name.length() == 0 &&
|
||||
(parentPath.equals("/") || parentPath.endsWith(":\\")))
|
||||
{
|
||||
return getParentPath();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public String getParentPath()
|
||||
{
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
|
||||
{
|
||||
// filter doesn't separate path from name
|
||||
String path = _element.getName();
|
||||
return getParentPathFromPath(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _element.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
String name = getName();
|
||||
if (name == null || name.length() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return name.charAt(0) == '.';
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDirectory()
|
||||
{
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)
|
||||
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public boolean isRoot()
|
||||
{
|
||||
String parentPath = getParentPath();
|
||||
String name = _element.getName();
|
||||
if (parentPath == null || parentPath.length() == 0 ||
|
||||
(name.length() == 0 && (parentPath.equals("/") || parentPath.endsWith(":\\")))
|
||||
)
|
||||
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFile()
|
||||
{
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR)
|
||||
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|
||||
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean exists()
|
||||
{
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) ||
|
||||
type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR) ||
|
||||
type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) ||
|
||||
type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) ||
|
||||
type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getAbsolutePath()
|
||||
{
|
||||
String parentPath = getParentPath();
|
||||
String name = _element.getName();
|
||||
|
||||
String type = _element.getType();
|
||||
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
|
||||
{
|
||||
return parentPath;
|
||||
}
|
||||
|
||||
if (name.length() == 0)
|
||||
{
|
||||
return PathUtility.normalizeUnknown(parentPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PathUtility.normalizeUnknown(parentPath + "/" + name);
|
||||
}
|
||||
}
|
||||
|
||||
public long getSize()
|
||||
{
|
||||
return getFileLength(_element.getSource());
|
||||
}
|
||||
|
||||
public long getModifiedDate()
|
||||
{
|
||||
return getModifiedDate(_element.getSource());
|
||||
|
||||
}
|
||||
|
||||
public String getClassification()
|
||||
{
|
||||
String classification = getClassification(_element.getSource());
|
||||
if (classification == null)
|
||||
{
|
||||
if (isFile())
|
||||
{
|
||||
classification = "file";
|
||||
}
|
||||
else
|
||||
{
|
||||
classification = "directory";
|
||||
}
|
||||
}
|
||||
return classification;
|
||||
}
|
||||
|
||||
protected static String getClassification(String attributes)
|
||||
{
|
||||
return getAttribute(attributes, ATTRIBUTE_CLASSIFICATION);
|
||||
}
|
||||
|
||||
protected static long getFileLength(String attributes)
|
||||
{
|
||||
String str = getAttribute(attributes, ATTRIBUTE_SIZE);
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
protected static long getModifiedDate(String attributes)
|
||||
{
|
||||
String str = getAttribute(attributes, ATTRIBUTE_MODIFIED_DATE);
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
protected static String getAttribute(String attributes, int index)
|
||||
{
|
||||
String[] str = attributes.split("\\"+IServiceConstants.TOKEN_SEPARATOR);
|
||||
if (str.length > index)
|
||||
{
|
||||
return str[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void renameTo(String newAbsolutePath)
|
||||
{
|
||||
_element.setAttribute(DE.A_NAME, newAbsolutePath);
|
||||
_isArchive = internalIsArchive();
|
||||
}
|
||||
|
||||
protected boolean internalIsArchive()
|
||||
{
|
||||
String path = getAbsolutePath();
|
||||
return ArchiveHandlerManager.getInstance().isArchive(new File(path))
|
||||
&& !ArchiveHandlerManager.isVirtual(path);
|
||||
}
|
||||
|
||||
public boolean isArchive()
|
||||
{
|
||||
return _isArchive;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.files;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
|
||||
public class DStoreVirtualHostFile extends DStoreHostFile
|
||||
{
|
||||
|
||||
public static final int ATTRIBUTE_COMMENT = 6;
|
||||
public static final int ATTRIBUTE_COMPRESSEDSIZE = 7;
|
||||
public static final int ATTRIBUTE_COMPRESSIONMETHOD = 8;
|
||||
public static final int ATTRIBUTE_COMPRESSIONRATIO = 9;
|
||||
public static final int ATTRIBUTE_EXPANDEDSIZE = 10;
|
||||
|
||||
public DStoreVirtualHostFile(DataElement element)
|
||||
{
|
||||
super(element);
|
||||
}
|
||||
|
||||
protected static long getCompressedSize(String attributes)
|
||||
{
|
||||
String str = getAttribute(attributes, ATTRIBUTE_COMPRESSEDSIZE);
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
protected static long getExpandedSize(String attributes)
|
||||
{
|
||||
String str = getAttribute(attributes, ATTRIBUTE_EXPANDEDSIZE);
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
protected static double getCompressionRatio(String attributes)
|
||||
{
|
||||
String str = getAttribute(attributes, ATTRIBUTE_COMPRESSIONRATIO);
|
||||
return Double.parseDouble(str);
|
||||
}
|
||||
|
||||
public String getComment()
|
||||
{
|
||||
return getAttribute(_element.getSource(), ATTRIBUTE_COMMENT);
|
||||
}
|
||||
|
||||
public long getCompressedSize()
|
||||
{
|
||||
return getCompressedSize(_element.getSource());
|
||||
}
|
||||
|
||||
public String getCompressionMethod()
|
||||
{
|
||||
return getAttribute(_element.getSource(), ATTRIBUTE_COMPRESSIONMETHOD);
|
||||
}
|
||||
|
||||
public double getCompressionRatio()
|
||||
{
|
||||
return getCompressionRatio(_element.getSource());
|
||||
}
|
||||
|
||||
public long getExpandedSize()
|
||||
{
|
||||
return getExpandedSize(_element.getSource());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,519 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.processes;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||
|
||||
/**
|
||||
* This class implements the IRemoteClientProcess interface by wrappering a DataElement
|
||||
* and returning process attribute information from the underlying DataElement.
|
||||
* It also contains client-specific methods for getting contextual information about
|
||||
* the process such as the associated subsystem and connection.
|
||||
* @author mjberger
|
||||
*
|
||||
*/
|
||||
public class DStoreHostProcess implements IHostProcess, org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants, IAdaptable, org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants
|
||||
{
|
||||
public static final boolean ROOT_TRUE = true;
|
||||
public static final boolean ROOT_FALSE = false;
|
||||
|
||||
protected String _name, _username;
|
||||
protected long _pid = -1;
|
||||
protected long _ppid = -1;
|
||||
protected long _tgid = -1;
|
||||
protected long _tracerPid = -1;
|
||||
protected long _uid = -1;
|
||||
protected long _gid = -1;
|
||||
|
||||
protected String _label = null;
|
||||
protected String _fullyQualifiedProcess;
|
||||
|
||||
protected boolean _isRoot = false;
|
||||
|
||||
protected Object _remoteObj;
|
||||
|
||||
// master hash map
|
||||
protected HashMap _contents = new HashMap();
|
||||
|
||||
/* container properties */
|
||||
protected boolean _isStale = false;
|
||||
|
||||
// properties
|
||||
protected HashMap _properties = new HashMap();
|
||||
protected HashMap _propertyStates = new HashMap();
|
||||
|
||||
/**
|
||||
* Constructor that takes a dataElement object containing the process information, and
|
||||
* a parent process.
|
||||
*/
|
||||
public DStoreHostProcess(DataElement dataElementObj)
|
||||
{
|
||||
init(dataElementObj);
|
||||
}
|
||||
|
||||
protected void init(DataElement dataElementObj)
|
||||
{
|
||||
setProcess(dataElementObj);
|
||||
String name = dataElementObj.getName();
|
||||
_fullyQualifiedProcess = "/proc/" + name;
|
||||
|
||||
// if we already have retrieved file properties
|
||||
// set them now
|
||||
String s = dataElementObj.getAttribute(DE.A_VALUE);
|
||||
if (s != null && s.length() > 0)
|
||||
{
|
||||
getAttributes(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Properties of the process are returned from the miner in a string that can be parsed using
|
||||
* the String.split method, with delimiter "|".
|
||||
* You can also set all attributes at once with your own string passed as a parameter, as long
|
||||
* as the string is in the same format as outlined below (pass in null to use the DataElement's string):
|
||||
* <p> The string contains properties of the object in the following order
|
||||
* <ul>
|
||||
* <li>Process Id (pid) - long
|
||||
* <li>Executable name - String
|
||||
* <li>Status - char
|
||||
* <li>Tgid - long
|
||||
* <li>Process Parent id (ppid) - long
|
||||
* <li>Tracer pid - long
|
||||
* <li>User id (uid) - int
|
||||
* <li>Username - String
|
||||
* <li>Group id (gid) - int
|
||||
* <li>VM Size - long
|
||||
* <li>VM RSS - long
|
||||
* </ul>
|
||||
*/
|
||||
protected String getAttributes(String newAttributes)
|
||||
{
|
||||
DataElement deObj = (DataElement) this.getObject();
|
||||
|
||||
String s = null;
|
||||
|
||||
if (newAttributes == null) s = deObj.getAttribute(DE.A_VALUE);
|
||||
else s = newAttributes;
|
||||
|
||||
if (s != null && s.length() > 0)
|
||||
{
|
||||
String[] str = s.split("\\"+TOKEN_SEPARATOR);
|
||||
int tokens = str.length;
|
||||
if (tokens > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
setPid(str[PROCESS_ATTRIBUTES_INDEX_PID]);
|
||||
|
||||
setName(str[PROCESS_ATTRIBUTES_INDEX_EXENAME]);
|
||||
|
||||
setTgid(str[PROCESS_ATTRIBUTES_INDEX_TGID]);
|
||||
|
||||
setPPid(str[PROCESS_ATTRIBUTES_INDEX_PPID]);
|
||||
|
||||
if (_ppid == 0) _isRoot = true;
|
||||
|
||||
setTracerPid(str[PROCESS_ATTRIBUTES_INDEX_TRACERPID]);
|
||||
|
||||
setUid(str[PROCESS_ATTRIBUTES_INDEX_UID]);
|
||||
|
||||
setUsername(str[PROCESS_ATTRIBUTES_INDEX_USERNAME]);
|
||||
|
||||
setGid(str[PROCESS_ATTRIBUTES_INDEX_GID]);
|
||||
|
||||
setLabel(str[PROCESS_ATTRIBUTES_INDEX_EXENAME]);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.getAttributes(). Attributes = " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DataElement for this object
|
||||
*/
|
||||
public void setProcess(Object dataElementObj)
|
||||
{
|
||||
_remoteObj = (DataElement) dataElementObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DataElement for this object
|
||||
*/
|
||||
public Object getObject()
|
||||
{
|
||||
return _remoteObj;
|
||||
}
|
||||
|
||||
public String getAbsolutePath()
|
||||
{
|
||||
return _fullyQualifiedProcess;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return _label;
|
||||
}
|
||||
|
||||
public long getPid()
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String getState()
|
||||
{
|
||||
String state = getSubAttribute(PROCESS_ATTRIBUTES_INDEX_STATUS);
|
||||
if (state == null)
|
||||
{
|
||||
//SystemPlugin.logError("Error in UniversalProcessImpl.getAttributes(): status of process " + getPid() + " is not given.");
|
||||
return " ";
|
||||
}
|
||||
else return state;
|
||||
}
|
||||
|
||||
public long getTgid()
|
||||
{
|
||||
return _tgid;
|
||||
}
|
||||
|
||||
public long getTracerPid()
|
||||
{
|
||||
return _tracerPid;
|
||||
}
|
||||
|
||||
public long getUid()
|
||||
{
|
||||
return _uid;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return _username;
|
||||
}
|
||||
|
||||
public long getGid()
|
||||
{
|
||||
return _gid;
|
||||
}
|
||||
|
||||
protected void setAbsolutePath(String path)
|
||||
{
|
||||
_fullyQualifiedProcess = path;
|
||||
}
|
||||
|
||||
protected void setGid(long gid)
|
||||
{
|
||||
_gid = gid;
|
||||
}
|
||||
|
||||
protected void setGid(String newGid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_gid = Long.parseLong(newGid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
//SystemPlugin.logError("Error in UniversalProcessImpl.setGid: Could not parse gid into integer.");
|
||||
_gid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLabel(String newLabel)
|
||||
{
|
||||
_label = newLabel;
|
||||
}
|
||||
|
||||
protected void setName(String exeName)
|
||||
{
|
||||
_name = exeName;
|
||||
}
|
||||
|
||||
protected void setPid(long newPid)
|
||||
{
|
||||
_pid = newPid;
|
||||
}
|
||||
|
||||
protected void setPid(String newPid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_pid = Long.parseLong(newPid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setPid: Could not parse pid into integer.");
|
||||
_pid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setState(String newState)
|
||||
{
|
||||
setSubAttribute(PROCESS_ATTRIBUTES_INDEX_STATUS, newState);
|
||||
}
|
||||
|
||||
protected void setTgid(long tgid)
|
||||
{
|
||||
_tgid = tgid;
|
||||
}
|
||||
|
||||
protected void setTgid(String newTgid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tgid = Long.parseLong(newTgid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setTgid: Could not parse tgid into integer.");
|
||||
_tgid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTracerPid(long tracerPid)
|
||||
{
|
||||
_tracerPid = tracerPid;
|
||||
}
|
||||
|
||||
protected void setTracerPid(String newTracerPid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tracerPid = Long.parseLong(newTracerPid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setTracerPid: Could not parse tracerpid into integer.");
|
||||
_tracerPid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUid(long uid)
|
||||
{
|
||||
_uid = uid;
|
||||
}
|
||||
|
||||
protected void setUid(String newUid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_uid = Long.parseLong(newUid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setUid: Could not parse uid into integer.");
|
||||
_uid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUsername(String username)
|
||||
{
|
||||
_username = username;
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapterType)
|
||||
{
|
||||
return Platform.getAdapterManager().getAdapter(this, adapterType);
|
||||
}
|
||||
|
||||
public long getPPid()
|
||||
{
|
||||
return _ppid;
|
||||
}
|
||||
|
||||
protected void setPPid(long newPPid)
|
||||
{
|
||||
_ppid = newPPid;
|
||||
}
|
||||
|
||||
protected void setPPid(String newPPid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ppid = Long.parseLong(newPPid);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setPPid: Could not parse ppid into integer.");
|
||||
_ppid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRoot()
|
||||
{
|
||||
return _isRoot;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.clientserver.processes.IHostProcess#getAllProperties()
|
||||
*/
|
||||
public String getAllProperties()
|
||||
{
|
||||
return getAttributes(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allProperties
|
||||
*/
|
||||
protected void setAllProperties(String allProperties)
|
||||
{
|
||||
getAttributes(allProperties);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.clientserver.processes.IHostProcess#getVmSizeInKB()
|
||||
*/
|
||||
public long getVmSizeInKB()
|
||||
{
|
||||
String sizeStr = getSubAttribute(PROCESS_ATTRIBUTES_INDEX_VMSIZE);
|
||||
if (sizeStr == null) return 0;
|
||||
long vmsize = 0;
|
||||
try
|
||||
{
|
||||
vmsize = Long.parseLong(sizeStr);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.getVMSizeInKB: Could not parse VM Size into integer.");
|
||||
return 0;
|
||||
}
|
||||
return vmsize;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.clientserver.processes.IHostProcess#getVmRSSInKB()
|
||||
*/
|
||||
public long getVmRSSInKB()
|
||||
{
|
||||
String sizeStr = getSubAttribute(PROCESS_ATTRIBUTES_INDEX_VMRSS);
|
||||
if (sizeStr == null) return 0;
|
||||
long vmrss = 0;
|
||||
try
|
||||
{
|
||||
vmrss = Long.parseLong(sizeStr);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.getVMRSSInKB: Could not parse VM RSS into integer.");
|
||||
return 0;
|
||||
}
|
||||
return vmrss;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param size the size to set
|
||||
*/
|
||||
protected void setVmSizeInKB(long size)
|
||||
{
|
||||
String sizeStr = "";
|
||||
sizeStr = sizeStr + size;
|
||||
setSubAttribute(PROCESS_ATTRIBUTES_INDEX_VMSIZE, sizeStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size the size to set
|
||||
*/
|
||||
protected void setVmRSSInKB(long size)
|
||||
{
|
||||
String sizeStr = "";
|
||||
sizeStr = sizeStr + size;
|
||||
setSubAttribute(PROCESS_ATTRIBUTES_INDEX_VMRSS, sizeStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a subattribute of the A_VALUE of this process's associated
|
||||
* data element.
|
||||
* @param attIndex the index of the desired subattribute
|
||||
* @return a string containing that attribute, or null if that attribute
|
||||
* is not specified, if the dataelement does not exist, or if the attIndex
|
||||
* is out of bounds.
|
||||
*/
|
||||
protected String getSubAttribute(int attIndex)
|
||||
{
|
||||
DataElement deObj = (DataElement) this.getObject();
|
||||
if (deObj == null) return null;
|
||||
|
||||
String s = deObj.getAttribute(DE.A_VALUE);
|
||||
|
||||
if (s != null && s.length() > 0)
|
||||
{
|
||||
String[] str = s.split("\\"+TOKEN_SEPARATOR);
|
||||
if (attIndex >= str.length) return null;
|
||||
if (str[attIndex] == null || str[attIndex].equals("")) return null;
|
||||
else return str[attIndex];
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for setting any attributes of the underlying DataElement.
|
||||
* @param attIndex
|
||||
* @param newSubAttribute
|
||||
*/
|
||||
protected void setSubAttribute(int attIndex, String newSubAttribute)
|
||||
{
|
||||
DataElement deObj = (DataElement) this.getObject();
|
||||
if (deObj == null)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setSubAttribute: Could not access dataelement.");
|
||||
return;
|
||||
}
|
||||
String s = deObj.getAttribute(DE.A_VALUE);
|
||||
|
||||
if (s != null && s.length() > 0)
|
||||
{
|
||||
String[] str = s.split("\\"+TOKEN_SEPARATOR);
|
||||
if (attIndex >= str.length)
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setSubAttribute: Attribute index out of bounds.");
|
||||
return;
|
||||
}
|
||||
s = "";
|
||||
str[attIndex] = newSubAttribute;
|
||||
for (int i = 0; i < str.length; i++)
|
||||
{
|
||||
if (i == str.length - 1) s = s + str[i];
|
||||
else s = s + str[i] + TOKEN_SEPARATOR;
|
||||
}
|
||||
deObj.setAttribute(DE.A_VALUE, s);
|
||||
DataStore ds = deObj.getDataStore();
|
||||
ds.refresh(deObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// SystemPlugin.logError("Error in UniversalProcessImpl.setSubAttribute: Dataelement did not contain an attribute string.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,338 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.processes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.dstore.universal.miners.processes.IUniversalProcessDataStoreConstants;
|
||||
import org.eclipse.rse.dstore.universal.miners.processes.UniversalProcessMiner;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
||||
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||
import org.eclipse.rse.services.dstore.ServiceResources;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
import org.eclipse.rse.services.processes.AbstractProcessService;
|
||||
import org.eclipse.rse.services.processes.IProcessService;
|
||||
|
||||
|
||||
public class DStoreProcessService extends AbstractProcessService implements IProcessService, IUniversalProcessDataStoreConstants, ISystemProcessRemoteConstants
|
||||
{
|
||||
protected IDataStoreProvider _provider;
|
||||
protected DataElement _minerElement = null;
|
||||
protected DStoreStatusMonitor _statusMonitor;
|
||||
protected DataElement _procMinerStatus;
|
||||
protected String[] _statusTypes;
|
||||
|
||||
public DStoreProcessService(IDataStoreProvider provider)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return ServiceResources.DStore_Process_Service_Label;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return ServiceResources.DStore_Process_Service_Description;
|
||||
}
|
||||
|
||||
public IHostProcess[] listAllProcesses(IProgressMonitor monitor, IHostProcessFilter filter) throws SystemMessageException
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
waitForInitialize(monitor);
|
||||
}
|
||||
IHostProcess[] processes = null;
|
||||
|
||||
DataStore ds = getDataStore();
|
||||
DataElement universaltemp = getMinerElement();
|
||||
|
||||
// create filter descriptor
|
||||
DataElement deObj;
|
||||
deObj = ds.find(universaltemp, DE.A_NAME, UNIVERSAL_PROCESS_ROOT, 1);
|
||||
if (deObj == null) deObj = ds.createObject(universaltemp, UNIVERSAL_PROCESS_FILTER, UNIVERSAL_PROCESS_ROOT, "", "", false);
|
||||
deObj.setAttribute(DE.A_SOURCE, filter.toString());
|
||||
|
||||
// query
|
||||
DataElement queryCmd = ds.localDescriptorQuery(deObj.getDescriptor(), C_PROCESS_FILTER_QUERY_ALL);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataElement status = ds.command(queryCmd, deObj, true);
|
||||
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(status);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
throw new SystemMessageException(getMessage("RSEG1067"));
|
||||
}
|
||||
// get results
|
||||
List nested = deObj.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
Object[] results = nested.toArray();
|
||||
|
||||
String message = status.getAttribute(DE.A_VALUE);
|
||||
if (!message.equals(PROCESS_MINER_SUCCESS))
|
||||
{
|
||||
throw new SystemMessageException(getMessage("RSEPG1301"));
|
||||
}
|
||||
|
||||
// convert objects to remote files
|
||||
processes = convertObjsToHostProcesses(filter, results);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//SystemPlugin.logWarning(CLASSNAME + " queryCmd is null in listRoots");
|
||||
}
|
||||
|
||||
return processes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to convert DataElement objects to IRemoteClientProcess objects.
|
||||
*/
|
||||
protected IHostProcess[] convertObjsToHostProcesses(IHostProcessFilter processFilter, Object[] objs)
|
||||
{
|
||||
if (objs == null)
|
||||
return null;
|
||||
|
||||
ArrayList list = new ArrayList(objs.length);
|
||||
|
||||
for (int idx = 0; idx < objs.length; idx++)
|
||||
{
|
||||
DataElement de = (DataElement) objs[idx];
|
||||
if (!de.isDeleted())
|
||||
{
|
||||
if (processFilter == null || processFilter.allows(de.getValue()))
|
||||
{
|
||||
DStoreHostProcess newProcess = new DStoreHostProcess(de);
|
||||
list.add(newProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IHostProcess[] processes = new IHostProcess[list.size()];
|
||||
|
||||
for (int idx = 0; idx < list.size(); idx++)
|
||||
{
|
||||
processes[idx] = (IHostProcess) list.get(idx);
|
||||
}
|
||||
|
||||
return processes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to return the DataStore object needed by comm layer.
|
||||
*/
|
||||
protected DataStore getDataStore()
|
||||
{
|
||||
return _provider.getDataStore();
|
||||
}
|
||||
|
||||
protected DataElement getMinerElement()
|
||||
{
|
||||
|
||||
if (_minerElement == null || _minerElement.getDataStore() != getDataStore())
|
||||
{
|
||||
_minerElement = getDataStore()
|
||||
.findMinerInformation(
|
||||
"org.eclipse.rse.dstore.universal.miners.processes.UniversalProcessMiner");
|
||||
}
|
||||
return _minerElement;
|
||||
}
|
||||
|
||||
public DStoreStatusMonitor getStatusMonitor(DataStore dataStore)
|
||||
{
|
||||
if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore)
|
||||
{
|
||||
_statusMonitor = new DStoreStatusMonitor(dataStore);
|
||||
}
|
||||
return _statusMonitor;
|
||||
}
|
||||
|
||||
public boolean kill(IProgressMonitor monitor, long PID, String signal) throws SystemMessageException
|
||||
{
|
||||
try
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
// run kill command on host
|
||||
DStoreHostProcess process = (DStoreHostProcess) getProcess(monitor, PID);
|
||||
DataElement deObj = (DataElement) process.getObject();
|
||||
DataElement killCmd = ds.localDescriptorQuery(deObj.getDescriptor(), C_PROCESS_KILL);
|
||||
deObj.setAttribute(DE.A_SOURCE, signal);
|
||||
|
||||
if (killCmd != null)
|
||||
{
|
||||
DataElement status = ds.command(killCmd, deObj, true);
|
||||
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status);
|
||||
|
||||
// get results
|
||||
String message = status.getAttribute(DE.A_VALUE);
|
||||
if (message.equals(PROCESS_MINER_SUCCESS)) return true;
|
||||
else
|
||||
{
|
||||
SystemMessage msg = getMessage("RSEPG1300");
|
||||
msg.makeSubstitution(process.getName() + " (" + process.getPid() + ")", message);
|
||||
throw new SystemMessageException(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// SystemPlugin.logWarning(CLASSNAME + " queryCmd is null in listRoots");
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
throw new SystemMessageException(getMessage("RSEG1067"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getSignalTypes()
|
||||
{
|
||||
if (_statusTypes != null)
|
||||
{
|
||||
return _statusTypes;
|
||||
}
|
||||
else
|
||||
{
|
||||
_statusTypes = internalGetSignalTypes();
|
||||
}
|
||||
return _statusTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the types of signals that can be sent to
|
||||
* a process on the remote system.
|
||||
* @return the signal types, or null if there are none, or they cannot be found.
|
||||
*/
|
||||
private String[] internalGetSignalTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
DataElement sigTypesElement = getSignalTypesMinerElement();
|
||||
String sigTypesOutput = sigTypesElement.getValue();
|
||||
String[] lines = sigTypesOutput.trim().split("\\s+");
|
||||
if (lines == null) throw new Exception();
|
||||
return lines;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// SystemPlugin.logError("UniversalProcessSubSystemImpl.getSignalTypes() 'kill -l' command failed.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected DataElement getSignalTypesMinerElement()
|
||||
{
|
||||
return getDataStore().find(_minerElement, DE.A_NAME, "universal.killinfo");
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
initMiner(monitor);
|
||||
}
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_procMinerStatus != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
return smon.determineStatusDone(_procMinerStatus);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_procMinerStatus!= null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(_procMinerStatus, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getMinerElement();
|
||||
}
|
||||
}
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
{
|
||||
DataElement fsElement = getMinerElement();
|
||||
if (fsElement == null)
|
||||
{
|
||||
if (getServerVersion() >= 8)
|
||||
{
|
||||
String minerId = getMinerId();
|
||||
String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId);
|
||||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_minerElement == null || _minerElement.getDataStore() != ds)
|
||||
{
|
||||
if (ds != null)
|
||||
{
|
||||
_procMinerStatus = ds.activateMiner(minerId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return UniversalProcessMiner.MINER_ID;
|
||||
}
|
||||
|
||||
public int getServerVersion()
|
||||
{
|
||||
return getDataStore().getServerVersion();
|
||||
}
|
||||
|
||||
public int getServerMinor()
|
||||
{
|
||||
return getDataStore().getServerMinor();
|
||||
}
|
||||
|
||||
protected String getProcessMinerId()
|
||||
{
|
||||
return UniversalProcessMiner.MINER_ID;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.rmtservice;
|
||||
|
||||
import org.eclipse.dstore.core.java.IRemoteClassInstance;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.services.dstore.AbstractDStoreService;
|
||||
|
||||
public class DStoreRemoteServiceService extends AbstractDStoreService
|
||||
{
|
||||
|
||||
public DStoreRemoteServiceService(IDataStoreProvider dataStoreProvider)
|
||||
{
|
||||
super(dataStoreProvider);
|
||||
}
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void runRemoteService(IRemoteClassInstance serviceClass)
|
||||
{
|
||||
getDataStore().runRemoteClassInstance(serviceClass);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.search;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.extra.internal.extra.DomainEvent;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainListener;
|
||||
import org.eclipse.rse.services.clientserver.SystemSearchString;
|
||||
import org.eclipse.rse.services.search.AbstractSearchResultConfiguration;
|
||||
import org.eclipse.rse.services.search.IHostSearchResultSet;
|
||||
import org.eclipse.rse.services.search.ISearchService;
|
||||
|
||||
public abstract class DStoreSearchResultConfiguration extends AbstractSearchResultConfiguration implements IDomainListener
|
||||
{
|
||||
protected DataElement _status;
|
||||
public DStoreSearchResultConfiguration(IHostSearchResultSet set, Object searchObject, SystemSearchString searchString, ISearchService searchService)
|
||||
{
|
||||
super(set, searchObject, searchString, searchService);
|
||||
}
|
||||
|
||||
public void setStatusObject(DataElement status)
|
||||
{
|
||||
_status = status;
|
||||
// don't need this anymore
|
||||
//_status.getDataStore().getDomainNotifier().addDomainListener(this);
|
||||
}
|
||||
|
||||
public DataElement getStatusObject()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public boolean listeningTo(DomainEvent e)
|
||||
{
|
||||
return e.getParent() == _status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.dstore.universal.miners.filesystem.UniversalFileSystemMiner;
|
||||
import org.eclipse.rse.services.clientserver.SystemSearchString;
|
||||
import org.eclipse.rse.services.dstore.AbstractDStoreService;
|
||||
import org.eclipse.rse.services.dstore.ServiceResources;
|
||||
import org.eclipse.rse.services.dstore.files.DStoreHostFile;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.search.IHostSearchConstants;
|
||||
import org.eclipse.rse.services.search.IHostSearchResultConfiguration;
|
||||
import org.eclipse.rse.services.search.ISearchService;
|
||||
|
||||
|
||||
|
||||
public class DStoreSearchService extends AbstractDStoreService implements ISearchService
|
||||
{
|
||||
public DStoreSearchService(IDataStoreProvider provider)
|
||||
{
|
||||
super(provider);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return ServiceResources.DStore_Search_Service_Label;
|
||||
}
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return UniversalFileSystemMiner.MINER_ID;
|
||||
}
|
||||
|
||||
public void search(IProgressMonitor monitor, IHostSearchResultConfiguration searchConfig, IFileService fileService)
|
||||
{
|
||||
DStoreHostFile searchTarget = (DStoreHostFile) searchConfig.getSearchTarget();
|
||||
|
||||
SystemSearchString searchString = searchConfig.getSearchString();
|
||||
String textString = searchString.getTextString();
|
||||
boolean isCaseSensitive = searchString.isCaseSensitive();
|
||||
boolean isTextRegex = searchString.isTextStringRegex();
|
||||
String fileNamesString = searchString.getFileNamesString();
|
||||
boolean isFileNamesRegex = searchString.isFileNamesRegex();
|
||||
boolean includeArchives = searchString.isIncludeArchives();
|
||||
boolean includeSubfolders = searchString.isIncludeSubfolders();
|
||||
String classificationString = searchString.getClassificationString();
|
||||
|
||||
|
||||
DataElement deObj = searchTarget.getDataElement();
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
DataElement queryCmd = ds.localDescriptorQuery(deObj.getDescriptor(), "C_SEARCH");
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
ArrayList argList = setSearchAttributes(textString, isCaseSensitive, isTextRegex, fileNamesString, isFileNamesRegex, includeArchives, includeSubfolders, classificationString, true);
|
||||
|
||||
DataElement status = ds.command(queryCmd, argList, deObj);
|
||||
DStoreSearchResultConfiguration config = (DStoreSearchResultConfiguration) searchConfig;
|
||||
config.setStatusObject(status);
|
||||
|
||||
try
|
||||
{
|
||||
getStatusMonitor(ds).waitForUpdate(status, monitor);
|
||||
config.setStatus(IHostSearchConstants.FINISHED);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
config.setStatus(IHostSearchConstants.CANCELLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList setSearchAttributes(
|
||||
String textString,
|
||||
boolean isCaseSensitive,
|
||||
boolean isTextRegex,
|
||||
String fileNamesString,
|
||||
boolean isFileNamesRegex,
|
||||
boolean includeArchives,
|
||||
boolean includeSubfolders,
|
||||
String classificationString,
|
||||
boolean showHidden)
|
||||
{
|
||||
|
||||
DataStore ds = getDataStore();
|
||||
DataElement universaltemp = getMinerElement();
|
||||
|
||||
// create the argument data elements
|
||||
DataElement arg1 = ds.createObject(universaltemp, textString, String.valueOf(isCaseSensitive), String.valueOf(isTextRegex));
|
||||
DataElement arg2 = ds.createObject(universaltemp, fileNamesString, String.valueOf(isFileNamesRegex), classificationString);
|
||||
DataElement arg3 = ds.createObject(universaltemp, String.valueOf(includeArchives), String.valueOf(includeSubfolders), String.valueOf(showHidden));
|
||||
|
||||
// add the arguments to the argument list
|
||||
ArrayList argList = new ArrayList();
|
||||
argList.add(arg1);
|
||||
argList.add(arg2);
|
||||
argList.add(arg3);
|
||||
|
||||
return argList;
|
||||
}
|
||||
|
||||
public void cancelSearch(IProgressMonitor monitor, IHostSearchResultConfiguration searchConfig)
|
||||
{
|
||||
DStoreSearchResultConfiguration config = (DStoreSearchResultConfiguration) searchConfig;
|
||||
DataElement status = config.getStatusObject();
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
DataElement command = status.getParent();
|
||||
DataStore dataStore = command.getDataStore();
|
||||
DataElement cmdDescriptor = command.getDescriptor();
|
||||
DataElement cancelDescriptor = dataStore.localDescriptorQuery(cmdDescriptor, "C_CANCEL");
|
||||
|
||||
if (cancelDescriptor != null)
|
||||
{
|
||||
dataStore.command(cancelDescriptor, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.shells;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.rse.internal.services.dstore.shell.DStoreShellOutputReader;
|
||||
import org.eclipse.rse.internal.services.dstore.shell.DStoreShellThread;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
import org.eclipse.rse.services.shells.AbstractHostShell;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IHostShellOutputReader;
|
||||
|
||||
|
||||
public class DStoreHostShell extends AbstractHostShell implements IHostShell
|
||||
{
|
||||
private DStoreShellThread _shellThread;
|
||||
private IHostShellOutputReader _stdoutHandler;
|
||||
private IHostShellOutputReader _stderrHandler;
|
||||
private DataElement _status;
|
||||
private DStoreStatusMonitor _statusMonitor;
|
||||
|
||||
public DStoreHostShell(DStoreStatusMonitor statusMonitor, DataStore dataStore, String initialWorkingDirectory, String invocation, String encoding, String[] environment)
|
||||
{
|
||||
_shellThread = new DStoreShellThread(dataStore, initialWorkingDirectory, invocation, encoding, environment);
|
||||
_status = _shellThread.getStatus();
|
||||
_stdoutHandler = new DStoreShellOutputReader(this, _status, false);
|
||||
_stderrHandler = new DStoreShellOutputReader(this, _status,true);
|
||||
_statusMonitor = statusMonitor;
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return !_statusMonitor.determineStatusDone(_status);
|
||||
}
|
||||
|
||||
public void writeToShell(String command)
|
||||
{
|
||||
_shellThread.writeToShell(command);
|
||||
}
|
||||
|
||||
public IHostShellOutputReader getStandardOutputReader()
|
||||
{
|
||||
return _stdoutHandler;
|
||||
}
|
||||
|
||||
public IHostShellOutputReader getStandardErrorReader()
|
||||
{
|
||||
return _stderrHandler;
|
||||
}
|
||||
|
||||
public void exit()
|
||||
{
|
||||
writeToShell("exit");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.shells;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.dstore.universal.miners.command.CommandMiner;
|
||||
import org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.dstore.AbstractDStoreService;
|
||||
import org.eclipse.rse.services.dstore.ServiceResources;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
|
||||
|
||||
public class DStoreShellService extends AbstractDStoreService implements IShellService
|
||||
{
|
||||
protected String[] _envVars;
|
||||
protected DataElement _envMinerElement;
|
||||
protected DataElement _envMinerStatus;
|
||||
|
||||
public DStoreShellService(IDataStoreProvider dataStoreProvider)
|
||||
{
|
||||
super(dataStoreProvider);
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return ServiceResources.DStore_Shell_Service_Label;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return ServiceResources.DStore_Shell_Service_Description;
|
||||
}
|
||||
|
||||
|
||||
public IHostShell launchShell(IProgressMonitor monitor, String initialWorkingDirectory, String[] environment)
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
waitForInitialize(null);
|
||||
}
|
||||
return launchShell(monitor, initialWorkingDirectory, null, environment);
|
||||
}
|
||||
|
||||
public IHostShell launchShell(IProgressMonitor monitor, String initialWorkingDirectory, String encoding, String[] environment)
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
waitForInitialize(null);
|
||||
}
|
||||
return new DStoreHostShell(getStatusMonitor(getDataStore()), getDataStore(), initialWorkingDirectory, ">", encoding, environment);
|
||||
}
|
||||
|
||||
public IHostShell runCommand(IProgressMonitor monitor, String initialWorkingDirectory, String command,
|
||||
String[] environment)
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
waitForInitialize(null);
|
||||
}
|
||||
return runCommand(monitor, initialWorkingDirectory, command, null, environment);
|
||||
}
|
||||
|
||||
public IHostShell runCommand(IProgressMonitor monitor, String initialWorkingDirectory, String command,
|
||||
String encoding, String[] environment)
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
waitForInitialize(null);
|
||||
}
|
||||
return new DStoreHostShell(getStatusMonitor(getDataStore()), getDataStore(), initialWorkingDirectory, command, encoding, environment);
|
||||
}
|
||||
|
||||
public String[] getHostEnvironment()
|
||||
{
|
||||
if (_envVars == null || _envVars.length == 0)
|
||||
{
|
||||
List envVars = new ArrayList();
|
||||
DataStore ds = getDataStore();
|
||||
DataElement envMinerData = ds.findMinerInformation(getEnvSystemMinerId());
|
||||
if (envMinerData != null)
|
||||
{
|
||||
DataElement systemEnvironment = ds.find(envMinerData, DE.A_NAME, "System Environment", 1);
|
||||
if (systemEnvironment != null && systemEnvironment.getNestedSize() > 0)
|
||||
{
|
||||
for (int i = 0; i < systemEnvironment.getNestedSize(); i++)
|
||||
{
|
||||
DataElement var = systemEnvironment.get(i);
|
||||
envVars.add(var.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
_envVars = (String[])envVars.toArray(new String[envVars.size()]);
|
||||
}
|
||||
return _envVars;
|
||||
}
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return CommandMiner.MINER_ID;
|
||||
}
|
||||
|
||||
protected String getEnvSystemMinerId()
|
||||
{
|
||||
return EnvironmentMiner.MINER_ID;
|
||||
}
|
||||
|
||||
protected String getOldEnvSystemMinerId()
|
||||
{
|
||||
return "com.ibm.etools.systems.dstore.miners.environment.EnvironmentMiner";
|
||||
}
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
return smon.determineStatusDone(_initializeStatus);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_envMinerStatus!= null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(_envMinerStatus, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getMinerElement(getEnvSystemMinerId());
|
||||
}
|
||||
super.waitForInitialize(monitor);
|
||||
}
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
{
|
||||
// init env miner first
|
||||
|
||||
if (getServerVersion() >= 8)
|
||||
{
|
||||
String minerId = getEnvSystemMinerId();
|
||||
String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId);
|
||||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_envMinerElement == null || _envMinerElement.getDataStore() != ds)
|
||||
{
|
||||
if (ds != null)
|
||||
{
|
||||
_envMinerStatus = ds.activateMiner(minerId);
|
||||
/*
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(status, monitor, 50);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getMinerElement(getEnvSystemMinerId());
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
super.initMiner(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.util;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.rse.services.clientserver.IServiceConstants;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.DataStoreSchema;
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* copyright 2003 IBM Corp.
|
||||
*/
|
||||
public class DStoreFileTransferStatusListener extends StatusChangeListener
|
||||
{
|
||||
|
||||
protected String _remotePath;
|
||||
protected DataElement _log;
|
||||
protected DataElement _statusElement;
|
||||
|
||||
public DStoreFileTransferStatusListener(String remotePath, Shell shell, IProgressMonitor monitor, DataStore ds, DataElement uploadLog) throws Exception
|
||||
{
|
||||
super(shell, monitor);
|
||||
_remotePath = remotePath.replace('\\', '/');
|
||||
|
||||
_log = uploadLog;
|
||||
if (_log == null)
|
||||
{
|
||||
throw new Exception("Could not find log in DataStore.");
|
||||
}
|
||||
setStatus(findOrCreateUploadStatus(ds));
|
||||
}
|
||||
|
||||
protected DataElement findOrCreateUploadStatus(DataStore ds)
|
||||
{
|
||||
DataElement result = ds.find(_log, DE.A_NAME, _remotePath,1);
|
||||
|
||||
// first upload, this will always ben null
|
||||
// but also need to handle case where it's been uploaded before in the sessoin (i.e. for reseting values)
|
||||
if (result == null)
|
||||
{
|
||||
result = _log.getDataStore().createObject(_log, "uploadstatus", _remotePath);
|
||||
result.setAttribute(DE.A_SOURCE, "running");
|
||||
result.setAttribute(DE.A_VALUE, "");
|
||||
|
||||
DataElement cmd = ds.findCommandDescriptor(DataStoreSchema.C_SET);
|
||||
|
||||
DataElement setstatus = ds.command(cmd, _log, true);
|
||||
/*
|
||||
try
|
||||
{
|
||||
StatusMonitorFactory.getInstance().getStatusMonitorFor(system, ds).waitForUpdate(setstatus);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
*/
|
||||
// DKM: no need for this - turns out the problem was that we need to send the LOG not the result -
|
||||
// since the server needs to know the parent!
|
||||
//ds.waitUntil(setstatus, "done");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
result.setAttribute(DE.A_SOURCE, "running");
|
||||
result.setAttribute(DE.A_VALUE, "");
|
||||
}
|
||||
_statusElement = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.dstore.util.StatusChangeListener#determineStatusDone()
|
||||
*/
|
||||
protected boolean determineStatusDone()
|
||||
{
|
||||
return getStatus().getAttribute(DE.A_SOURCE).equals(IServiceConstants.SUCCESS) || getStatus().getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED);
|
||||
|
||||
}
|
||||
|
||||
public boolean uploadHasFailed()
|
||||
{
|
||||
return getStatus().getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED);
|
||||
}
|
||||
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return getStatus().getAttribute(DE.A_VALUE);
|
||||
}
|
||||
|
||||
public String getRemotePath()
|
||||
{
|
||||
return _remotePath;
|
||||
}
|
||||
|
||||
public void setRemotePath(String remotePath)
|
||||
{
|
||||
_remotePath = remotePath;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,399 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.extra.internal.extra.DomainEvent;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainListener;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainNotifier;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/*
|
||||
* This utility class can be used to monitor the status of one more more status DataElements.
|
||||
* Only one instanceof of this class is required per DataStore for use in monitoring statuses.
|
||||
* This is intended to be used in place of StatusChangeListeners
|
||||
*
|
||||
* * <p>
|
||||
* The following is one example of the use of the StatusMonitor. The code:
|
||||
* <blockquote><pre>
|
||||
* DataElement status = dataStore.command(dsCmd, args, deObj);
|
||||
*
|
||||
* StatusMonitor smon = StatusMonitorFactory.getInstance().getStatusMonitorFor(getSystem(), ds);
|
||||
* smon.waitForUpdate(status, monitor);
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
public class DStoreStatusMonitor implements IDomainListener
|
||||
{
|
||||
|
||||
protected Shell _shell;
|
||||
|
||||
protected boolean _networkDown = false;
|
||||
|
||||
protected List _workingStatuses;
|
||||
protected List _cancelledStatuses;
|
||||
protected List _doneStatuses;
|
||||
|
||||
protected DataStore _dataStore;
|
||||
|
||||
protected class FindShell implements Runnable
|
||||
{
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* @see Runnable#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
Display display = Display.getCurrent();
|
||||
if (display != null)
|
||||
{
|
||||
try {
|
||||
Shell[] shells = Display.getCurrent().getShells();
|
||||
for (int loop = 0; loop < shells.length && shell == null; loop++) {
|
||||
if (shells[loop].isEnabled()) {
|
||||
shell = shells[loop];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a StatusChangeListener
|
||||
*
|
||||
* @param dataStore the dataStore associated with this monitor
|
||||
*/
|
||||
public DStoreStatusMonitor(DataStore dataStore)
|
||||
{
|
||||
_dataStore = dataStore;
|
||||
reInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void reInit()
|
||||
{
|
||||
_networkDown = false;
|
||||
_workingStatuses = new ArrayList();
|
||||
_doneStatuses = new ArrayList();
|
||||
_cancelledStatuses = new ArrayList();
|
||||
IDomainNotifier notifier = _dataStore.getDomainNotifier();
|
||||
if (notifier != null)
|
||||
{
|
||||
notifier.addDomainListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public DataStore getDataStore()
|
||||
{
|
||||
return _dataStore;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
_workingStatuses.clear();
|
||||
_doneStatuses.clear();
|
||||
_cancelledStatuses.clear();
|
||||
_dataStore.getDomainNotifier().removeDomainListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#listeningTo(DomainEvent)
|
||||
*/
|
||||
public boolean listeningTo(DomainEvent event)
|
||||
{
|
||||
if (_workingStatuses.size() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
DataElement parent = (DataElement)event.getParent();
|
||||
if (_workingStatuses.contains(parent))
|
||||
{
|
||||
return determineStatusDone(parent);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see IDomainListener#domainChanged(DomainEvent)
|
||||
*/
|
||||
public void domainChanged(DomainEvent event)
|
||||
{
|
||||
if (_workingStatuses.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataElement parent = (DataElement)event.getParent();
|
||||
if (_workingStatuses.contains(parent))
|
||||
{
|
||||
boolean isStatusDone = determineStatusDone(parent);
|
||||
if (isStatusDone)
|
||||
{
|
||||
setDone(parent);
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the status is done.
|
||||
* @return <code>true</code> if status done, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean determineStatusDone(DataElement status)
|
||||
{
|
||||
return status.getAttribute(DE.A_VALUE).equals("done") || status.getAttribute(DE.A_NAME).equals("done");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the the monitor is passive. In this case it is false.
|
||||
*/
|
||||
public boolean isPassiveCommunicationsListener()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* setDone(boolean)
|
||||
*/
|
||||
public synchronized void setDone(DataElement status)
|
||||
{
|
||||
_workingStatuses.remove(status);
|
||||
_doneStatuses.add(status);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void setCancelled(DataElement status)
|
||||
{
|
||||
_workingStatuses.remove(status);
|
||||
_cancelledStatuses.add(status);
|
||||
}
|
||||
|
||||
public synchronized void setWorking(DataElement status)
|
||||
{
|
||||
_workingStatuses.add(status);
|
||||
}
|
||||
|
||||
|
||||
public boolean wasCancelled(DataElement status)
|
||||
{
|
||||
if (_cancelledStatuses.contains(status))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#getShell()
|
||||
*/
|
||||
public Shell getShell()
|
||||
{
|
||||
// dy: DomainNotifier (which calls this method) requires the shell not be disposed
|
||||
//if (shell == null) {
|
||||
if (_shell == null || _shell.isDisposed())
|
||||
{
|
||||
FindShell findShell = new FindShell();
|
||||
Display.getDefault().syncExec(findShell);
|
||||
_shell = findShell.shell;
|
||||
}
|
||||
return _shell;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if the StatusChangeListener returned because the network connection to the
|
||||
* remote system was broken.
|
||||
*/
|
||||
public boolean isNetworkDown()
|
||||
{
|
||||
return _networkDown;
|
||||
}
|
||||
|
||||
public DataElement waitForUpdate(DataElement status) throws InterruptedException
|
||||
{
|
||||
return waitForUpdate(status, null, 0);
|
||||
}
|
||||
|
||||
public DataElement waitForUpdate(DataElement status, IProgressMonitor monitor) throws InterruptedException
|
||||
{
|
||||
return waitForUpdate(status, monitor, 0);
|
||||
}
|
||||
|
||||
public DataElement waitForUpdate(DataElement status, int wait) throws InterruptedException
|
||||
{
|
||||
return waitForUpdate(status, null, wait);
|
||||
}
|
||||
|
||||
public synchronized DataElement waitForUpdate(DataElement status, IProgressMonitor monitor, int wait) throws InterruptedException
|
||||
{
|
||||
if (_networkDown && status.getDataStore().isConnected())
|
||||
{
|
||||
reInit();
|
||||
}
|
||||
if (determineStatusDone(status))
|
||||
{
|
||||
setDone(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
setWorking(status);
|
||||
|
||||
Display display = Display.getCurrent();
|
||||
|
||||
|
||||
// Prevent infinite looping by introducing a threshold for wait
|
||||
int WaitThreshold = 600; //default. sleep(100ms) for 600 times
|
||||
if ( wait > 0 )
|
||||
WaitThreshold = wait*10; // 1 second means 10 sleep(100ms)
|
||||
else if ( wait == -1 ) // force a diagnostic
|
||||
WaitThreshold = -1;
|
||||
|
||||
|
||||
if (display != null)
|
||||
{
|
||||
// Current thread is UI thread
|
||||
while (_workingStatuses.contains(status))
|
||||
{
|
||||
// Process everything on event queue
|
||||
while (display.readAndDispatch()) {}
|
||||
|
||||
if ((monitor != null) && (monitor.isCanceled()))
|
||||
{
|
||||
setCancelled(status);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
boolean statusDone = determineStatusDone(status);
|
||||
|
||||
if (statusDone)
|
||||
{
|
||||
setDone(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
waitForUpdate();
|
||||
//Thread.sleep(100);
|
||||
|
||||
if (WaitThreshold > 0) // update timer count if
|
||||
// threshold not reached
|
||||
--WaitThreshold; // decrement the timer count
|
||||
|
||||
if (WaitThreshold == 0)
|
||||
{
|
||||
// no diagnostic factory but there is a timeout
|
||||
return status; // returning the undone status object
|
||||
}
|
||||
else if (_networkDown)
|
||||
{
|
||||
dispose();
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Current thread is not UI thread
|
||||
while (_workingStatuses.contains(status))
|
||||
{
|
||||
|
||||
if ((monitor != null) && (monitor.isCanceled()))
|
||||
{
|
||||
setCancelled(status);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
boolean statusDone = determineStatusDone(status);
|
||||
|
||||
if (statusDone)
|
||||
{
|
||||
setDone(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
waitForUpdate();
|
||||
//Thread.sleep(200);
|
||||
|
||||
if (WaitThreshold > 0) // update timer count if
|
||||
// threshold not reached
|
||||
--WaitThreshold; // decrement the timer count
|
||||
|
||||
if (WaitThreshold == 0)
|
||||
{
|
||||
// no diagnostic factory but there is a timeout
|
||||
return status; // returning the undone status object
|
||||
}
|
||||
else if (_networkDown)
|
||||
{
|
||||
dispose();
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Causes the current thread to wait until this class request has been
|
||||
* fulfilled.
|
||||
*/
|
||||
public synchronized void waitForUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
wait(200);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes all threads waiting for this class request to be filled
|
||||
* to wake up.
|
||||
*/
|
||||
public synchronized void notifyUpdate()
|
||||
{
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,335 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.util;
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.dstore.ServiceResources;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.extra.internal.extra.DomainEvent;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainListener;
|
||||
|
||||
public class DownloadListener implements IDomainListener,IUniversalDataStoreConstants
|
||||
{
|
||||
|
||||
private DataElement _status;
|
||||
private IProgressMonitor _monitor;
|
||||
private DataStore _dataStore;
|
||||
private File _localFile;
|
||||
private Display _display;
|
||||
|
||||
private boolean _networkDown = false;
|
||||
private boolean _isDone = false;
|
||||
private boolean _isCancelled = false;
|
||||
private long _totalBytesNotified = 0;
|
||||
private long _totalLength;
|
||||
|
||||
private static String _percentMsg = SystemMessage.sub(SystemMessage.sub(SystemMessage.sub(ServiceResources.DStore_Service_Percent_Complete_Message, "&0", "{0}"), "&1", "{1}"), "&2", "{2}");
|
||||
|
||||
public DownloadListener(IProgressMonitor monitor, DataElement status, File localFile, String remotePath, long totalLength)
|
||||
{
|
||||
_monitor = monitor;
|
||||
_status = status;
|
||||
_totalLength = totalLength;
|
||||
_display = Display.getCurrent();
|
||||
|
||||
if (_status == null)
|
||||
{
|
||||
System.out.println("Status is null!");
|
||||
}
|
||||
|
||||
_dataStore = _status.getDataStore();
|
||||
_dataStore.getDomainNotifier().addDomainListener(this);
|
||||
|
||||
_localFile = localFile;
|
||||
|
||||
if (monitor != null)
|
||||
{
|
||||
if (_display != null)
|
||||
{
|
||||
while (_display.readAndDispatch())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (_status.getValue().equals("done"))
|
||||
{
|
||||
updateDownloadState();
|
||||
setDone(true);
|
||||
}
|
||||
|
||||
}
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
public DataElement getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#listeningTo(DomainEvent)
|
||||
*/
|
||||
public boolean listeningTo(DomainEvent event)
|
||||
{
|
||||
if (_status == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_status == event.getParent())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#domainChanged(DomainEvent)
|
||||
*/
|
||||
public void domainChanged(DomainEvent event)
|
||||
{
|
||||
if (_status.getValue().equals("done"))
|
||||
{
|
||||
|
||||
if (_status == event.getParent())
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateDownloadState();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDownloadState()
|
||||
{
|
||||
|
||||
if (_monitor != null)
|
||||
{
|
||||
long currentLength = _localFile.length();
|
||||
long delta = currentLength - _totalBytesNotified;
|
||||
if (delta > 0)
|
||||
{
|
||||
//System.out.println(_status.getAttribute(DE.A_SOURCE));
|
||||
_monitor.worked((int)delta);
|
||||
|
||||
try
|
||||
{
|
||||
long percent = (currentLength * 100) / _totalLength;
|
||||
|
||||
|
||||
StringBuffer current = new StringBuffer();
|
||||
current.append(currentLength /KB_IN_BYTES);
|
||||
current.append(" KB");
|
||||
|
||||
StringBuffer total = new StringBuffer();
|
||||
total.append(_totalLength / KB_IN_BYTES);
|
||||
total.append(" KB");
|
||||
|
||||
StringBuffer percentBuf = new StringBuffer();
|
||||
percentBuf.append(percent);
|
||||
percentBuf.append("%");
|
||||
|
||||
String str = MessageFormat.format(_percentMsg, new Object[] {current, total, percentBuf});
|
||||
|
||||
_monitor.subTask(str);
|
||||
|
||||
if (_display != null)
|
||||
{
|
||||
while (_display.readAndDispatch())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
_totalBytesNotified = currentLength;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_status.getDataStore().getStatus().getName().equals("okay"))
|
||||
{
|
||||
_networkDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setDone(boolean)
|
||||
*/
|
||||
public void setDone(boolean done)
|
||||
{
|
||||
this._isDone = done;
|
||||
if (done)
|
||||
{
|
||||
updateDownloadState();
|
||||
_status.getDataStore().getDomainNotifier().removeDomainListener(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean wasCancelled()
|
||||
{
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Wait for the the status DataElement to be refreshed
|
||||
*
|
||||
* @param
|
||||
* ICommunicationsDiagnosticFactory factory : for creating system specific diagnostic class instance
|
||||
* Int wait : threshold for starting diagnostic. Default is 60 seconds; a zero means to use the default.
|
||||
* -1 means to force a timeout; mainly for testing purpose.
|
||||
*
|
||||
* @return The status DataElement after it has been updated, or the user
|
||||
* has pressed cancel
|
||||
*
|
||||
* @throws InterruptedException if the thread was interrupted.
|
||||
*/
|
||||
public DataElement waitForUpdate() throws InterruptedException
|
||||
{
|
||||
return waitForUpdate(0); //No diagnostic
|
||||
}
|
||||
|
||||
|
||||
public DataElement waitForUpdate(int wait) throws InterruptedException
|
||||
{
|
||||
Display display = _display;
|
||||
|
||||
if (wait > 0)
|
||||
{
|
||||
}
|
||||
else if (wait == -1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (display != null)
|
||||
{
|
||||
|
||||
// Current thread is UI thread
|
||||
while (!_isDone && !_isCancelled && !_networkDown)
|
||||
{
|
||||
// Process everything on event queue
|
||||
while (display.readAndDispatch())
|
||||
{
|
||||
}
|
||||
|
||||
if ((_monitor != null) && (_monitor.isCanceled()))
|
||||
{
|
||||
// cancel remote request
|
||||
cancelDownload();
|
||||
_isCancelled = true;
|
||||
setDone(true);
|
||||
}
|
||||
else if (_networkDown)
|
||||
{
|
||||
_isCancelled = true;
|
||||
setDone(true);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
if (getStatus().getAttribute(DE.A_NAME).equals("done"))
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.sleep(100);
|
||||
updateDownloadState();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Current thread is not UI thread
|
||||
while (!_isDone && !_isCancelled && !_networkDown)
|
||||
{
|
||||
if ((_monitor != null) && (_monitor.isCanceled()))
|
||||
{
|
||||
cancelDownload();
|
||||
_isCancelled = true;
|
||||
setDone(true);
|
||||
}
|
||||
else if (_networkDown)
|
||||
{
|
||||
_isCancelled = true;
|
||||
setDone(true);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
if (getStatus().getAttribute(DE.A_NAME).equals("done"))
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.sleep(100);
|
||||
updateDownloadState();
|
||||
}
|
||||
}
|
||||
}
|
||||
return _status;
|
||||
}
|
||||
|
||||
public void cancelDownload()
|
||||
{
|
||||
DataElement status = _status;
|
||||
if (status != null)
|
||||
{
|
||||
DataElement command = status.getParent();
|
||||
DataStore dataStore = command.getDataStore();
|
||||
DataElement cmdDescriptor = command.getDescriptor();
|
||||
DataElement cancelDescriptor = dataStore.localDescriptorQuery(cmdDescriptor, "C_CANCEL");
|
||||
if (cancelDescriptor != null)
|
||||
{
|
||||
dataStore.command(cancelDescriptor, command);
|
||||
}
|
||||
_localFile.delete();
|
||||
}
|
||||
if (_monitor != null)
|
||||
{
|
||||
_monitor.done();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.eclipse.rse.services.dstore.util;
|
||||
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
|
||||
public class FileSystemMessageUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the source message (first part of the source attribute) for this element.
|
||||
*
|
||||
* @return the source message
|
||||
*/
|
||||
public static String getSourceMessage(DataElement element)
|
||||
{
|
||||
String source = element.getSource();
|
||||
if (source == null) return null;
|
||||
if (source.equals("")) return "";
|
||||
int sepIndex = source.indexOf("|");
|
||||
if (sepIndex == -1) return source;
|
||||
else return source.substring(0, sepIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source location (second part of the source attribute) for this element.
|
||||
*
|
||||
* @return the source location
|
||||
*/
|
||||
public static String getSourceLocation(DataElement element)
|
||||
{
|
||||
String source = element.getSource();
|
||||
if (source == null) return null;
|
||||
if (source.equals("")) return "";
|
||||
int sepIndex = source.indexOf("|");
|
||||
if (sepIndex == -1) return "";
|
||||
else return source.substring(sepIndex+1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,330 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.util;
|
||||
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import org.eclipse.dstore.core.model.DE;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.extra.internal.extra.DomainEvent;
|
||||
import org.eclipse.dstore.extra.internal.extra.IDomainListener;
|
||||
|
||||
/*
|
||||
* Utility class for determining when a DataStore command is complete via the status.
|
||||
*/
|
||||
public class StatusChangeListener implements IDomainListener
|
||||
{
|
||||
|
||||
protected DataElement target;
|
||||
protected Shell shell;
|
||||
protected IProgressMonitor monitor;
|
||||
|
||||
protected boolean _networkDown = false;
|
||||
protected boolean done = false;
|
||||
protected boolean cancelled = false;
|
||||
|
||||
protected Vector historyOfTargets;
|
||||
|
||||
protected class FindShell implements Runnable {
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* @see Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
try {
|
||||
Shell[] shells = Display.getCurrent().getShells();
|
||||
for (int loop = 0; loop < shells.length && shell == null; loop++) {
|
||||
if (shells[loop].isEnabled()) {
|
||||
shell = shells[loop];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a StatusChangeListener
|
||||
*
|
||||
* @param shell A valid Shell object
|
||||
*
|
||||
* @param monitor A progress monitor if you want this object to check if
|
||||
* the user presses cancel while waiting for the status object
|
||||
* to be updated
|
||||
*
|
||||
* @param target The status DataElement for which you wish to wait for an update
|
||||
*/
|
||||
public StatusChangeListener(Shell shell, IProgressMonitor monitor, DataElement target) {
|
||||
this.shell = shell;
|
||||
this.monitor = monitor;
|
||||
this.target = target;
|
||||
historyOfTargets = new Vector();
|
||||
}
|
||||
|
||||
|
||||
public StatusChangeListener(Shell shell, IProgressMonitor monitor) {
|
||||
this(shell, monitor, null);
|
||||
}
|
||||
|
||||
|
||||
// public StatusChangeListener(Shell shell, DataElement target) {
|
||||
// this(shell, null, target);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setStatus(DataElement p_target)
|
||||
{
|
||||
this.target = p_target;
|
||||
|
||||
for (int i = 0; i < historyOfTargets.size(); i++)
|
||||
{
|
||||
if (target == historyOfTargets.elementAt(i))
|
||||
{
|
||||
setDone( true );
|
||||
historyOfTargets.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
historyOfTargets.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DataElement getStatus()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#listeningTo(DomainEvent)
|
||||
*/
|
||||
public boolean listeningTo(DomainEvent event) {
|
||||
if (target == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == event.getParent()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see IDomainListener#domainChanged(DomainEvent)
|
||||
*/
|
||||
public void domainChanged(DomainEvent event) {
|
||||
if (target == null)
|
||||
{
|
||||
if (historyOfTargets.size() < 1000)
|
||||
{
|
||||
historyOfTargets.addElement(event.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
if (target == event.getParent())
|
||||
{
|
||||
boolean isStatusDone = determineStatusDone();
|
||||
|
||||
if (isStatusDone)
|
||||
{
|
||||
setDone( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setDone(boolean)
|
||||
*/
|
||||
public void setDone(boolean done)
|
||||
{
|
||||
this.done = done;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDomainListener#getShell()
|
||||
*/
|
||||
public Shell getShell() {
|
||||
// dy: DomainNotifier (which calls this method) requires the shell not be disposed
|
||||
//if (shell == null) {
|
||||
if (shell == null || shell.isDisposed())
|
||||
{
|
||||
FindShell findShell = new FindShell();
|
||||
Display.getDefault().syncExec(findShell);
|
||||
shell = findShell.shell;
|
||||
}
|
||||
return shell;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean wasCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Wait for the the status DataElement to be refreshed
|
||||
*
|
||||
* @param
|
||||
* ICommunicationsDiagnosticFactory factory : for creating system specific diagnostic class instance
|
||||
* Int wait : threshold for starting diagnostic. Default is 60 seconds; a zero means to use the default.
|
||||
* -1 means to force a timeout; mainly for testing purpose.
|
||||
*
|
||||
* @return The status DataElement after it has been updated, or the user
|
||||
* has pressed cancel
|
||||
*
|
||||
* @throws InterruptedException if the thread was interrupted.
|
||||
*/
|
||||
public DataElement waitForUpdate() throws InterruptedException
|
||||
{
|
||||
return waitForUpdate( 0); //No diagnostic
|
||||
}
|
||||
|
||||
|
||||
public DataElement waitForUpdate(int wait) throws InterruptedException
|
||||
{
|
||||
boolean statusDone = determineStatusDone();
|
||||
if (statusDone)
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Display display = Display.getCurrent();
|
||||
|
||||
if ( wait > 0 )
|
||||
{
|
||||
}
|
||||
else if ( wait == -1 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if (display != null) {
|
||||
if (shell == null || shell.isDisposed()) {
|
||||
shell = Display.getDefault().getActiveShell();
|
||||
}
|
||||
// Current thread is UI thread
|
||||
while (!done && !cancelled) {
|
||||
// Process everything on event queue
|
||||
while (display.readAndDispatch()) {
|
||||
}
|
||||
|
||||
if ((monitor != null) && (monitor.isCanceled())) {
|
||||
cancelled = true;
|
||||
target.getDataStore().getDomainNotifier().removeDomainListener(this);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
statusDone = determineStatusDone();
|
||||
|
||||
if (statusDone)
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.sleep(100);
|
||||
if (_networkDown)
|
||||
{
|
||||
target.getDataStore().getDomainNotifier().removeDomainListener(this);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Current thread is not UI thread
|
||||
while (!done && !cancelled)
|
||||
{
|
||||
|
||||
if ((monitor != null) && (monitor.isCanceled()))
|
||||
{
|
||||
cancelled = true;
|
||||
target.getDataStore().getDomainNotifier().removeDomainListener(this);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
statusDone = determineStatusDone();
|
||||
|
||||
if (statusDone)
|
||||
{
|
||||
setDone(true);
|
||||
}
|
||||
else {
|
||||
Thread.sleep(100);
|
||||
|
||||
if (_networkDown)
|
||||
{
|
||||
target.getDataStore().getDomainNotifier().removeDomainListener(this);
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset done so we can detect the next event if waitForUpdate
|
||||
// is called again
|
||||
done = false;
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the status is done.
|
||||
* @return <code>true</code> if status done, <code>false</code> otherwise.
|
||||
*/
|
||||
protected boolean determineStatusDone() {
|
||||
return getStatus().getAttribute(DE.A_VALUE).equals("done") || getStatus().getAttribute(DE.A_NAME).equals("done");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
|
||||
*/
|
||||
public boolean isPassiveCommunicationsListener() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the StatusChangeListener returned because the network connection to the
|
||||
* remote system was broken.
|
||||
*/
|
||||
public boolean isNetworkDown() {
|
||||
return _networkDown;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
bin
|
28
rse/plugins/org.eclipse.rse.services.files.ftp/.project
Normal file
28
rse/plugins/org.eclipse.rse.services.files.ftp/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.rse.services.files.ftp</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,14 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: org.eclipse.rse.services.files.ftp
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: org.eclipse.rse.services.files.ftp.Activator
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.services.files.ftp
|
||||
Bundle-ClassPath: ftpfiles.jar
|
22
rse/plugins/org.eclipse.rse.services.files.ftp/about.html
Normal file
22
rse/plugins/org.eclipse.rse.services.files.ftp/about.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>February 24, 2005</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
# about.properties
|
||||
# contains externalized strings for about.ini
|
||||
# java.io.Properties file (ISO 8859-1 with "\" escapes)
|
||||
# fill-ins are supplied by about.mappings
|
||||
# This file should be translated.
|
||||
#
|
||||
# Do not translate any values surrounded by {}
|
||||
|
||||
blurb=Remote System Explorer FTP services\n\
|
||||
\n\
|
||||
Version: {featureVersion}\n\
|
||||
Build id: {0}\n\
|
||||
\n\
|
||||
(c) Copyright Eclipse contributors and others 2000, 2006. All rights reserved.\n\
|
||||
Visit http://www.eclipse.org/dsdp/tm/
|
|
@ -0,0 +1,12 @@
|
|||
bin.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties,\
|
||||
ftpfiles.jar
|
||||
src.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties
|
||||
source.ftpfiles.jar = src/
|
||||
jars.compile.order = ftpfiles.jar
|
||||
output.ftpfiles.jar = bin/
|
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
plugin.name = RSE FTP services
|
|
@ -0,0 +1,70 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import org.eclipse.ui.plugin.*;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The main plugin class to be used in the desktop.
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
//The shared instance.
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public Activator() {
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon plug-in activation
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the plug-in is stopped
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
super.stop(context);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance.
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given
|
||||
* plug-in relative path.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return AbstractUIPlugin.imageDescriptorFromPlugin("com.ibm.rse.universal.services.ftp", path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.net.ftp.FtpClient;
|
||||
|
||||
public class FTPClientService extends FtpClient
|
||||
{
|
||||
public int sendCommand(String command)
|
||||
{
|
||||
try
|
||||
{
|
||||
return issueCommand(command);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
|
||||
public class FTPHostFile implements IHostFile
|
||||
{
|
||||
private String _name;
|
||||
private String _parentPath;
|
||||
private boolean _isDirectory = false;
|
||||
private boolean _isRoot = false;
|
||||
private boolean _isArchive = false;
|
||||
private long _lastModified = 0;
|
||||
private long _size = 0;
|
||||
|
||||
public FTPHostFile(String parentPath, String name, boolean isDirectory, boolean isRoot, long lastModified, long size)
|
||||
{
|
||||
_parentPath = parentPath;
|
||||
_name = name;
|
||||
_isDirectory = isDirectory;
|
||||
_isRoot = isRoot;
|
||||
_lastModified = lastModified;
|
||||
_size = size;
|
||||
_isArchive = internalIsArchive();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
String name = getName();
|
||||
return name.charAt(0) == '.';
|
||||
|
||||
}
|
||||
|
||||
public String getParentPath()
|
||||
{
|
||||
return _parentPath;
|
||||
}
|
||||
|
||||
public boolean isDirectory()
|
||||
{
|
||||
return _isDirectory;
|
||||
}
|
||||
|
||||
public boolean isFile()
|
||||
{
|
||||
return !(_isDirectory || _isRoot);
|
||||
}
|
||||
|
||||
public boolean isRoot()
|
||||
{
|
||||
return _isRoot;
|
||||
}
|
||||
|
||||
public boolean exists()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getAbsolutePath()
|
||||
{
|
||||
|
||||
StringBuffer path = new StringBuffer(getParentPath());
|
||||
if (!_parentPath.endsWith("/"))
|
||||
{
|
||||
path.append('/');
|
||||
}
|
||||
path.append(getName());
|
||||
|
||||
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public long getSize()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
public long getModifiedDate()
|
||||
{
|
||||
return _lastModified;
|
||||
}
|
||||
|
||||
public void renameTo(String newAbsolutePath)
|
||||
{
|
||||
int i = newAbsolutePath.lastIndexOf("/");
|
||||
if (i == -1)
|
||||
{
|
||||
_name = newAbsolutePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
_parentPath = newAbsolutePath.substring(0, i);
|
||||
_name = newAbsolutePath.substring(i+1);
|
||||
}
|
||||
|
||||
_isArchive = internalIsArchive();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected boolean internalIsArchive()
|
||||
{
|
||||
return ArchiveHandlerManager.getInstance().isArchive(new File(getAbsolutePath()))
|
||||
&& !ArchiveHandlerManager.isVirtual(getAbsolutePath());
|
||||
}
|
||||
|
||||
public boolean isArchive()
|
||||
{
|
||||
return _isArchive;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FTPLinuxDirectoryListingParser implements IFTPDirectoryListingParser
|
||||
{
|
||||
|
||||
public FTPHostFile getFTPHostFile(String line, String parentPath)
|
||||
{
|
||||
// Note this assumes that text is always formatted the same way
|
||||
if (line == null) return null;
|
||||
String[] tokens = line.split("\\s+", 9);
|
||||
if (tokens.length < 9) return null;
|
||||
String name = tokens[8];
|
||||
boolean isDirectory = line.charAt(0) == 'd';
|
||||
long length = 0;
|
||||
long lastMod = 0;
|
||||
if (tokens.length > 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
length = Long.parseLong(tokens[tokens.length - 5]);
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
|
||||
try
|
||||
{
|
||||
int i = tokens.length - 4;
|
||||
int j = tokens.length - 3;
|
||||
int k = tokens.length - 2;
|
||||
String time = "";
|
||||
String year = "";
|
||||
if (tokens[k].indexOf(":") == -1)
|
||||
{
|
||||
time = "11:59 PM";
|
||||
year = tokens[k];
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] parts = tokens[k].split(":");
|
||||
int hours = Integer.parseInt(parts[0]);
|
||||
boolean morning = hours < 12; // assumes midnight is 00:00
|
||||
if (morning)
|
||||
{
|
||||
if (hours == 0)
|
||||
{
|
||||
hours = 12;
|
||||
}
|
||||
}
|
||||
time = hours + ":" + parts[1] + (morning? " AM" : " PM");
|
||||
year = "" + (Calendar.getInstance().get(Calendar.YEAR));
|
||||
}
|
||||
|
||||
String date = tokens[i] + " " + tokens[j] + ", " + year + " " + time;
|
||||
lastMod = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, new Locale("EN", "US")).parse(date).getTime();
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
return new FTPHostFile(parentPath, name, isDirectory, false, lastMod, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,396 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.AbstractFileService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
|
||||
|
||||
import sun.net.TelnetInputStream;
|
||||
import sun.net.ftp.FtpClient;
|
||||
|
||||
|
||||
|
||||
public class FTPService extends AbstractFileService implements IFileService, IFTPService
|
||||
{
|
||||
private FTPClientService _ftpClient;
|
||||
private String _userHome;
|
||||
private IFTPDirectoryListingParser _ftpPropertiesUtil;
|
||||
|
||||
|
||||
|
||||
private transient String _hostname;
|
||||
private transient String _userId;
|
||||
private transient String _password;
|
||||
|
||||
public FTPService()
|
||||
{
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return FTPServiceResources.FTP_File_Service_Name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return FTPServiceResources.FTP_File_Service_Description;
|
||||
}
|
||||
|
||||
public void setHostName(String hostname)
|
||||
{
|
||||
_hostname = hostname;
|
||||
}
|
||||
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
_userId = userId;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
_password = password;
|
||||
}
|
||||
|
||||
|
||||
public void connect() throws Exception
|
||||
{
|
||||
FtpClient ftp = getFTPClient();
|
||||
ftp.openServer(_hostname);
|
||||
ftp.login(_userId, _password);
|
||||
|
||||
_userHome = ftp.pwd();
|
||||
}
|
||||
|
||||
protected void reconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
connect();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
getFTPClient().closeServer();
|
||||
_ftpClient = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// e.printStackTrace();
|
||||
_ftpClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
public IFTPDirectoryListingParser getDirListingParser()
|
||||
{
|
||||
if (_ftpPropertiesUtil == null)
|
||||
{
|
||||
_ftpPropertiesUtil = new FTPLinuxDirectoryListingParser();
|
||||
}
|
||||
return _ftpPropertiesUtil;
|
||||
}
|
||||
|
||||
public FTPClientService getFTPClient()
|
||||
{
|
||||
if (_ftpClient == null)
|
||||
{
|
||||
_ftpClient = new FTPClientService();
|
||||
}
|
||||
return _ftpClient;
|
||||
}
|
||||
|
||||
public IHostFile getFile(IProgressMonitor monitor, String remoteParent, String fileName)
|
||||
{
|
||||
IHostFile[] matches = internalFetch(monitor, remoteParent, fileName, FILE_TYPE_FILES_AND_FOLDERS);
|
||||
if (matches != null && matches.length > 0)
|
||||
{
|
||||
return matches[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public boolean isConnected()
|
||||
{
|
||||
return getFTPClient().serverIsOpen();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected IHostFile[] internalFetch(IProgressMonitor monitor, String parentPath, String fileFilter, int fileType)
|
||||
{
|
||||
if (fileFilter == null)
|
||||
{
|
||||
fileFilter = "*";
|
||||
}
|
||||
NamePatternMatcher filematcher = new NamePatternMatcher(fileFilter, true, true);
|
||||
List results = new ArrayList();
|
||||
try
|
||||
{
|
||||
FtpClient ftp = getFTPClient();
|
||||
try
|
||||
{
|
||||
ftp.noop();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//e.printStackTrace();
|
||||
disconnect();
|
||||
|
||||
// probably timed out
|
||||
reconnect();
|
||||
ftp = getFTPClient();
|
||||
}
|
||||
|
||||
ftp.cd(parentPath);
|
||||
TelnetInputStream stream = ftp.list();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
String line = reader.readLine();
|
||||
while (line != null)
|
||||
{
|
||||
FTPHostFile node = getDirListingParser().getFTPHostFile(line, parentPath);
|
||||
if (node != null && filematcher.matches(node.getName()))
|
||||
{
|
||||
if (isRightType(fileType, node))
|
||||
{
|
||||
results.add(node);
|
||||
}
|
||||
}
|
||||
line = reader.readLine();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return (IHostFile[])results.toArray(new IHostFile[results.size()]);
|
||||
}
|
||||
|
||||
public String getSeparator()
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
|
||||
|
||||
public boolean upload(IProgressMonitor monitor, File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding)
|
||||
{
|
||||
FtpClient ftp = getFTPClient();
|
||||
try
|
||||
{
|
||||
ftp.cd(remoteParent);
|
||||
if (isBinary)
|
||||
ftp.binary();
|
||||
else
|
||||
ftp.ascii();
|
||||
ftp.put(localFile.getAbsolutePath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean upload(IProgressMonitor monitor, InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding)
|
||||
{
|
||||
// hack for now
|
||||
try
|
||||
{
|
||||
BufferedInputStream bis = new BufferedInputStream(stream);
|
||||
File tempFile = File.createTempFile("ftp", "temp");
|
||||
FileOutputStream os = new FileOutputStream(tempFile);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int readCount;
|
||||
while( (readCount = bis.read(buffer)) > 0)
|
||||
{
|
||||
bos.write(buffer, 0, readCount);
|
||||
}
|
||||
bos.close();
|
||||
|
||||
FtpClient ftp = getFTPClient();
|
||||
try
|
||||
{
|
||||
ftp.cd(remoteParent);
|
||||
if (isBinary)
|
||||
ftp.binary();
|
||||
else
|
||||
ftp.ascii();
|
||||
ftp.put(tempFile.getAbsolutePath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean download(IProgressMonitor monitor, String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding)
|
||||
{
|
||||
FtpClient ftp = getFTPClient();
|
||||
try
|
||||
{
|
||||
ftp.cd(remoteParent);
|
||||
/*
|
||||
if (isBinary)
|
||||
ftp.binary();
|
||||
else
|
||||
ftp.ascii();
|
||||
*/
|
||||
// for now only binary seems to work
|
||||
ftp.binary();
|
||||
|
||||
InputStream is = ftp.get(remoteFile);
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
|
||||
if (!localFile.exists())
|
||||
{
|
||||
File localParentFile = localFile.getParentFile();
|
||||
if (!localParentFile.exists())
|
||||
{
|
||||
localParentFile.mkdirs();
|
||||
}
|
||||
localFile.createNewFile();
|
||||
}
|
||||
OutputStream os = new FileOutputStream(localFile);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int totalWrote = 0;
|
||||
int readCount;
|
||||
while( (readCount = bis.read(buffer)) > 0)
|
||||
{
|
||||
bos.write(buffer, 0, readCount);
|
||||
totalWrote += readCount;
|
||||
}
|
||||
bos.close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IHostFile getUserHome()
|
||||
{
|
||||
int lastSlash = _userHome.lastIndexOf('/');
|
||||
String name = _userHome.substring(lastSlash + 1);
|
||||
String parent = _userHome.substring(0, lastSlash);
|
||||
return getFile(null, parent, name);
|
||||
}
|
||||
|
||||
public IHostFile[] getRoots(IProgressMonitor monitor)
|
||||
{
|
||||
IHostFile root = new FTPHostFile("/", "/", true, true, 0, 0);
|
||||
return new IHostFile[] { root };
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
/********************************************************
|
||||
*
|
||||
* The following APIs need to be implemented
|
||||
*
|
||||
********************************************************/
|
||||
|
||||
public IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean delete(IProgressMonitor monitor, String remoteParent, String fileName) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent) throws SystemMessageException
|
||||
{
|
||||
boolean ok = true;
|
||||
for (int i = 0; i < srcParents.length; i++)
|
||||
{
|
||||
ok = ok && copy(monitor, srcParents[i], srcNames[i], tgtParent, srcNames[i]);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class FTPServiceResources extends NLS
|
||||
{
|
||||
private static String BUNDLE_NAME = "org.eclipse.rse.services.files.ftp.FTPServiceResources";//$NON-NLS-1$
|
||||
|
||||
public static String FTP_File_Service_Name;
|
||||
public static String FTP_File_Service_Description;
|
||||
|
||||
static {
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, FTPServiceResources.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2006 IBM Corporation. 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
|
||||
#
|
||||
# Initial Contributors:
|
||||
# The following IBM employees contributed to the Remote System Explorer
|
||||
# component that contains this file: David McKnight, Kushal Munir,
|
||||
# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
#
|
||||
# Contributors:
|
||||
# {Name} (company) - description of contribution.
|
||||
################################################################################
|
||||
|
||||
FTP_File_Service_Name=FTP File Service
|
||||
FTP_File_Service_Description=The FTP File Service uses the FTP protocol to provide service for the Files subsystem. It requires an FTP daemon to be running on the host machine.
|
|
@ -0,0 +1,36 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
/**
|
||||
* Implementers of this interface provide a way to get
|
||||
* information about file properties from an FTP directory
|
||||
* listing in a way
|
||||
* that might be specific to a certain system type.
|
||||
* @author mjberger
|
||||
*
|
||||
*/
|
||||
public interface IFTPDirectoryListingParser
|
||||
{
|
||||
/**
|
||||
* Return an FTPHostFile representing a line from an FTP directory listing
|
||||
* @param line The line of text from the directory listing
|
||||
* @param parentPath The directory that this is a listing of
|
||||
* @return null if the line is not well formed
|
||||
*/
|
||||
public FTPHostFile getFTPHostFile(String line, String parentPath);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files.ftp;
|
||||
|
||||
public interface IFTPService
|
||||
{
|
||||
|
||||
}
|
7
rse/plugins/org.eclipse.rse.services.local/.classpath
Normal file
7
rse/plugins/org.eclipse.rse.services.local/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
rse/plugins/org.eclipse.rse.services.local/.cvsignore
Normal file
1
rse/plugins/org.eclipse.rse.services.local/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
bin
|
28
rse/plugins/org.eclipse.rse.services.local/.project
Normal file
28
rse/plugins/org.eclipse.rse.services.local/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.rse.services.local</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,20 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: org.eclipse.rse.services.local;singleton:=true
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: org.eclipse.rse.services.local.Activator
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.internal.services.local.search,
|
||||
org.eclipse.rse.internal.services.local.shells,
|
||||
org.eclipse.rse.services.local,
|
||||
org.eclipse.rse.services.local.files,
|
||||
org.eclipse.rse.services.local.processes,
|
||||
org.eclipse.rse.services.local.search,
|
||||
org.eclipse.rse.services.local.shells
|
||||
Bundle-ClassPath: localfiles.jar
|
22
rse/plugins/org.eclipse.rse.services.local/about.html
Normal file
22
rse/plugins/org.eclipse.rse.services.local/about.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>February 24, 2005</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
25
rse/plugins/org.eclipse.rse.services.local/about.properties
Normal file
25
rse/plugins/org.eclipse.rse.services.local/about.properties
Normal file
|
@ -0,0 +1,25 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
# about.properties
|
||||
# contains externalized strings for about.ini
|
||||
# java.io.Properties file (ISO 8859-1 with "\" escapes)
|
||||
# fill-ins are supplied by about.mappings
|
||||
# This file should be translated.
|
||||
#
|
||||
# Do not translate any values surrounded by {}
|
||||
|
||||
blurb=Remote System Explorer local services\n\
|
||||
\n\
|
||||
Version: {featureVersion}\n\
|
||||
Build id: {0}\n\
|
||||
\n\
|
||||
(c) Copyright Eclipse contributors and others 2000, 2006. All rights reserved.\n\
|
||||
Visit http://www.eclipse.org/dsdp/tm/
|
12
rse/plugins/org.eclipse.rse.services.local/build.properties
Normal file
12
rse/plugins/org.eclipse.rse.services.local/build.properties
Normal file
|
@ -0,0 +1,12 @@
|
|||
bin.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties,\
|
||||
localfiles.jar
|
||||
src.includes = META-INF/,\
|
||||
about.html,\
|
||||
about.properties,\
|
||||
plugin.properties
|
||||
source.localfiles.jar = src/
|
||||
jars.compile.order = localfiles.jar
|
||||
output.localfiles.jar = bin/
|
269
rse/plugins/org.eclipse.rse.services.local/patterns.dat
Normal file
269
rse/plugins/org.eclipse.rse.services.local/patterns.dat
Normal file
|
@ -0,0 +1,269 @@
|
|||
#
|
||||
# parse command line output.
|
||||
#
|
||||
# CLICK THIS LINE TO EDIT THIS FILE (PATTERNS.DAT). (When viewing from the Output view)
|
||||
|
||||
command: grep -n.*
|
||||
grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.*
|
||||
|
||||
command: grep -.*n.*
|
||||
grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.*
|
||||
|
||||
command: grep .*
|
||||
grep file pattern =([\w,.,/,(,)\\,\-,\+,\d]*):.*
|
||||
|
||||
|
||||
command: pwd
|
||||
directory file pattern=([\w,.,/,(,),\\,\-,\+,\d,:]*)
|
||||
|
||||
command: nmake.*
|
||||
error pattern=NMAKE : .*
|
||||
error file line pattern =([\w,.,\-,\+,(,),\\,:]*)\((\d*):(\d*)\) : error EDC.*
|
||||
error file pattern =[\w,.,\-,\+,(,),\\,:]*\(([\w,.,/,\\]*)\) : error LNK.*
|
||||
error file line pattern=([\w,.,/,\-,\+,(,),\\]*):(\d*):\d*\) : error .*
|
||||
warning file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : warning .*
|
||||
informational file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : informational .*
|
||||
|
||||
command: make.*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(E\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
#iseries c compiler
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
#makefile errors
|
||||
error file line pattern=\"([\w,\.,/,(,),\-,\+,\\]*)\", line (\d*): make:.*
|
||||
#xlc Options warnings
|
||||
warning pattern=\(W\) Option .*
|
||||
#c89 errors
|
||||
error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
informational pattern=CBC\d*\(I\) .*
|
||||
|
||||
command: gmake.*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
# ixlc compiler
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
# icc compiler
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.*
|
||||
error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.*
|
||||
#generic
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: gcc\s.*
|
||||
error file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
warning file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*): warning: .*
|
||||
warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.*
|
||||
informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*):
|
||||
|
||||
command: cc\s.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: CC\s.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.*
|
||||
|
||||
command: c89.*
|
||||
error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .*
|
||||
informational pattern=CBC\d*\(I\) .*
|
||||
|
||||
command: icc.*
|
||||
error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.*
|
||||
error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.*
|
||||
|
||||
command: javac.*
|
||||
warning file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*): warning.*
|
||||
error file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*):.*
|
||||
|
||||
command: .*bat\s.*
|
||||
error file line pattern=\[javac\]\s([\w,.,/,\\,:]*):(\d*):.*
|
||||
error file line pattern=file:([\w,.,/,\\,:]*):(\d*):.*
|
||||
|
||||
command: dir.*
|
||||
directory file pattern=\d{2}/\d{2}/\d*\s\d{2}:\d{2}[a,p,AM,PM,\s].*\s*<DIR>\s*([\w,.,/,\\,\s,\-,\+\+,\d]*).*
|
||||
file file pattern=\d{2}/\d{2}/\d*\s\d{2}:\d{2}[a,p,AM,PM,\s].*\s*[\d,,]* ([\w,.,/,\\,\s,\-,\+\+,\d]*).*
|
||||
directory file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*<DIR>\s*([\w,.,/,\\,\s,\-,\+\+,\d]*)
|
||||
file file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*[\d,,,.]*\s*([\w,.,/,\\,\s,\-,\+\+,\d]*)
|
||||
|
||||
command: ls -l.*
|
||||
file file pattern=-[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
file file pattern=l[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
file file pattern=l.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
file file pattern=l.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]*
|
||||
directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)
|
||||
|
||||
command: ls -a.*
|
||||
file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*)
|
||||
|
||||
command: ls
|
||||
file file pattern=([\w,\d,.,(,),\-,\+\s]+)
|
||||
|
||||
command: ls\s.*
|
||||
file file pattern=([\w,\d,.,(,),\-,\+\s]+)
|
||||
|
||||
command: .*
|
||||
prompt file pattern=([\w,.,/,(,),\\,\-,\+,\d,:,\s]*)>.*
|
||||
|
||||
command: find .*
|
||||
file file pattern=([\w,.,/,\\,(,),\-]+)
|
||||
|
||||
command: env
|
||||
pathenvvar file pattern=PATH\=(.*)
|
||||
libpathenvvar file pattern=LIBPATH\=(.*)
|
||||
libpathenvvar file pattern=LIB\=(.*)
|
||||
envvar pattern=[\w\d]+\=.*
|
||||
|
||||
command: ps
|
||||
process pattern=[\s]*[\d]+\s.*
|
||||
|
||||
command: ps .*
|
||||
process pattern=[\s]*[\d]+\s.*
|
||||
|
||||
command: xl[C,c].*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(S\).*
|
||||
error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(E\).*
|
||||
warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).*
|
||||
informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).*
|
||||
|
||||
command: ixlc.*
|
||||
error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.*
|
||||
error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .*
|
||||
|
||||
command: cat.*patterns.*
|
||||
warning file pattern=# .*(PATTERNS.DAT).*
|
||||
Output pattern=command: .*
|
||||
#statement pattern=#.*
|
||||
statement pattern=.* pattern.*=.*
|
||||
|
||||
# special for autoconf
|
||||
command: ./bootstrap.sc.*
|
||||
error file line pattern=aclocal: ([\w,.,/,\\]*): (\d*):.*
|
||||
warning file line pattern=([\w,.,/,\\]*):(\d*):.*
|
||||
|
||||
command: ./configure.*
|
||||
error file line pattern=./(configure): line (\d*): .*
|
||||
|
||||
# How Patterns Work
|
||||
# -----------------
|
||||
#
|
||||
# Patterns are used by the Output View to allow lines that contain file names and
|
||||
# perhaps line numbers to be clicked to cause the file location to be opened in an Editor.
|
||||
# A line in this file can be 1 of 3 things:
|
||||
# 1. An empty line or a comment line (denoted by a # in column 1)
|
||||
# 2. The start of a command description (denoted by a 'command:' at the beginning of the line)
|
||||
# 3. A pattern description.
|
||||
# A formal description of the syntax of this file is included at the bottom of this file.
|
||||
#
|
||||
#
|
||||
# Command Descriptions
|
||||
# --------------------
|
||||
#
|
||||
# A Command Description consists of 2 things: A regular expression that describes the
|
||||
# command invocation, and a list of Pattern Descriptions. The regular expression
|
||||
# is used to determine what set of Pattern Descriptons to use when parsing command output.
|
||||
# For example, if you type the command 'gmake clean', the Command Descriptions are checked and
|
||||
# .*make.* would match that command. Therefore the Pattern Descriptions for .*make.* would
|
||||
# be used to parse the output of the 'gmake clean'.
|
||||
# Note: The first Command Description that is found to match the command is used, so make
|
||||
# sure you put the most specific patterns first. For example, if the nmake.* Command
|
||||
# Description appeared after .*make.*, then 'nmake install' would be matched by the .*make.*
|
||||
# Command Descripton, which is probably not what was intended.
|
||||
#
|
||||
#
|
||||
# Pattern Descriptions
|
||||
# --------------------
|
||||
#
|
||||
# A Pattern Description has the following form:
|
||||
# <obj-name> <match-info> "pattern="<reg-ex>
|
||||
#
|
||||
# where:
|
||||
# <obj-name>: The type of object that will be created in the Output View if
|
||||
# a line of output matches this pattern. If you have put an
|
||||
# icon called "<object-name>.gif" in the com.ibm.etools.systems.dstore.core/icons
|
||||
# directory, then the icon will be displayed in the view.
|
||||
#
|
||||
# <match-info>: This is some combination of the words "file" and "line" or nothing
|
||||
# at all. This is used to define how the backreferences in the
|
||||
# regular expression are to be interpreted. So "file line" means
|
||||
# that the first back-reference is a file, and the second is a
|
||||
# line number. This may seem unnecessary, but we added this capability
|
||||
# in the event that future releases support other types of information
|
||||
# that may be useful, such as column info (once we support it).
|
||||
#
|
||||
# <reg-ex>: A regular expression that describes a line of output. Backreferences
|
||||
# are used to store (instead of just match) the filename and line
|
||||
# number. To store a filename use the backreference ([\w,.,/,\\]*), and
|
||||
# to store a line number, use (\d*)
|
||||
#
|
||||
#
|
||||
# Note: The patterns are checked against command output and only exact matches are dealt with
|
||||
# So as an example, if you forget the .* (match everything) at the end of a pattern,
|
||||
# the match will fail if there are trailing characters in the output not accounted for by
|
||||
# the pattern
|
||||
#
|
||||
#
|
||||
# Pattern File Syntax
|
||||
# -------------------
|
||||
#
|
||||
# The pattern file syntax should be easy to grasp by looking at the ones
|
||||
# above, but for those of you who like formal grammars, here it is:
|
||||
#
|
||||
# patterns-file:
|
||||
# commands
|
||||
#
|
||||
# commands:
|
||||
# command
|
||||
# commands new-line command
|
||||
#
|
||||
# command:
|
||||
# "command:" reg-ex new-line patterns
|
||||
#
|
||||
# patterns:
|
||||
# pattern
|
||||
# patterns new-line pattern
|
||||
#
|
||||
# pattern:
|
||||
# command-name match-list "pattern=" reg-ex
|
||||
#
|
||||
# command-name:
|
||||
# String that denotes what type of object will be created if some output matches this pattern
|
||||
#
|
||||
# match-list:
|
||||
# file-or-line
|
||||
# match-list space file-or-line
|
||||
#
|
||||
# file-or-line:
|
||||
# "file" | "line"
|
||||
#
|
||||
# reg-ex:
|
||||
# A regular expression
|
||||
#
|
||||
# new-line:
|
||||
# The new-line character \n
|
||||
#
|
||||
# space:
|
||||
# The space character
|
||||
|
||||
|
12
rse/plugins/org.eclipse.rse.services.local/plugin.properties
Normal file
12
rse/plugins/org.eclipse.rse.services.local/plugin.properties
Normal file
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 IBM Corporation 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:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
plugin.name = RSE Local Services
|
|
@ -0,0 +1,29 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.local.search;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.SystemSearchString;
|
||||
import org.eclipse.rse.services.search.AbstractSearchResult;
|
||||
import org.eclipse.rse.services.search.IHostSearchResultConfiguration;
|
||||
|
||||
public class LocalSearchResult extends AbstractSearchResult
|
||||
{
|
||||
public LocalSearchResult(IHostSearchResultConfiguration configuration, Object parent, SystemSearchString searchString)
|
||||
{
|
||||
super(configuration, parent, searchString);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2001, 2006 IBM Corporation and International Business Machines Corporation. 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
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.local.shells;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CommandPattern
|
||||
{
|
||||
|
||||
|
||||
private Pattern _pattern;
|
||||
private ArrayList _outputPatterns;
|
||||
|
||||
public CommandPattern(Pattern theCommandPattern)
|
||||
{
|
||||
_pattern = theCommandPattern;
|
||||
_outputPatterns = new ArrayList();
|
||||
}
|
||||
|
||||
public void addOutputPattern(OutputPattern op)
|
||||
{
|
||||
_outputPatterns.add(op);
|
||||
}
|
||||
|
||||
public boolean matchCommand(String theLine)
|
||||
{
|
||||
return _pattern.matcher(theLine).matches();
|
||||
}
|
||||
|
||||
public ParsedOutput matchLine(String theLine)
|
||||
{
|
||||
int patterns = _outputPatterns.size();
|
||||
ParsedOutput matchedOutput;
|
||||
OutputPattern curPattern;
|
||||
for (int i = 0; i < patterns; i++)
|
||||
{
|
||||
curPattern = (OutputPattern) _outputPatterns.get(i);
|
||||
matchedOutput = curPattern.matchLine(theLine);
|
||||
if (matchedOutput != null)
|
||||
return matchedOutput;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue