Exemple #1
0
  public void init(@Observes @Initialize String event) {
    // Chargement de la conf
    String userDir = System.getProperty("user.dir");
    File directory = new File(userDir);
    if (!directory.canRead() || !directory.canWrite())
      throw new BackException("Can't initialize application");
    configurationFile = new File(userDir + "/configuration.k");
    if (!configurationFile.exists()) {
      initConfigurationFile(configurationFile, userDir);
    }
    loadKConfiguration(configurationFile);

    // Chargement du fichier de sauvegarde
    String directionSaveFile = getDirectorySave();
    File tmpSaveFile = new File(directionSaveFile);
    if (!tmpSaveFile.exists()) throw new BackException("Can't initialize application");
    tmpSaveFile = new File(directionSaveFile + "/" + SAVE_FILENAME);
    if (!tmpSaveFile.exists()) {
      try {
        tmpSaveFile.createNewFile();
        JAXBContext jaxbContext = JAXBContext.newInstance(DtoPortfolio.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.marshal(new DtoPortfolio(), tmpSaveFile);
      } catch (IOException | JAXBException e) {
        throw new BackException("Can't initialize application");
      }
    }
    saveFile = tmpSaveFile;
    loadSaveFile();
    if (migration != null) migration.fire(this);
    if (initialisation != null) initialisation.fire("");
  }
  protected void selectProcessDefinition(final ProcessSummary processSummary, final Boolean close) {
    PlaceStatus instanceDetailsStatus =
        placeManager.getStatus(new DefaultPlaceRequest("Process Instance Details Multi"));

    if (instanceDetailsStatus == PlaceStatus.OPEN) {
      placeManager.closePlace("Process Instance Details Multi");
    }

    placeIdentifier = "Advanced Process Details Multi";
    PlaceStatus status = placeManager.getStatus(new DefaultPlaceRequest(placeIdentifier));

    if (status == PlaceStatus.CLOSE) {
      placeManager.goTo(placeIdentifier);
      processDefSelected.fire(
          new ProcessDefSelectionEvent(
              processSummary.getProcessDefId(),
              processSummary.getDeploymentId(),
              selectedServerTemplate,
              processSummary.getProcessDefName()));
    } else if (status == PlaceStatus.OPEN && !close) {
      processDefSelected.fire(
          new ProcessDefSelectionEvent(
              processSummary.getProcessDefId(),
              processSummary.getDeploymentId(),
              selectedServerTemplate,
              processSummary.getProcessDefName()));
    } else if (status == PlaceStatus.OPEN && close) {
      placeManager.closePlace(placeIdentifier);
    }
  }
 public void selectTask(final TaskSummary summary, final Boolean close) {
   final DefaultPlaceRequest defaultPlaceRequest = new DefaultPlaceRequest("Task Details Multi");
   final PlaceStatus status = placeManager.getStatus(defaultPlaceRequest);
   boolean logOnly = false;
   if (summary.getStatus().equals("Completed") && summary.isLogOnly()) {
     logOnly = true;
   }
   if (status == PlaceStatus.CLOSE) {
     placeManager.goTo(defaultPlaceRequest);
     taskSelected.fire(
         new TaskSelectionEvent(
             selectedServerTemplate,
             summary.getDeploymentId(),
             summary.getTaskId(),
             summary.getTaskName(),
             summary.isForAdmin(),
             logOnly));
   } else if (status == PlaceStatus.OPEN && !close) {
     taskSelected.fire(
         new TaskSelectionEvent(
             selectedServerTemplate,
             summary.getDeploymentId(),
             summary.getTaskId(),
             summary.getTaskName(),
             summary.isForAdmin(),
             logOnly));
   } else if (status == PlaceStatus.OPEN && close) {
     placeManager.closePlace("Task Details Multi");
   }
 }
  private void handleLockFailure(final LockInfo lockInfo) {

    if (lockInfo != null) {
      updateLockInfo(lockInfo);
      lockNotification.fire(
          new NotificationEvent(
              WorkbenchConstants.INSTANCE.lockedMessage(lockInfo.lockedBy()),
              NotificationEvent.NotificationType.INFO,
              true,
              lockTarget.getPlace(),
              20));
    } else {
      lockNotification.fire(
          new NotificationEvent(
              WorkbenchConstants.INSTANCE.lockError(),
              NotificationEvent.NotificationType.ERROR,
              true,
              lockTarget.getPlace(),
              20));
    }
    // Delay reloading slightly in case we're dealing with a flood of events
    if (reloadTimer == null) {
      reloadTimer =
          new Timer() {

            public void run() {
              reload();
            }
          };
    }

    if (!reloadTimer.isRunning()) {
      reloadTimer.schedule(250);
    }
  }
  @Override
  public void isComplete(final Callback<Boolean> callback) {
    // Do all Patterns have unique bindings?
    final boolean arePatternBindingsUnique = getValidator().arePatternBindingsUnique();

    // Signal duplicates to other pages
    final DuplicatePatternsEvent event = new DuplicatePatternsEvent(arePatternBindingsUnique);
    duplicatePatternsEvent.fire(event);

    // Are all Actions defined?
    boolean areActionInsertFieldsDefined = true;
    for (List<ActionInsertFactCol52> actions : patternToActionsMap.values()) {
      for (ActionInsertFactCol52 a : actions) {
        if (!getValidator().isActionValid(a)) {
          areActionInsertFieldsDefined = false;
          break;
        }
      }
    }

    // Signal Action Insert Fact Fields to other pages
    final ActionInsertFactFieldsDefinedEvent eventFactFields =
        new ActionInsertFactFieldsDefinedEvent(areActionInsertFieldsDefined);
    actionInsertFactFieldsDefinedEvent.fire(eventFactFields);

    callback.callback(arePatternBindingsUnique && areActionInsertFieldsDefined);
  }
  public void setAll(String json) {
    albums = new HashMap<String, JSONObject>();
    images = new HashMap<String, Map<String, JSONObject>>();

    try {
      JSONArray jAlbums = new JSONArray(json);

      String albumId;
      JSONObject jo;

      for (int i = 0; i < jAlbums.length(); i++) {
        jo = jAlbums.getJSONObject(i);

        if (!jo.has("id")) {
          error.fire(new ErrorEvent("Error, object does not contain albums"));
        }

        albumId = jo.getString("id");

        images.put(albumId, new HashMap<String, JSONObject>());
        if (jo.getInt("size") > 0) {
          storeImagesToAlbum(albumId, jo.getJSONArray("images"));
          jo.remove("images");
        }
        albums.put(albumId, jo);
      }
      loaded = true;
      emptyCache = jAlbums.length() == 0;
    } catch (JSONException e) {
      error.fire(new ErrorEvent("Error: ", e.getMessage()));
    }
  }
 private void performLoginStatusChangeActions(final User user) {
   StyleBindingsRegistry.get().updateStyles();
   if (user == null) {
     throw new RuntimeException("The current user should never be null.");
   } else if (User.ANONYMOUS.equals(user)) {
     logoutEvent.fire(new LoggedOutEvent());
   } else {
     loginEvent.fire(new LoggedInEvent(user));
   }
 }
  @Override
  public Project newProject(
      final Repository repository, final String projectName, final POM pom, final String baseUrl) {
    try {
      // Projects are always created in the FS root
      final Path fsRoot = repository.getRoot();
      final Path projectRootPath = Paths.convert(Paths.convert(fsRoot).resolve(projectName));

      // Set-up project structure and KModule.xml
      kModuleService.setUpKModuleStructure(projectRootPath);

      // Create POM.xml
      pomService.create(projectRootPath, baseUrl, pom);

      // Create Project configuration
      final Path projectConfigPath =
          Paths.convert(Paths.convert(projectRootPath).resolve(PROJECT_IMPORTS_PATH));
      ioService.createFile(Paths.convert(projectConfigPath));
      ioService.write(
          Paths.convert(projectConfigPath),
          projectConfigurationContentHandler.toString(createProjectImports()));

      // Raise an event for the new project
      final Project project = resolveProject(projectRootPath);
      newProjectEvent.fire(new NewProjectEvent(project, sessionInfo));

      // Create a default workspace based on the GAV
      final String legalJavaGroupId[] =
          IdentifierUtils.convertMavenIdentifierToJavaIdentifier(
              pom.getGav().getGroupId().split("\\.", -1));
      final String legalJavaArtifactId[] =
          IdentifierUtils.convertMavenIdentifierToJavaIdentifier(
              pom.getGav().getArtifactId().split("\\.", -1));
      final String defaultWorkspacePath =
          StringUtils.join(legalJavaGroupId, "/")
              + "/"
              + StringUtils.join(legalJavaArtifactId, "/");
      final Path defaultPackagePath =
          Paths.convert(Paths.convert(projectRootPath).resolve(MAIN_RESOURCES_PATH));
      final Package defaultPackage = resolvePackage(defaultPackagePath);
      final Package defaultWorkspacePackage = doNewPackage(defaultPackage, defaultWorkspacePath);

      // Raise an event for the new project's default workspace
      newPackageEvent.fire(new NewPackageEvent(defaultWorkspacePackage));

      // Return new project
      return project;

    } catch (Exception e) {
      throw ExceptionUtilities.handleException(e);
    }
  }
  /**
   * Return news items for display
   *
   * @param newsItemsRequestEvent
   */
  public void observesNewsItemsRequestEvent(@Observes NewsItemsRequestEvent newsItemsRequestEvent) {
    try {
      // Get the list
      List<NewsItem> newsItems = newsItemDAO.getActiveNewsItems();

      // Send the data back
      newsItemsResponseEvent.fire(new NewsItemsResponseEvent(newsItems));
    } catch (Exception e) {
      log.log(Level.SEVERE, e.getMessage(), e);

      // Tell the user what the exception was
      serviceErrorEvent.fire(new ServiceErrorEvent(e.getMessage()));
    }
  }
 @Override
 public QCEvent segment(
     Collection<String> toMove,
     Collection<String> toClone,
     IDWithIssuer pid,
     String targetStudyUID,
     Attributes targetStudyAttributes,
     Attributes targetSeriesAttributes,
     Code qcRejectionCode)
     throws QCOperationNotPermittedException {
   QCOperationContext qcContext =
       structuralChangeService.segment(
           STRUCTURAL_CHANGE.QC,
           toMove,
           toClone,
           pid,
           targetStudyUID,
           targetStudyAttributes,
           targetSeriesAttributes,
           qcRejectionCode);
   QCEvent qcEvent = QCContextImpl.toQCEvent(qcContext);
   internalNotification
       .select(new ServiceQualifier(ServiceType.QCDURINGTRANSACTION))
       .fire(qcEvent);
   return qcEvent;
 }
  public InputStream load(final Path path, final String sessionId) {
    try {
      final InputStream inputStream =
          ioService.newInputStream(Paths.convert(path), StandardOpenOption.READ);

      // Signal opening to interested parties
      resourceOpenedEvent.fire(
          new ResourceOpenedEvent(
              path,
              new SessionInfo() {
                @Override
                public String getId() {
                  return sessionId;
                }

                @Override
                public Identity getIdentity() {
                  return identity;
                }
              }));

      return inputStream;

    } catch (Exception e) {
      throw ExceptionUtilities.handleException(e);
    }
  }
 @Produces
 @ApplicationScoped
 public EntityManagerFactory create() {
   EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdidemo");
   created.fire(new EntityManagerFactoryCreatedEvent(emf));
   return emf;
 }
Exemple #13
0
  @TransactionAttribute(REQUIRED)
  public String update() {
    auth.preserveLogin();

    if (!geaendertArtikel || artikel == null) {
      return JSF_INDEX;
    }

    LOGGER.tracef("Aktualisierter artikel: %s", artikel);

    try {
      artikel = as.updateArtikel(artikel);
    } catch (BezeichnungExistsException | InvalidArtikelException | OptimisticLockException e) {
      final String outcome = updateErrorMsg(e, artikel.getClass());
      return outcome;
    }

    // Push-Event fuer Webbrowser
    updateArtikelEvent.fire(String.valueOf(artikel.getAId()));

    // ValueChangeListener zuruecksetzen
    geaendertArtikel = false;

    // Aufbereitung fuer viewKunde.xhtml
    artikelId = artikel.getAId();
    artikel = null;
    return JSF_LIST_ARTIKEL + JSF_REDIRECT_SUFFIX;
  }
  public String login() {
    IUser storedUser = authenticator.checkCredential(username, password);
    String outcome;

    if (storedUser != null) {
      setLoggedIn(true);
      user = storedUser;
      loginEvent.fire(new LoginEvent(storedUser, requestedRole, requestedStoreId));
      LOG.info(String.format("Successful login: username %s.", getUserName()));
      outcome =
          isStoreRequired()
              ? NavigationElements.STORE_MAIN.getNavigationOutcome()
              : NavigationElements.ENTERPRISE_MAIN.getNavigationOutcome();
    } else {
      FacesContext context = FacesContext.getCurrentInstance();
      String message =
          context
              .getApplication()
              .evaluateExpressionGet(context, "#{strings['login.failed.text']}", String.class);
      context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
      outcome = NavigationElements.LOGIN.getNavigationOutcome();
      LOG.warn(String.format("Failed login: username %s.", getUserName()));
    }
    return outcome;
  }
 public T update(T entity) {
   //		log.info("Updating" + entity);
   em.merge(entity);
   em.flush();
   entityEventSrc.fire(entity);
   return entity;
 }
Exemple #16
0
 void teardown(@Observes final Shutdown shutdown, final Event<PreShutdown> preShutdown) {
   preShutdown.fire(new PreShutdown(shutdown.getStatus()));
   exitRequested = true;
   if (inputPipe != null) {
     inputPipe.stop();
   }
 }
  public Path save(final Path resource, final InputStream content, final String comment) {
    log.info("USER:"******" UPDATING asset [" + resource.getFileName() + "]");

    try {
      final org.kie.commons.java.nio.file.Path nioPath = paths.convert(resource);
      final OutputStream outputStream =
          ioService.newOutputStream(nioPath, makeCommentedOption(comment));
      IOUtils.copy(content, outputStream);
      outputStream.flush();
      outputStream.close();

      // Read Path to ensure attributes have been set
      final Path newPath = paths.convert(nioPath);

      // Signal update to interested parties
      resourceUpdatedEvent.fire(new ResourceUpdatedEvent(newPath, sessionInfo));

      return newPath;

    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw ExceptionUtilities.handleException(e);

    } finally {
      try {
        content.close();
      } catch (IOException e) {
        throw ExceptionUtilities.handleException(e);
      }
    }
  }
  @Override
  public void removeRepository(final String alias) {
    final ConfigGroup thisRepositoryConfig = findRepositoryConfig(alias);

    try {
      configurationService.startBatch();
      if (thisRepositoryConfig != null) {
        configurationService.removeConfiguration(thisRepositoryConfig);
      }

      final Repository repo = configuredRepositories.remove(alias);
      if (repo != null) {
        repositoryRemovedEvent.fire(new RepositoryRemovedEvent(repo));
        ioService.delete(convert(repo.getRoot()).getFileSystem().getPath(null));
      }

      // Remove reference to Repository from Organizational Units
      final Collection<OrganizationalUnit> organizationalUnits =
          organizationalUnitService.getOrganizationalUnits();
      for (OrganizationalUnit ou : organizationalUnits) {
        for (Repository repository : ou.getRepositories()) {
          if (repository.getAlias().equals(alias)) {
            organizationalUnitService.removeRepository(ou, repository);
          }
        }
      }
    } catch (final Exception e) {
      logger.error("Error during remove repository", e);
      throw new RuntimeException(e);
    } finally {
      configurationService.endBatch();
    }
  }
 // Event notifications
 private void notifyFieldSelected(ObjectProperty selectedProperty) {
   if (!skipNextFieldNotification && selectedProperty != null) {
     context.setObjectProperty(selectedProperty);
     dataModelerWBContextEvent.fire(new DataModelerWorkbenchContextChangeEvent());
   }
   skipNextFieldNotification = false;
 }
  void fireContextChangeEvent() {
    if (activeFolderItem == null) {
      contextChangedEvent.fire(
          new ProjectContextChangeEvent(activeOrganizationalUnit, activeRepository, activeProject));
      return;
    }

    if (activeFolderItem.getItem() instanceof Package) {
      setActivePackage((Package) activeFolderItem.getItem());
      contextChangedEvent.fire(
          new ProjectContextChangeEvent(
              activeOrganizationalUnit, activeRepository, activeProject, activePackage));
    } else if (activeFolderItem.getType().equals(FolderItemType.FOLDER)) {
      explorerService.call(getResolvePackageRemoteCallback()).resolvePackage(activeFolderItem);
    }
  }
  public void fireEvents() {
    Document d = new Document("Test");
    docEvent.fire(d); // general fire of a Document related event

    // send a created event
    docEvent.select(new AnnotationLiteral<Created>() {}).fire(d);

    d.update();
    // send an updated event
    docEvent.select(new AnnotationLiteral<Updated>() {}).fire(d);

    // send an updated and approved event
    docEvent
        .select(new AnnotationLiteral<Updated>() {}, new AnnotationLiteral<Approved>() {})
        .fire(d);
  }
 @Override
 public void notify(QCEvent event) {
   LOG.debug(
       "QC info[Notify] - Operation successfull," + " notification triggered with event {}",
       event.toString());
   internalNotification.select(new ServiceQualifier(ServiceType.QCPOSTPROCESSING)).fire(event);
 }
  public void refreshNewTask(@Observes NewTaskEvent newTask) {
    refreshGrid();
    PlaceStatus status = placeManager.getStatus(new DefaultPlaceRequest("Task Details Multi"));
    if (status == PlaceStatus.OPEN) {
      taskSelected.fire(
          new TaskSelectionEvent(
              selectedServerTemplate, null, newTask.getNewTaskId(), newTask.getNewTaskName()));
    } else {
      placeManager.goTo("Task Details Multi");
      taskSelected.fire(
          new TaskSelectionEvent(
              selectedServerTemplate, null, newTask.getNewTaskId(), newTask.getNewTaskName()));
    }

    view.setSelectedTask(new TaskSummary(newTask.getNewTaskId(), newTask.getNewTaskName()));
  }
 public void register() throws Exception {
   log.info("Registering " + newUser.getName());
   em.persist(newUser);
   userEventSrc.fire(newUser);
   initNewUser();
   emptyFields();
 }
 public void hideDataModellerDocks(@Observes PlaceHidEvent event) {
   if (context != null) {
     if ("DataModelerEditor".equals(event.getPlace().getIdentifier())) {
       dataModelerFocusEvent.fire(new DataModelerWorkbenchFocusEvent().lostFocus());
     }
   }
 }
 public T merge(T entity) {
   final T merge = em.merge(entity);
   ElasticSearchableEntityEvent event =
       createElasticSearchableEntityEvent(entity, EntityEventType.MERGE);
   events.fire(event);
   return merge;
 }
Exemple #27
0
  @Override
  public void copy(final Path pathToPomXML, final String newName, final String comment) {
    try {
      final org.uberfire.java.nio.file.Path projectDirectory =
          Paths.convert(pathToPomXML).getParent();
      final org.uberfire.java.nio.file.Path newProjectPath =
          projectDirectory.resolveSibling(newName);

      final POM content = pomService.load(pathToPomXML);

      if (newProjectPath.equals(projectDirectory)) {
        return;
      }

      if (ioService.exists(newProjectPath)) {
        throw new FileAlreadyExistsException(newProjectPath.toString());
      }

      content.setName(newName);
      final Path newPathToPomXML = Paths.convert(newProjectPath.resolve("pom.xml"));
      ioService.startBatch();
      ioService.copy(projectDirectory, newProjectPath, makeCommentedOption(comment));
      pomService.save(newPathToPomXML, content, null, comment);
      ioService.endBatch();
      final Project newProject = resolveProject(Paths.convert(newProjectPath));
      newProjectEvent.fire(new NewProjectEvent(newProject, sessionInfo));

    } catch (final Exception e) {
      throw ExceptionUtilities.handleException(e);
    }
  }
  public void handleMessage(@Observes HelloMessage event) {
    System.out.println("Received HelloMessage from Client: " + event.getMessage());

    // Note that because Response is declared @Conversational, this message
    // only goes to the client who sent the HelloEvent.
    responseEvent.fire(
        new Response(event.getMessage() + " @ timemillis: " + System.currentTimeMillis()));
  }
 @UiHandler("newPropertyButton")
 void newPropertyClick(ClickEvent event) {
   lockRequired.fire(new LockRequiredEvent());
   if (getContext() != null) {
     newFieldPopup.init(getContext());
     newFieldPopup.show();
   }
 }
 private void notifyFieldDeleted(ObjectProperty deletedProperty) {
   dataModelerEvent.fire(
       new DataObjectFieldDeletedEvent(
           getContext().getContextId(),
           DataModelerEvent.DATA_OBJECT_BROWSER,
           getDataObject(),
           deletedProperty));
 }