private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) { final Fragment fragment = new Fragment("actions", "locationActions", this); final AjaxLink<String> create = new IndicatingAjaxLink<String>("create") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { final ConnInstanceTO modelObject = new ConnInstanceTO(); modelObject.setLocation(node.getKey().toString()); final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject); resourceModal.setFormModel(model); target.add(resourceModal.setContent(new ConnectorModal(resourceModal, pageRef, model))); resourceModal.header( new Model<>(MessageFormat.format(getString("connector.new"), node.getKey()))); MetaDataRoleAuthorizationStrategy.authorize( resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.CONNECTOR_CREATE); resourceModal.show(true); } }; fragment.add(create); MetaDataRoleAuthorizationStrategy.authorize( create, ENABLE, StandardEntitlement.CONNECTOR_CREATE); return fragment; }
private Fragment getSyncopeFragment(final PageReference pageRef) { final Fragment fragment = new Fragment("actions", "syncopeActions", this); final AjaxLink<String> tasks = new IndicatingAjaxLink<String>("tasks") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { target.add(taskModal.setContent(new SchedTasks(pageRef))); taskModal.header(new ResourceModel("task.generic.list", "Scheduled tasks")); taskModal.show(true); } }; fragment.add(tasks); MetaDataRoleAuthorizationStrategy.authorize(tasks, ENABLE, StandardEntitlement.TASK_LIST); return fragment; }
private Fragment getResurceFragment(final TopologyNode node, final PageReference pageRef) { final Fragment fragment = new Fragment("actions", "resourceActions", this); final AjaxLink<String> delete = new IndicatingAjaxLink<String>("delete") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { try { resourceRestClient.delete(node.getKey().toString()); target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey())); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While deleting resource {}", node.getKey(), e); } ((BasePage) getPage()).getNotificationPanel().refresh(target); } }; fragment.add(delete); delete.add(new ConfirmationModalBehavior()); MetaDataRoleAuthorizationStrategy.authorize( delete, ENABLE, StandardEntitlement.RESOURCE_DELETE); final AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { final ResourceTO modelObject = resourceRestClient.read(node.getKey().toString()); final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject); resourceModal.setFormModel(model); target.add( resourceModal.setContent( new ResourceModal<>(resourceModal, pageRef, model, false))); resourceModal.header( new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey()))); MetaDataRoleAuthorizationStrategy.authorize( resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_UPDATE); resourceModal.show(true); } }; fragment.add(edit); MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.RESOURCE_UPDATE); final AjaxLink<String> propagation = new IndicatingAjaxLink<String>("propagation") { private static final long serialVersionUID = 3776750333491622263L; @Override @SuppressWarnings("unchecked") public void onClick(final AjaxRequestTarget target) { target.add( taskModal.setContent(new PropagationTasks(pageRef, node.getKey().toString()))); taskModal.header(new ResourceModel("task.propagation.list", "Propagation tasks")); taskModal.show(true); } }; fragment.add(propagation); MetaDataRoleAuthorizationStrategy.authorize(propagation, ENABLE, StandardEntitlement.TASK_LIST); final AjaxLink<String> synchronization = new IndicatingAjaxLink<String>("synchronization") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { target.add(taskModal.setContent(new SyncTasks(pageRef, node.getKey().toString()))); taskModal.header( new ResourceModel("task.synchronization.list", "Synchronization tasks")); taskModal.show(true); } }; fragment.add(synchronization); MetaDataRoleAuthorizationStrategy.authorize( synchronization, ENABLE, StandardEntitlement.TASK_LIST); final AjaxLink<String> push = new IndicatingAjaxLink<String>("push") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { target.add(taskModal.setContent(new PushTasks(pageRef, node.getKey().toString()))); taskModal.header(new ResourceModel("task.push.list", "Push tasks")); taskModal.show(true); } }; fragment.add(push); MetaDataRoleAuthorizationStrategy.authorize(push, ENABLE, StandardEntitlement.TASK_LIST); return fragment; }
private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) { final Fragment fragment = new Fragment("actions", "connectorActions", this); final AjaxLink<String> delete = new IndicatingAjaxLink<String>("delete") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { try { connectorRestClient.delete(Long.class.cast(node.getKey())); target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey())); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While deleting resource {}", node.getKey(), e); } ((BasePage) getPage()).getNotificationPanel().refresh(target); } }; fragment.add(delete); delete.add(new ConfirmationModalBehavior()); MetaDataRoleAuthorizationStrategy.authorize( delete, ENABLE, StandardEntitlement.CONNECTOR_DELETE); final AjaxLink<String> create = new IndicatingAjaxLink<String>("create") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { final ResourceTO modelObject = new ResourceTO(); modelObject.setConnector(Long.class.cast(node.getKey())); modelObject.setConnectorDisplayName(node.getDisplayName()); final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject); resourceModal.setFormModel(model); target.add( resourceModal.setContent(new ResourceModal<>(resourceModal, pageRef, model, true))); resourceModal.header( new Model<>(MessageFormat.format(getString("resource.new"), node.getKey()))); MetaDataRoleAuthorizationStrategy.authorize( resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_CREATE); resourceModal.show(true); } }; fragment.add(create); MetaDataRoleAuthorizationStrategy.authorize( create, ENABLE, StandardEntitlement.RESOURCE_CREATE); final AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { final ConnInstanceTO modelObject = connectorRestClient.read(Long.class.cast(node.getKey())); final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject); resourceModal.setFormModel(model); target.add(resourceModal.setContent(new ConnectorModal(resourceModal, pageRef, model))); resourceModal.header( new Model<>(MessageFormat.format(getString("connector.edit"), node.getKey()))); MetaDataRoleAuthorizationStrategy.authorize( resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.CONNECTOR_UPDATE); resourceModal.show(true); } }; fragment.add(edit); MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.CONNECTOR_UPDATE); return fragment; }