use of org.netxms.client.server.ServerFile in project netxms by netxms.
the class NXCSession method listServerFiles.
/**
* List files in server's file store.
*
* @param filter array with required extension. Will be used as file filter. Give empty array or null if no filter should be
* applyed.
* @return list of files in server's file store
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public ServerFile[] listServerFiles(String[] filter) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_LIST_SERVER_FILES);
if (filter != null) {
msg.setFieldInt32(NXCPCodes.VID_EXTENSION_COUNT, filter.length);
int i = 0;
long j = NXCPCodes.VID_EXTENSION_LIST_BASE;
for (; i < filter.length; i++, j++) {
msg.setField(j, filter[i]);
}
} else {
msg.setFieldInt32(NXCPCodes.VID_EXTENSION_COUNT, 0);
}
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_INSTANCE_COUNT);
ServerFile[] files = new ServerFile[count];
long varId = NXCPCodes.VID_INSTANCE_LIST_BASE;
for (int i = 0; i < count; i++) {
files[i] = new ServerFile(response, varId);
varId += 10;
}
return files;
}
use of org.netxms.client.server.ServerFile in project netxms by netxms.
the class ServerFilesTest method testFileList.
public void testFileList() throws Exception {
final NXCSession session = connect();
ServerFile[] files = session.listServerFiles();
for (ServerFile f : files) System.out.println(f.getName() + " size=" + f.getSize() + " modified: " + f.getModifyicationTime().toString());
session.disconnect();
}
use of org.netxms.client.server.ServerFile in project netxms by netxms.
the class ServerFileComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
TableColumn sortColumn = ((TableViewer) viewer).getTable().getSortColumn();
if (sortColumn == null)
return 0;
int rc;
switch(// $NON-NLS-1$
(Integer) sortColumn.getData("ID")) {
case SelectServerFileDialog.COLUMN_NAME:
rc = ((ServerFile) e1).getName().compareToIgnoreCase(((ServerFile) e2).getName());
break;
case SelectServerFileDialog.COLUMN_SIZE:
rc = Long.signum(((ServerFile) e1).getSize() - ((ServerFile) e2).getSize());
break;
case SelectServerFileDialog.COLUMN_MODTIME:
rc = ((ServerFile) e1).getModifyicationTime().compareTo(((ServerFile) e2).getModifyicationTime());
break;
default:
rc = 0;
break;
}
int dir = ((TableViewer) viewer).getTable().getSortDirection();
return (dir == SWT.UP) ? rc : -rc;
}
use of org.netxms.client.server.ServerFile in project netxms by netxms.
the class SelectServerFileDialog method okPressed.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty()) {
MessageDialogHelper.openWarning(getShell(), Messages.get().SelectServerFileDialog_Warning, Messages.get().SelectServerFileDialog_WarningText);
return;
}
final List<ServerFile> list = selection.toList();
selectedFiles = list.toArray(new ServerFile[list.size()]);
super.okPressed();
}
use of org.netxms.client.server.ServerFile in project netxms by netxms.
the class ServerFileComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
TableColumn sortColumn = ((TableViewer) viewer).getTable().getSortColumn();
if (sortColumn == null)
return 0;
int rc;
switch(// $NON-NLS-1$
(Integer) sortColumn.getData("ID")) {
case ServerFileManager.COLUMN_NAME:
rc = ((ServerFile) e1).getName().compareToIgnoreCase(((ServerFile) e2).getName());
break;
case ServerFileManager.COLUMN_TYPE:
rc = ((ServerFile) e1).getExtension().compareToIgnoreCase(((ServerFile) e2).getExtension());
break;
case ServerFileManager.COLUMN_SIZE:
rc = Long.signum(((ServerFile) e1).getSize() - ((ServerFile) e2).getSize());
break;
case ServerFileManager.COLUMN_MODIFYED:
rc = ((ServerFile) e1).getModifyicationTime().compareTo(((ServerFile) e2).getModifyicationTime());
break;
default:
rc = 0;
break;
}
int dir = ((TableViewer) viewer).getTable().getSortDirection();
return (dir == SWT.UP) ? rc : -rc;
}
Aggregations