Search in sources :

Example 6 with ServerFile

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ServerFile(org.netxms.client.server.ServerFile) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 7 with ServerFile

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();
}
Also used : ServerFile(org.netxms.client.server.ServerFile)

Example 8 with ServerFile

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;
}
Also used : ServerFile(org.netxms.client.server.ServerFile) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 9 with ServerFile

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();
}
Also used : ServerFile(org.netxms.client.server.ServerFile) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 10 with ServerFile

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;
}
Also used : ServerFile(org.netxms.client.server.ServerFile) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

ServerFile (org.netxms.client.server.ServerFile)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 File (java.io.File)2 IOException (java.io.IOException)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileChannel (java.nio.channels.FileChannel)1 IStatus (org.eclipse.core.runtime.IStatus)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1