private void cleanSystemMessages(String currentMessageType) { UnpublishMessagesEvent unpublishMessage = new UnpublishMessagesEvent(); unpublishMessage.setShowSystemConsole(false); unpublishMessage.setMessageType(currentMessageType); unpublishMessage.setUserId( (sessionInfo != null && sessionInfo.getIdentity() != null) ? sessionInfo.getIdentity().getIdentifier() : null); unpublishMessagesEvent.fire(unpublishMessage); }
boolean hasAccessRightsForFeature(String feature) { Set<String> grantedRoles = kieACL.getGrantedRoles(feature); if (sessionInfo != null && sessionInfo.getIdentity() != null && sessionInfo.getIdentity().getRoles() != null) { for (Role role : sessionInfo.getIdentity().getRoles()) { if (grantedRoles.contains(role.getName())) { return true; } } } return false; }
private void setSourceEditionGrant() { Set<String> grantedRoles = kieACL.getGrantedRoles(DataModelerFeatures.EDIT_SOURCES); sourceEditionEnabled = false; if (sessionInfo != null && sessionInfo.getIdentity() != null && sessionInfo.getIdentity().getRoles() != null) { for (Role role : sessionInfo.getIdentity().getRoles()) { if (grantedRoles.contains(role.getName())) { sourceEditionEnabled = true; break; } } } }
@Test public void doNotRefreshWhenAnotherUserMakesThePomXMLFileContentChange() throws Exception { final ResourceUpdatedEvent resourceUpdatedEvent = mock(ResourceUpdatedEvent.class); final SessionInfo sessionInfo = mock(SessionInfo.class); when(resourceUpdatedEvent.getSessionInfo()).thenReturn(sessionInfo); when(sessionInfo.getIdentity()).thenReturn(mock(User.class)); when(resourceUpdatedEvent.getPath()).thenReturn(mock(Path.class)); reset(view); presenter.onResourceUpdated(resourceUpdatedEvent); verify(view, never()).setPOM(any(POM.class)); }
private void publishSystemMessages( String messageType, boolean cleanExisting, List<DataModelerError> errors) { PublishBatchMessagesEvent publishMessage = new PublishBatchMessagesEvent(); publishMessage.setCleanExisting(cleanExisting); publishMessage.setMessageType(messageType); publishMessage.setUserId( (sessionInfo != null && sessionInfo.getIdentity() != null) ? sessionInfo.getIdentity().getIdentifier() : null); publishMessage.setPlace(PublishBaseEvent.Place.TOP); SystemMessage systemMessage; for (DataModelerError error : errors) { systemMessage = new SystemMessage(); systemMessage.setMessageType(messageType); systemMessage.setId(error.getId()); systemMessage.setText(error.getMessage()); systemMessage.setPath(error.getFile()); systemMessage.setLevel(error.getLevel()); systemMessage.setLine(error.getLine()); systemMessage.setColumn(error.getColumn()); publishMessage.getMessagesToPublish().add(systemMessage); } publishBatchMessagesEvent.fire(publishMessage); }
@Test public void refreshWhenPomXMLFileContentChanges() throws Exception { final ResourceUpdatedEvent resourceUpdatedEvent = mock(ResourceUpdatedEvent.class); final SessionInfo sessionInfo = mock(SessionInfo.class); when(resourceUpdatedEvent.getSessionInfo()).thenReturn(sessionInfo); when(sessionInfo.getIdentity()).thenReturn(user); when(resourceUpdatedEvent.getPath()).thenReturn(observablePathToPomXML); reset(view); presenter.onResourceUpdated(resourceUpdatedEvent); verify(view).setPOM(any(POM.class)); }