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;
 }
  @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 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;
        }
      }
    }
  }
Beispiel #5
0
 private CommentedOption makeCommentedOption(final String commitMessage) {
   final String name = identity.getName();
   final Date when = new Date();
   final CommentedOption co =
       new CommentedOption(sessionInfo.getId(), name, null, commitMessage, when);
   return co;
 }
 protected String getSessionId(SessionInfo sessionInfo) {
   try {
     return sessionInfo != null ? sessionInfo.getId() : UNKNOWN_SESSION;
   } catch (ContextNotActiveException e) {
     return UNKNOWN_SESSION;
   }
 }
 @Inject
 public DataModelerScreenPresenter(DataModelerScreenView baseView, SessionInfo sessionInfo) {
   super(baseView);
   view = baseView;
   this.sessionInfo = sessionInfo;
   editorId = sessionInfo.getId() + "-" + editorIds++;
 }
  @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));
  }
 void onResourceBatchEvent(@Observes final ResourceBatchChangesEvent batchEvent) {
   if (path != null && batchEvent.containPath(path)) {
     if (sessionInfo.getId().equals(batchEvent.getSessionInfo().getId())) {
       for (final ResourceChange change : batchEvent.getChanges(path)) {
         switch (change.getType()) {
           case COPY:
             executeCopyCommands();
             break;
           case DELETE:
             executeDeleteCommands();
             break;
           case RENAME:
             path = ((ResourceRenamed) change).getDestinationPath();
             executeRenameCommands();
             break;
           case UPDATE:
             executeUpdateCommands();
             break;
         }
       }
     } else {
       for (final ResourceChange change : batchEvent.getChanges(path)) {
         switch (change.getType()) {
           case COPY:
             executeConcurrentCopyCommand(
                 path,
                 ((ResourceCopied) change).getDestinationPath(),
                 batchEvent.getSessionInfo().getId(),
                 batchEvent.getSessionInfo().getIdentity());
             break;
           case DELETE:
             executeConcurrentDeleteCommand(
                 path,
                 batchEvent.getSessionInfo().getId(),
                 batchEvent.getSessionInfo().getIdentity());
             break;
           case RENAME:
             path = ((ResourceRenamed) change).getDestinationPath();
             executeConcurrentRenameCommand(
                 path,
                 ((ResourceRenamed) change).getDestinationPath(),
                 batchEvent.getSessionInfo().getId(),
                 batchEvent.getSessionInfo().getIdentity());
             break;
           case UPDATE:
             executeConcurrentUpdateCommand(
                 path,
                 batchEvent.getSessionInfo().getId(),
                 batchEvent.getSessionInfo().getIdentity());
             break;
         }
       }
     }
   }
 }
 void onResourceUpdated(@Observes final ResourceUpdatedEvent updatedEvent) {
   if (path != null && path.equals(updatedEvent.getPath())) {
     if (sessionInfo.getId().equals(updatedEvent.getSessionInfo().getId())) {
       executeUpdateCommands();
     } else {
       executeConcurrentUpdateCommand(
           updatedEvent.getPath(),
           updatedEvent.getSessionInfo().getId(),
           updatedEvent.getSessionInfo().getIdentity());
     }
   }
 }
 void onResourceCopied(@Observes final ResourceCopiedEvent copiedEvent) {
   if (path != null && path.equals(copiedEvent.getPath())) {
     if (sessionInfo.getId().equals(copiedEvent.getSessionInfo().getId())) {
       executeCopyCommands();
     } else {
       executeConcurrentCopyCommand(
           copiedEvent.getPath(),
           copiedEvent.getDestinationPath(),
           copiedEvent.getSessionInfo().getId(),
           copiedEvent.getSessionInfo().getIdentity());
     }
   }
 }
 void onResourceRenamed(@Observes final ResourceRenamedEvent renamedEvent) {
   if (path != null && path.equals(renamedEvent.getPath())) {
     path = renamedEvent.getDestinationPath();
     if (sessionInfo.getId().equals(renamedEvent.getSessionInfo().getId())) {
       executeRenameCommands();
     } else {
       executeConcurrentRenameCommand(
           renamedEvent.getPath(),
           renamedEvent.getDestinationPath(),
           renamedEvent.getSessionInfo().getId(),
           renamedEvent.getSessionInfo().getIdentity());
     }
   }
 }
 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);
 }
Beispiel #14
0
  @Override
  public void delete(final Path pathToPomXML, final String comment) {
    try {
      final org.uberfire.java.nio.file.Path projectDirectory =
          Paths.convert(pathToPomXML).getParent();
      final Project project2Delete = resolveProject(Paths.convert(projectDirectory));

      ioService.delete(
          projectDirectory,
          StandardDeleteOption.NON_EMPTY_DIRECTORIES,
          new CommentedOption(sessionInfo.getId(), identity.getName(), null, comment));
      deleteProjectEvent.fire(new DeleteProjectEvent(project2Delete));
    } catch (final Exception e) {
      throw ExceptionUtilities.handleException(e);
    }
  }