1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[190803] basic query cancellation support for dstore files

This commit is contained in:
David McKnight 2007-07-09 17:59:48 +00:00
parent 85b84f72f8
commit fa54878306
9 changed files with 1168 additions and 898 deletions

View file

@ -573,7 +573,7 @@ public class XMLgenerator
{
String tagType = XMLparser.STR_DATAELEMENT;
if (object.isUpdated() && !object.isPendingTransfer() && !_generateBuffer)
if (object.isUpdated() && !object.isPendingTransfer())
{
}
else

View file

@ -0,0 +1,344 @@
/********************************************************************************
* Copyright (c) 2007 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.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.DataStoreResources;
import org.eclipse.dstore.core.util.StringCompare;
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
import org.eclipse.rse.dstore.universal.miners.UniversalFileSystemMiner;
import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
import org.eclipse.rse.services.clientserver.IClientServerConstants;
import org.eclipse.rse.services.clientserver.IServiceConstants;
import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
public class ArchiveQueryThread extends QueryThread {
private DataElement _attributes;
private boolean _caseSensitive;
private boolean _foldersOnly;
private boolean _showHidden;
private boolean _isWindows;
public ArchiveQueryThread(DataElement subject, DataElement attributes,
boolean caseSensitive, boolean foldersOnly, boolean showHidden,
boolean isWindows, DataElement status) {
super(subject, status);
_attributes = attributes;
_foldersOnly = foldersOnly;
_caseSensitive = caseSensitive;
_showHidden = showHidden;
_isWindows = isWindows;
}
public void run() {
doQueryAll();
if (!isCancelled()) {
_isDone = true;
// refresh data store
_dataStore.refresh(_subject);
// refresh status
statusDone(_status);
}
}
protected void doQueryAll() {
{
File fileobj = null;
try {
ArchiveHandlerManager mgr = ArchiveHandlerManager.getInstance();
char separatorChar = File.separatorChar;
if (ArchiveHandlerManager.isVirtual(_subject
.getAttribute(DE.A_VALUE))) {
separatorChar = '/';
}
String path = _subject.getAttribute(DE.A_VALUE) + separatorChar
+ _subject.getName();
String rootPath = path;
String virtualPath = ""; //$NON-NLS-1$
VirtualChild[] children = null;
if (_subject
.getType()
.equals(
IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR)) {
// it's an archive file (i.e. file.zip)
fileobj = new File(rootPath);
_subject.setAttribute(DE.A_SOURCE, setProperties(fileobj,
true));
if (_foldersOnly) {
children = mgr.getFolderContents(fileobj, ""); //$NON-NLS-1$
} else {
children = mgr.getContents(fileobj, ""); //$NON-NLS-1$
}
if (isCancelled())
return;
} else if (_subject
.getType()
.equals(
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)) {
// it's a virtual folder (i.e. a folder within zip)
// need to determine the associate File object
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(path);
rootPath = avp.getContainingArchiveString();
virtualPath = avp.getVirtualPart();
fileobj = new File(rootPath);
if (fileobj.exists()) {
if (_foldersOnly) {
children = mgr.getFolderContents(fileobj,
virtualPath);
} else {
children = mgr.getContents(fileobj, virtualPath);
}
_subject.setAttribute(DE.A_SOURCE, setProperties(mgr
.getVirtualObject(path)));
if (children == null || children.length == 0) {
_dataStore
.trace("problem with virtual:" + virtualPath); //$NON-NLS-1$
}
if (isCancelled())
return;
} else {
_dataStore.trace("problem with File:" + rootPath); //$NON-NLS-1$
}
}
createDataElement(_dataStore, _subject, children,
"*", rootPath, virtualPath); //$NON-NLS-1$
if (!isCancelled())
{
_dataStore.refresh(_subject);
FileClassifier clsfy = getFileClassifier(_subject);
clsfy.start();
}
return;
} catch (Exception e) {
if (!(fileobj == null)) {
try {
(new FileReader(fileobj)).read();
} catch (IOException ex) {
_status.setAttribute(DE.A_VALUE,
IClientServerConstants.FILEMSG_NO_PERMISSION);
_status.setAttribute(DE.A_SOURCE,
IServiceConstants.FAILED);
_dataStore.refresh(_subject);
statusDone(_status);
}
}
_status.setAttribute(DE.A_VALUE,
IClientServerConstants.FILEMSG_ARCHIVE_CORRUPTED);
_status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
statusDone(_status);
}
}
}
protected FileClassifier getFileClassifier(DataElement subject) {
return new FileClassifier(subject);
}
/**
* Complete status.
*/
public DataElement statusDone(DataElement status) {
status.setAttribute(DE.A_NAME, DataStoreResources.model_done);
_dataStore.refresh(status);
return status;
}
public void cancel() {
_isCancelled = true;
}
public boolean isCancelled() {
return _isCancelled;
}
public boolean isDone() {
return _isDone;
}
/**
* Method to create the DataElement object in the datastore out of a list of
* VirtualChildren
*/
protected void createDataElement(DataStore ds, DataElement subject,
VirtualChild[] list, String filter, String rootPath,
String virtualPath) {
HashMap filteredChildren = new HashMap();
List children = subject.getNestedData();
if (children != null) {
for (int f = 0; f < children.size(); f++) {
if (isCancelled())
return;
DataElement child = (DataElement) children.get(f);
String type = child.getType();
if (type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|| type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)) {
if (StringCompare.compare(filter, child.getName(), false)) {
filteredChildren.put(child.getName(), child);
}
} else {
filteredChildren.put(child.getName(), child);
}
}
}
// Check if the current Objects in the DataStore are valid... exist
// on the remote host
try {
boolean found = false;
for (int j = 0; j < list.length; ++j) {
if (isCancelled())
return;
found = false;
DataElement previousElement = (DataElement) filteredChildren
.get(list[j].name);
if (previousElement != null && !previousElement.isDeleted()) {
// Type have to be equal as well
String type = previousElement.getType();
boolean isfile = !list[j].isDirectory;
if (type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|| (type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) && !isfile)) {
filteredChildren.remove(list[j].name);
found = true;
}
}
DataElement deObj = null;
VirtualChild child = list[j];
if (found) {
deObj = previousElement;
}
if (deObj == null) {
if (child.isDirectory) {
deObj = _dataStore
.createObject(
subject,
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR,
child.name);
} else // file
{
deObj = _dataStore
.createObject(
subject,
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR,
child.name);
}
}
String oldValue = deObj.getAttribute(DE.A_VALUE);
String newValue = rootPath
+ ArchiveHandlerManager.VIRTUAL_SEPARATOR + virtualPath;
if (!oldValue.equals(newValue)) {
deObj.setAttribute(DE.A_VALUE, newValue);
}
String oldSource = deObj.getAttribute(DE.A_SOURCE);
String newSource = setProperties(child);
if (!oldSource.startsWith(newSource)) {
deObj.setAttribute(DE.A_SOURCE, newSource);
}
} // end for j
// Object left over in the filteredChildren is no longer in the
// system any more. Need to remove.
Iterator myIterator = filteredChildren.keySet().iterator();
while (myIterator.hasNext()) {
ds.deleteObject(subject, (DataElement) (filteredChildren
.get(myIterator.next())));
}
} catch (Exception e) {
e.printStackTrace();
UniversalServerUtilities.logError(
UniversalFileSystemMiner.CLASSNAME,
"createDataElement failed with exception - isFile ", e); //$NON-NLS-1$
}
} // end currentObj not 0
public String setProperties(VirtualChild fileObj) {
String version = IServiceConstants.VERSION_1;
StringBuffer buffer = new StringBuffer(500);
long date = fileObj.getTimeStamp();
long size = fileObj.getSize();
boolean hidden = false;
boolean canWrite = fileObj.getContainingArchive().canWrite();
boolean canRead = fileObj.getContainingArchive().canRead();
// These extra properties here might cause problems for older clients,
// ie: a IndexOutOfBounds in UniversalFileImpl.
String comment = fileObj.getComment();
if (comment.equals("")) //$NON-NLS-1$
comment = " "; // make sure this is still a //$NON-NLS-1$
// token
long compressedSize = fileObj.getCompressedSize();
String compressionMethod = fileObj.getCompressionMethod();
if (compressionMethod.equals("")) //$NON-NLS-1$
compressionMethod = " "; //$NON-NLS-1$
double compressionRatio = fileObj.getCompressionRatio();
long expandedSize = size;
buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR)
.append(date).append(IServiceConstants.TOKEN_SEPARATOR).append(
size).append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(hidden).append(IServiceConstants.TOKEN_SEPARATOR).append(
canWrite).append(IServiceConstants.TOKEN_SEPARATOR).append(
canRead);
buffer.append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(comment).append(IServiceConstants.TOKEN_SEPARATOR)
.append(compressedSize).append(
IServiceConstants.TOKEN_SEPARATOR).append(
compressionMethod).append(
IServiceConstants.TOKEN_SEPARATOR);
buffer.append(compressionRatio).append(
IServiceConstants.TOKEN_SEPARATOR).append(expandedSize);
return buffer.toString();
}
}

View file

@ -40,7 +40,7 @@ import org.eclipse.rse.services.clientserver.java.BasicClassFileParser;
/*
* This utility class is for determing file types
* This utility class is for determining file types
*/
public class FileClassifier extends Thread
{

View file

@ -0,0 +1,26 @@
/********************************************************************************
* Copyright (c) 2007 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.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
import org.eclipse.dstore.core.model.DataElement;
public class FileDescriptors
{
public static DataElement _deUniversalFileObject;
public static DataElement _deUniversalFolderObject;
public static DataElement _deUniversalVirtualFileObject;
public static DataElement _deUniversalVirtualFolderObject;
public static DataElement _deUniversalArchiveFileObject;
}

View file

@ -0,0 +1,377 @@
/********************************************************************************
* Copyright (c) 2007 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.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.IUniversalDataStoreConstants;
import org.eclipse.rse.dstore.universal.miners.UniversalFileSystemMiner;
import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
import org.eclipse.rse.services.clientserver.IClientServerConstants;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
public class FileQueryThread extends QueryThread
{
private File _fileobj;
private String _queryType;
private String _filter;
private boolean _caseSensitive;
private int _inclusion;
private boolean _showHidden;
private boolean _isWindows;
public FileQueryThread(
DataElement subject, File fileobj,
String queryType, String filter, boolean caseSensitive,
int inclusion,
boolean showHidden, boolean isWindows,
DataElement status)
{
super(subject, status);
_fileobj = fileobj;
_queryType = queryType;
_filter = filter;
_caseSensitive = caseSensitive;
_inclusion = inclusion;
_showHidden = showHidden;
_isWindows = isWindows;
}
public void run()
{
doQueryAll();
if (!isCancelled())
{
_isDone = true;
// refresh data store
_dataStore.refresh(_subject);
// refresh status
statusDone(_status);
}
}
protected void doQueryAll() {
if (_fileobj.exists())
{
boolean filterFiles = (_inclusion == IClientServerConstants.INCLUDE_ALL) || (_inclusion == IClientServerConstants.INCLUDE_FILES_ONLY);
boolean filterFolders = (_inclusion == IClientServerConstants.INCLUDE_ALL) || (_inclusion == IClientServerConstants.INCLUDE_FOLDERS_ONLY);
UniversalFileSystemFilter filefilter = new UniversalFileSystemFilter(_filter,filterFiles, filterFolders, _caseSensitive);
String theOS = System.getProperty("os.name"); //$NON-NLS-1$
File[] list = null;
if (theOS.equals("z/OS")) //$NON-NLS-1$
{
// filters not supported with z/OS jvm
File[] tempList = _fileobj.listFiles();
List acceptedList = new ArrayList(tempList.length);
for (int i = 0; i < tempList.length; i++) {
File afile = tempList[i];
if (filefilter.accept(_fileobj, afile.getName())) {
acceptedList.add(afile);
}
}
list = new File[acceptedList.size()];
for (int l = 0; l < acceptedList.size(); l++)
list[l] = (File) acceptedList.get(l);
}
else
{
list = _fileobj.listFiles(filefilter);
}
if (!_isCancelled)
{
if (list != null)
{
createDataElement(_dataStore, _subject, list, _queryType, _filter,_inclusion);
String folderProperties = setProperties(_fileobj);
if (_subject.getSource() == null || _subject.getSource().equals("")) //$NON-NLS-1$
_subject.setAttribute(DE.A_SOURCE, folderProperties);
if (!_isCancelled)
{
FileClassifier clsfy = getFileClassifier(_subject);
clsfy.start();
}
}
}
}
else {
}
}
protected FileClassifier getFileClassifier(DataElement subject)
{
return new FileClassifier(subject);
}
protected void createDataElement(DataStore ds, DataElement subject,
File[] list, String queryType, String filter, int include)
{
createDataElement(ds, subject, list, queryType, filter, include, null);
}
/**
* Method to create the DataElement object in the datastore.
*/
protected void createDataElement(DataStore ds, DataElement subject,
File[] list, String queryType, String filter, int include, String types[])
{
HashMap filteredChildren = new HashMap();
List children = subject.getNestedData();
if (children != null)
{
//Use a HashMap instead of array list to improve performance
for (int f = 0; f < children.size(); f++)
{
if (_isCancelled) {
return;
}
DataElement child = (DataElement)children.get(f);
if (!child.isDeleted())
{
String type = child.getType();
if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
{
if (StringCompare.compare(filter, child.getName(), false))
{
//filteredChildren.add(child);
filteredChildren.put(child.getName(), child);
}
}
else
{
//filteredChildren.add(child);
filteredChildren.put(child.getName(), child);
}
}
}
}
boolean found = false;
// Check if the current Objects in the DataStore are valid... exist
// on the remote host
try {
for (int j = 0; j < list.length; ++j)
{
if (_isCancelled) {
return;
}
found = false;
File file = list[j];
String fileName = file.getName();
boolean isHidden = file.isHidden() || fileName.charAt(0) == '.';
DataElement previousElement = (DataElement)filteredChildren.get(fileName);
if (previousElement != null && !previousElement.isDeleted())
{
// Type have to be equal as well
//String type = ((DataElement) currentObjList[i]).getType();
String type = previousElement.getType();
boolean isfile = list[j].isFile();
if (((type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR)) && isfile)
||
(type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR) && !isfile))
{
if (types !=null)
{
String attributes = previousElement.getAttribute(DE.A_SOURCE);
String thisType = types[j];
if (attributes.indexOf(thisType) != -1)
{
filteredChildren.remove(list[j].getName()); //remove it from the filterChildren list
found = true;
}
}
else
{
filteredChildren.remove(list[j].getName());
found = true;
}
}
}
DataElement deObj = null;
if (!isHidden || _showHidden)
{
if (found)
{
//this object already exists in the DStore
deObj = previousElement;
}
else
{
//We need to create a new data element for this object.
if (include == IClientServerConstants.INCLUDE_ALL)
{
if (file.isDirectory())
{
deObj = ds.createObject(subject,FileDescriptors._deUniversalFolderObject,fileName);
}
else
// file
{
if (ArchiveHandlerManager.getInstance().isArchive(file))
{
deObj = ds
.createObject(
subject,
FileDescriptors._deUniversalArchiveFileObject,
fileName);
}
else
{
deObj = ds.createObject(subject,
FileDescriptors._deUniversalFileObject,
fileName);
}
}
}
else if (include == IClientServerConstants.INCLUDE_FOLDERS_ONLY)
{
if (ArchiveHandlerManager.getInstance().isArchive(file))
{
deObj = ds.createObject(subject,
FileDescriptors._deUniversalArchiveFileObject,
fileName);
}
else
{
deObj = ds.createObject(subject,
FileDescriptors._deUniversalFolderObject,
fileName);
}
}
else if (include == IClientServerConstants.INCLUDE_FILES_ONLY)
{
if (ArchiveHandlerManager.getInstance().isArchive(file))
{
deObj = ds.createObject(subject,
FileDescriptors._deUniversalArchiveFileObject,
fileName);
}
else
{
deObj = ds
.createObject(subject,
FileDescriptors._deUniversalFileObject,
fileName);
}
}
if (deObj != null)
{
if (queryType.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
{
deObj.setAttribute(DE.A_VALUE, subject.getAttribute(DE.A_VALUE));
}
else
{
if (subject.getName().length() > 0)
{
String valueStr = subject.getAttribute(DE.A_VALUE);
//String valueStr = list[i].getParentFile().getAbsolutePath();
StringBuffer valueBuffer = new StringBuffer(valueStr);
if ((_isWindows && valueStr.endsWith("\\"))|| valueStr.endsWith("/") || subject.getName().startsWith("/")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
{
valueBuffer.append(subject.getName());
deObj.setAttribute(DE.A_VALUE,valueBuffer.toString());
}
else
{
valueBuffer.append(File.separatorChar);
valueBuffer.append(subject.getName());
deObj.setAttribute(DE.A_VALUE,valueBuffer.toString());
}
}
else
{
String valueStr = list[j].getParentFile().getAbsolutePath();
deObj.setAttribute(DE.A_VALUE, valueStr);
}
}
}
}
String properties = setProperties(file);
if (deObj != null)
{
if (types != null)
{
String oldSource = deObj.getAttribute(DE.A_SOURCE);
String newSource = properties + "|" + types[j]; //$NON-NLS-1$
if (!oldSource.startsWith(newSource))
{
deObj.setAttribute(DE.A_SOURCE, newSource);
}
}
else
{
String oldSource = deObj.getAttribute(DE.A_SOURCE);
String newSource = properties;
if (!oldSource.startsWith(newSource))
deObj.setAttribute(DE.A_SOURCE, properties);
}
}
}
} // end for j
//Object left over in the filteredChildren is no longer in the system any more. Need to remove.
Iterator myIterator = filteredChildren.keySet().iterator();
while(myIterator.hasNext())
{
ds.deleteObject(subject, (DataElement)(filteredChildren.get(myIterator.next())));
}
} catch (Exception e) {
e.printStackTrace();
UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME,
"createDataElement failed with exception - isFile ", e); //$NON-NLS-1$
}
}
}

View file

@ -0,0 +1,162 @@
/********************************************************************************
* Copyright (c) 2007 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.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
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.DataStoreResources;
import org.eclipse.rse.dstore.universal.miners.ICancellableHandler;
import org.eclipse.rse.services.clientserver.IServiceConstants;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
public class QueryThread extends Thread implements ICancellableHandler {
protected DataElement _subject;
protected DataElement _status;
protected boolean _isCancelled = false;
protected boolean _isDone = false;
protected DataStore _dataStore;
public QueryThread(DataElement subject, DataElement status)
{
_subject = subject;
_dataStore = _subject.getDataStore();
_status = status;
}
/**
* Complete status.
*/
public DataElement statusDone(DataElement status) {
status.setAttribute(DE.A_NAME, DataStoreResources.model_done);
_dataStore.refresh(status);
return status;
}
public void cancel() {
_isCancelled = true;
}
public boolean isCancelled() {
return _isCancelled;
}
public boolean isDone() {
return _isDone;
}
public String setProperties(File fileObj) {
return setProperties(fileObj, false);
}
/**
* Method to obtain the properties of file or folder.
*/
public String setProperties(File fileObj, boolean doArchiveProperties) {
String version = IServiceConstants.VERSION_1;
StringBuffer buffer = new StringBuffer(500);
long date = fileObj.lastModified();
long size = fileObj.length();
boolean hidden = fileObj.isHidden();
boolean canWrite = fileObj.canWrite() ;
boolean canRead = fileObj.canRead();
// These extra properties here might cause problems for older clients,
// ie: a IndexOutOfBounds in UniversalFileImpl.
// DKM: defer this until later as it is bad for performacnes..
// I think we're doing the full query on an archive by instantiating a
// handler
boolean isArchive = false;//ArchiveHandlerManager.getInstance().isArchive(fileObj);
String comment;
if (isArchive)
comment = ArchiveHandlerManager.getInstance().getComment(fileObj);
else
comment = " "; //$NON-NLS-1$
long compressedSize = size;
String compressionMethod = " "; //$NON-NLS-1$
double compressionRatio = 0;
long expandedSize;
if (isArchive)
expandedSize = ArchiveHandlerManager.getInstance().getExpandedSize(
fileObj);
else
expandedSize = size;
buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR).append(date).append(
IServiceConstants.TOKEN_SEPARATOR).append(size).append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(hidden).append(IServiceConstants.TOKEN_SEPARATOR).append(canWrite).append(
IServiceConstants.TOKEN_SEPARATOR).append(canRead);
// values might not be used but we set them here just so that there are right number
// of properties
buffer.append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(comment).append(IServiceConstants.TOKEN_SEPARATOR).append(compressedSize)
.append(IServiceConstants.TOKEN_SEPARATOR).append(compressionMethod).append(
IServiceConstants.TOKEN_SEPARATOR);
buffer.append(compressionRatio).append(IServiceConstants.TOKEN_SEPARATOR).append(
expandedSize);
String buf = buffer.toString();
return buf;
}
public String setProperties(VirtualChild fileObj) {
String version = IServiceConstants.VERSION_1;
StringBuffer buffer = new StringBuffer(500);
long date = fileObj.getTimeStamp();
long size = fileObj.getSize();
boolean hidden = false;
boolean canWrite = fileObj.getContainingArchive().canWrite();
boolean canRead = fileObj.getContainingArchive().canRead();
// These extra properties here might cause problems for older clients,
// ie: a IndexOutOfBounds in UniversalFileImpl.
String comment = fileObj.getComment();
if (comment.equals("")) //$NON-NLS-1$
comment = " "; // make sure this is still a //$NON-NLS-1$
// token
long compressedSize = fileObj.getCompressedSize();
String compressionMethod = fileObj.getCompressionMethod();
if (compressionMethod.equals("")) //$NON-NLS-1$
compressionMethod = " "; //$NON-NLS-1$
double compressionRatio = fileObj.getCompressionRatio();
long expandedSize = size;
buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR).append(date).append(
IServiceConstants.TOKEN_SEPARATOR).append(size).append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(hidden).append(IServiceConstants.TOKEN_SEPARATOR).append(canWrite).append(
IServiceConstants.TOKEN_SEPARATOR).append(canRead);
buffer.append(IServiceConstants.TOKEN_SEPARATOR);
buffer.append(comment).append(IServiceConstants.TOKEN_SEPARATOR).append(compressedSize)
.append(IServiceConstants.TOKEN_SEPARATOR).append(compressionMethod).append(
IServiceConstants.TOKEN_SEPARATOR);
buffer.append(compressionRatio).append(IServiceConstants.TOKEN_SEPARATOR).append(
expandedSize);
return buffer.toString();
}
}

View file

@ -87,6 +87,7 @@ public abstract class AbstractDStoreService implements IDStoreService
{
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
smon.waitForUpdate(status, monitor);
int resultSize = subject.getNestedSize();
checkHostJVM();

View file

@ -199,6 +199,20 @@ public class DStoreStatusMonitor implements IDomainListener
{
_workingStatuses.remove(status);
_cancelledStatuses.add(status);
// send a cancel command if possible
if (status != null)
{
DataElement command = status.getParent();
DataStore dataStore = command.getDataStore();
DataElement cmdDescriptor = command.getDescriptor();
DataElement cancelDescriptor = dataStore.localDescriptorQuery(cmdDescriptor, "C_CANCEL"); //$NON-NLS-1$
if (cancelDescriptor != null)
{
dataStore.command(cancelDescriptor, command);
}
}
}
public synchronized void setWorking(DataElement status)