mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Michael Berger's patch for 147531
This commit is contained in:
parent
a698ade0f7
commit
02f6549363
3 changed files with 58 additions and 2 deletions
|
@ -30,6 +30,7 @@ public interface IUniversalProcessDataStoreConstants
|
|||
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";
|
||||
public static final String UNIVERSAL_PROCESS_TEMP = "universal.process.temp";
|
||||
|
||||
//
|
||||
// Universal Process Miner Commands
|
||||
|
@ -37,5 +38,6 @@ public interface IUniversalProcessDataStoreConstants
|
|||
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";
|
||||
public static final String C_PROCESS_QUERY_USERNAME = "C_PROCESS_QUERY_USERNAME";
|
||||
|
||||
}
|
|
@ -98,6 +98,11 @@ public class UniversalProcessMiner extends Miner implements IUniversalProcessDat
|
|||
|
||||
String subjectType = (String) subject.getElementProperty(DE.P_TYPE);
|
||||
|
||||
if (name.equals(C_PROCESS_QUERY_USERNAME))
|
||||
{
|
||||
return handleQueryUserName(subject, status);
|
||||
}
|
||||
|
||||
if (subjectType.equals(UNIVERSAL_PROCESS_FILTER))
|
||||
{
|
||||
if (name.equals(C_PROCESS_FILTER_QUERY_ALL))
|
||||
|
@ -135,6 +140,21 @@ public class UniversalProcessMiner extends Miner implements IUniversalProcessDat
|
|||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the username
|
||||
*/
|
||||
protected DataElement handleQueryUserName(DataElement subject, DataElement status) {
|
||||
|
||||
String encoding = System.getProperty("user.name");
|
||||
|
||||
subject.setAttribute(DE.A_VALUE, encoding);
|
||||
_dataStore.refresh(subject);
|
||||
|
||||
status.setAttribute(DE.A_NAME, "done");
|
||||
_dataStore.refresh(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
public void extendSchema(DataElement schemaRoot)
|
||||
{
|
||||
|
||||
|
@ -143,11 +163,13 @@ public class UniversalProcessMiner extends Miner implements IUniversalProcessDat
|
|||
UNIVERSAL_PROCESS_FILTER);
|
||||
deUniversalProcessObject = createObjectDescriptor(schemaRoot,
|
||||
UNIVERSAL_PROCESS_DESCRIPTOR);
|
||||
DataElement tempnode = createObjectDescriptor(schemaRoot, UNIVERSAL_PROCESS_TEMP);
|
||||
|
||||
// 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);
|
||||
createCommandDescriptor(tempnode, "QueryUsername", C_PROCESS_QUERY_USERNAME);
|
||||
|
||||
_dataStore.refresh(schemaRoot);
|
||||
}
|
||||
|
@ -221,8 +243,9 @@ public class UniversalProcessMiner extends Miner implements IUniversalProcessDat
|
|||
// 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
|
||||
SortedSet sortedDEs = null;
|
||||
List nested = subject.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
protected DStoreStatusMonitor _statusMonitor;
|
||||
protected DataElement _procMinerStatus;
|
||||
protected String[] _statusTypes;
|
||||
protected String _userName;
|
||||
|
||||
public DStoreProcessService(IDataStoreProvider provider)
|
||||
{
|
||||
|
@ -106,6 +107,9 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
}
|
||||
|
||||
// convert objects to remote files
|
||||
String userName = getRemoteUserName();
|
||||
if (userName != null && filter.getUsername().equals("${user.id}"))
|
||||
filter.setUsername(getRemoteUserName());
|
||||
processes = convertObjsToHostProcesses(filter, results);
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +326,33 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
monitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the username used to connect to the remote machine
|
||||
*/
|
||||
public String getRemoteUserName()
|
||||
{
|
||||
if (_userName == null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
DataElement encodingElement = ds.createObject(null, UNIVERSAL_PROCESS_TEMP, "");
|
||||
|
||||
DataElement queryCmd = ds.localDescriptorQuery(encodingElement.getDescriptor(), C_PROCESS_QUERY_USERNAME);
|
||||
DStoreStatusMonitor monitor = getStatusMonitor(ds);
|
||||
DataElement status = ds.command(queryCmd, encodingElement, true);
|
||||
try
|
||||
{
|
||||
monitor.waitForUpdate(status);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
_userName = encodingElement.getValue();
|
||||
}
|
||||
return _userName;
|
||||
}
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return UniversalProcessMiner.MINER_ID;
|
||||
|
|
Loading…
Add table
Reference in a new issue