use of org.netxms.client.AccessListElement in project netxms by netxms.
the class GraphSettings method createGraphSettings.
/**
* Create graph settings object from NXCP message
*
* @param msg NXCP message
* @param baseId base variable id
* @return The graph settings object
*/
public static GraphSettings createGraphSettings(final NXCPMessage msg, long baseId) {
GraphSettings gs;
try {
gs = GraphSettings.createFromXml(msg.getFieldAsString(baseId + 4));
} catch (Exception e) {
gs = new GraphSettings();
Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ChartConfig XML", e);
}
gs.id = msg.getFieldAsInt64(baseId);
gs.ownerId = msg.getFieldAsInt64(baseId + 1);
gs.flags = (int) msg.getFieldAsInt64(baseId + 2);
gs.name = msg.getFieldAsString(baseId + 3);
try {
gs.filter = ObjectMenuFilter.createFromXml(msg.getFieldAsString(baseId + 5));
} catch (Exception e) {
Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ObjectMenuFilter XML: ", e);
gs.filter = new ObjectMenuFilter();
}
String[] parts = gs.name.split("->");
gs.shortName = (parts.length > 1) ? parts[parts.length - 1] : gs.name;
// ACL size
int count = msg.getFieldAsInt32(baseId + 6);
long[] users = msg.getFieldAsUInt32Array(baseId + 7);
long[] rights = msg.getFieldAsUInt32Array(baseId + 8);
gs.accessList = new ArrayList<AccessListElement>(count);
for (int i = 0; i < count; i++) {
gs.accessList.add(new AccessListElement(users[i], (int) rights[i]));
}
return gs;
}
use of org.netxms.client.AccessListElement in project netxms by netxms.
the class GraphSettings method fillMessage.
public void fillMessage(NXCPMessage msg) {
msg.setFieldInt32(NXCPCodes.VID_GRAPH_ID, (int) id);
msg.setField(NXCPCodes.VID_NAME, name);
msg.setFieldInt32(NXCPCodes.VID_FLAGS, flags);
msg.setField(NXCPCodes.VID_FILTER, filter.createXml());
try {
msg.setField(NXCPCodes.VID_GRAPH_CONFIG, createXml());
} catch (Exception e) {
Logger.debug("GraphSettings.CreateGraphSettings", "Cannot convert ChartConfig to XML: ", e);
msg.setField(NXCPCodes.VID_GRAPH_CONFIG, "");
}
msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, accessList.size());
long varId = NXCPCodes.VID_GRAPH_ACL_BASE;
for (AccessListElement el : accessList) {
msg.setFieldInt32(varId++, (int) el.getUserId());
msg.setFieldInt32(varId++, el.getAccessRights());
}
}
use of org.netxms.client.AccessListElement in project netxms by netxms.
the class LogViewer method init.
/* (non-Javadoc)
* @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
*/
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
session = (NXCSession) ConsoleSharedData.getSession();
logName = site.getSecondaryId();
// $NON-NLS-1$
setPartName(Messages.getString("LogViewer_" + logName));
// $NON-NLS-1$ //$NON-NLS-2$
final ImageDescriptor img = Activator.getImageDescriptor("icons/" + logName + ".png");
if (img != null) {
titleImage = img.createImage();
this.setTitleImage(titleImage);
}
filter = new LogFilter();
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
}
use of org.netxms.client.AccessListElement in project netxms by netxms.
the class AccessControl method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
AccessListElement[] origAcl = object.getAccessList();
acl = new HashMap<Long, AccessListElement>(origAcl.length);
for (int i = 0; i < origAcl.length; i++) acl.put(origAcl[i].getUserId(), new AccessListElement(origAcl[i]));
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
Group users = new Group(dialogArea, SWT.NONE);
users.setText(Messages.get().AccessControl_UsersGroups);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
users.setLayoutData(gd);
layout = new GridLayout();
users.setLayout(layout);
final String[] columnNames = { Messages.get().AccessControl_ColLogin, Messages.get().AccessControl_ColRights };
final int[] columnWidths = { 150, 100 };
userList = new SortableTableViewer(users, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userList.setContentProvider(new ArrayContentProvider());
userList.setLabelProvider(new AccessListLabelProvider());
userList.setComparator(new AccessListComparator());
userList.setInput(acl.values().toArray());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userList.getControl().setLayoutData(gd);
Composite buttons = new Composite(users, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().AccessControl_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(AccessControl.this.getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) acl.put(user.getId(), new AccessListElement(user.getId(), 0));
userList.setInput(acl.values().toArray());
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().AccessControl_Delete);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
Iterator<AccessListElement> it = sel.iterator();
while (it.hasNext()) {
AccessListElement element = it.next();
acl.remove(element.getUserId());
}
userList.setInput(acl.values().toArray());
}
});
Group rights = new Group(dialogArea, SWT.NONE);
rights.setText(Messages.get().AccessControl_AccessRights);
rights.setLayout(new RowLayout(SWT.VERTICAL));
gd = new GridData();
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
rights.setLayoutData(gd);
createAccessCheck(rights, Messages.get().AccessControl_AccessRead, UserAccessRights.OBJECT_ACCESS_READ);
createAccessCheck(rights, "Read agent data", UserAccessRights.OBJECT_ACCESS_READ_AGENT);
createAccessCheck(rights, "Read SNMP data", UserAccessRights.OBJECT_ACCESS_READ_SNMP);
createAccessCheck(rights, Messages.get().AccessControl_AccessModify, UserAccessRights.OBJECT_ACCESS_MODIFY);
createAccessCheck(rights, Messages.get().AccessControl_AccessCreate, UserAccessRights.OBJECT_ACCESS_CREATE);
createAccessCheck(rights, Messages.get().AccessControl_AccessDelete, UserAccessRights.OBJECT_ACCESS_DELETE);
createAccessCheck(rights, Messages.get().AccessControl_AccessControl, UserAccessRights.OBJECT_ACCESS_CONTROL);
createAccessCheck(rights, Messages.get().AccessControl_AccessSendEvents, UserAccessRights.OBJECT_ACCESS_SEND_EVENTS);
createAccessCheck(rights, Messages.get().AccessControl_AccessViewAlarms, UserAccessRights.OBJECT_ACCESS_READ_ALARMS);
createAccessCheck(rights, Messages.get().AccessControl_AccessUpdateAlarms, UserAccessRights.OBJECT_ACCESS_UPDATE_ALARMS);
createAccessCheck(rights, Messages.get().AccessControl_AccessTermAlarms, UserAccessRights.OBJECT_ACCESS_TERM_ALARMS);
createAccessCheck(rights, Messages.get().AccessControl_CreateTicket, UserAccessRights.OBJECT_ACCESS_CREATE_ISSUE);
createAccessCheck(rights, Messages.get().AccessControl_AccessPushData, UserAccessRights.OBJECT_ACCESS_PUSH_DATA);
createAccessCheck(rights, Messages.get().AccessControl_AccessAccessControl, UserAccessRights.OBJECT_ACCESS_ACL);
createAccessCheck(rights, Messages.get().AccessControl_DownloadFiles, UserAccessRights.OBJECT_ACCESS_DOWNLOAD);
createAccessCheck(rights, Messages.get().AccessControl_UploadFiles, UserAccessRights.OBJECT_ACCESS_UPLOAD);
createAccessCheck(rights, Messages.get().AccessControl_ManageFiles, UserAccessRights.OBJECT_ACCESS_MANAGE_FILES);
createAccessCheck(rights, "Control maintenance mode", UserAccessRights.OBJECT_ACCESS_MAINTENANCE);
createAccessCheck(rights, "Take screenshot", UserAccessRights.OBJECT_ACCESS_SCREENSHOT);
userList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.size() == 1) {
enableAllChecks(true);
AccessListElement element = (AccessListElement) sel.getFirstElement();
int rights = element.getAccessRights();
for (int i = 0, mask = 1; i < accessChecks.size(); i++, mask <<= 1) {
Button check = accessChecks.get(mask);
if (check != null) {
check.setSelection((rights & mask) == mask);
}
}
} else {
enableAllChecks(false);
}
deleteButton.setEnabled(sel.size() > 0);
}
});
checkInherit = new Button(dialogArea, SWT.CHECK);
checkInherit.setText(Messages.get().AccessControl_InheritRights);
if (object.getParentCount() > 0) {
checkInherit.setSelection(object.isInheritAccessRights());
} else {
// For objects without parent "inherit access rights" option is meaningless
checkInherit.setSelection(false);
checkInherit.setEnabled(false);
}
return dialogArea;
}
use of org.netxms.client.AccessListElement in project netxms by netxms.
the class AccessListLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
switch(columnIndex) {
case 0:
return getText(element);
case 1:
AccessListElement e = (AccessListElement) element;
StringBuilder sb = new StringBuilder(16);
sb.append(e.hasRead() ? 'R' : '-');
sb.append(e.hasModify() ? 'M' : '-');
sb.append(e.hasCreate() ? 'C' : '-');
sb.append(e.hasDelete() ? 'D' : '-');
sb.append(e.hasControl() ? 'O' : '-');
sb.append(e.hasSendEvents() ? 'E' : '-');
sb.append(e.hasReadAlarms() ? 'V' : '-');
sb.append(e.hasAckAlarms() ? 'K' : '-');
sb.append(e.hasTerminateAlarms() ? 'T' : '-');
sb.append(e.hasPushData() ? 'P' : '-');
sb.append(e.hasAccessControl() ? 'A' : '-');
return sb.toString();
}
return null;
}
Aggregations