/**
     * Function called when an audio device is plugged or unplugged.
     *
     * @param event The property change event which may concern the audio device.
     */
    public void propertyChange(PropertyChangeEvent event) {
      if (DeviceConfiguration.PROP_AUDIO_SYSTEM_DEVICES.equals(event.getPropertyName())) {
        NotificationService notificationService = getNotificationService();

        if (notificationService != null) {
          // Registers only once to the  popup message notification
          // handler.
          if (!isRegisteredToPopupMessageListener) {
            isRegisteredToPopupMessageListener = true;
            managePopupMessageListenerRegistration(true);
          }

          // Fires the popup notification.
          ResourceManagementService resources = NeomediaActivator.getResources();
          Map<String, Object> extras = new HashMap<String, Object>();

          extras.put(NotificationData.POPUP_MESSAGE_HANDLER_TAG_EXTRA, this);
          notificationService.fireNotification(
              DEVICE_CONFIGURATION_HAS_CHANGED,
              resources.getI18NString("impl.media.configform" + ".AUDIO_DEVICE_CONFIG_CHANGED"),
              resources.getI18NString(
                  "impl.media.configform" + ".AUDIO_DEVICE_CONFIG_MANAGMENT_CLICK"),
              null,
              extras);
        }
      }
    }
Пример #2
0
  /**
   * Upload files to pre-configured url.
   *
   * @param uploadLocation the location we are uploading to.
   * @param fileName the filename we use for the resulting filename we upload.
   * @param params the optional parameter names.
   * @param values the optional parameter values.
   */
  static void uploadLogs(String uploadLocation, String fileName, String[] params, String[] values) {
    try {
      File tempDir = LoggingUtilsActivator.getFileAccessService().getTemporaryDirectory();
      File newDest = new File(tempDir, fileName);

      File optionalFile = null;

      // if we have some description params
      // save them to file and add it to archive
      if (params != null) {
        optionalFile =
            new File(
                LoggingUtilsActivator.getFileAccessService().getTemporaryDirectory(),
                "description.txt");
        OutputStream out = new FileOutputStream(optionalFile);
        for (int i = 0; i < params.length; i++) {
          out.write((params[i] + " : " + values[i] + "\r\n").getBytes("UTF-8"));
        }
        out.flush();
        out.close();
      }

      newDest = LogsCollector.collectLogs(newDest, optionalFile);

      // don't leave any unneeded information
      if (optionalFile != null) optionalFile.delete();

      if (uploadLocation == null) return;

      if (HttpUtils.postFile(uploadLocation, "logs", newDest) != null) {
        NotificationService notificationService = LoggingUtilsActivator.getNotificationService();

        if (notificationService != null) {
          ResourceManagementService resources = LoggingUtilsActivator.getResourceService();
          String bodyMsgKey = "plugin.loggingutils.ARCHIVE_MESSAGE_OK";

          notificationService.fireNotification(
              LOGFILES_ARCHIVED,
              resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"),
              resources.getI18NString(bodyMsgKey, new String[] {uploadLocation}),
              null);
        }
      }
    } catch (Throwable e) {
      logger.error("Cannot upload file", e);
    }
  }
Пример #3
0
  /**
   * Asks user for a location to save logs by poping up a file chooser. and archiving logs and
   * saving them on the specified location.
   */
  private void collectLogs() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    SipCommFileChooser fileChooser =
        GenericFileDialog.create(
            null,
            resources.getI18NString("plugin.loggingutils.ARCHIVE_FILECHOOSE_TITLE"),
            SipCommFileChooser.SAVE_FILE_OPERATION);
    fileChooser.setSelectionMode(SipCommFileChooser.SAVE_FILE_OPERATION);

    String defaultDir = "";
    try {
      defaultDir =
          LoggingUtilsActivator.getFileAccessService()
                  .getDefaultDownloadDirectory()
                  .getAbsolutePath()
              + File.separator;
    } catch (IOException ex) {
    }
    fileChooser.setStartPath(defaultDir + LogsCollector.getDefaultFileName());

    File dest = fileChooser.getFileFromDialog();

    if (dest == null) return;

    dest = LogsCollector.collectLogs(dest, null);

    NotificationService notificationService = LoggingUtilsActivator.getNotificationService();

    if (notificationService != null) {
      String bodyMsgKey =
          (dest == null)
              ? "plugin.loggingutils.ARCHIVE_MESSAGE_NOTOK"
              : "plugin.loggingutils.ARCHIVE_MESSAGE_OK";

      notificationService.fireNotification(
          LOGFILES_ARCHIVED,
          resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"),
          resources.getI18NString(bodyMsgKey, new String[] {dest.getAbsolutePath()}),
          null);
    }
  }
  /**
   * Returns the <tt>NotificationService</tt> obtained from the bundle context.
   *
   * @return The <tt>NotificationService</tt> obtained from the bundle context.
   */
  public static NotificationService getNotificationService() {
    if (notificationService == null) {
      // Get the notification service implementation
      ServiceReference notifReference =
          bundleContext.getServiceReference(NotificationService.class.getName());

      notificationService = (NotificationService) bundleContext.getService(notifReference);

      if (notificationService != null) {
        // Register a popup message for a device configuration changed
        // notification.
        notificationService.registerDefaultNotificationForEvent(
            DEVICE_CONFIGURATION_HAS_CHANGED,
            net.java.sip.communicator.service.notification.NotificationAction.ACTION_POPUP_MESSAGE,
            "Device onfiguration has changed",
            null);
      }
    }

    return notificationService;
  }
  @Override
  public void copyToEnvironment(String site, String environment, String path)
      throws DeploymentException {
    ServicesConfig servicesConfig = getServicesManager().getService(ServicesConfig.class);
    PersistenceManagerService persistenceManagerService =
        getServicesManager().getService(PersistenceManagerService.class);
    String siteRepoRootPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);

    String envRepoPath = SITE_ENVIRONMENT_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
    envRepoPath = envRepoPath.replaceAll(ENVIRONMENT_REPLACEMENT_PATTERN, environment);

    NodeRef envRepoRoot = persistenceManagerService.getNodeRef(envRepoPath);

    NodeRef envNode = persistenceManagerService.getNodeRef(envRepoRoot, path);
    NodeRef nodeRef = persistenceManagerService.getNodeRef(siteRepoRootPath, path);
    if (nodeRef != null) {
      if (envNode == null) {
        envNode = createLiveRepositoryCopy(envRepoRoot, path, nodeRef);
      } else {
        FileInfo envNodeInfo = persistenceManagerService.getFileInfo(envNode);
        if (envNodeInfo.isFolder()) {
          Map<QName, Serializable> copyNodeProps = persistenceManagerService.getProperties(nodeRef);
          copyNodeProps.put(ContentModel.PROP_NAME, envNodeInfo.getName());
          persistenceManagerService.setProperties(envNode, copyNodeProps);
        } else {
          persistenceManagerService.copy(nodeRef, envNode);
        }
      }
      Serializable sendEmailValue =
          persistenceManagerService.getProperty(
              nodeRef, CStudioContentModel.PROP_WEB_WF_SEND_EMAIL);
      boolean sendEmail = (sendEmailValue != null) && (Boolean) sendEmailValue;

      if (sendEmail) {
        Serializable submittedByValue =
            persistenceManagerService.getProperty(
                nodeRef, CStudioContentModel.PROP_WEB_WF_SUBMITTED_BY);
        String submittedBy = "";
        if (submittedByValue != null) {
          submittedBy = (String) submittedByValue;
        } else {
          logger.error("did not send approval notification as submitted by property is null");
          return;
        }
        // DmPathTO path = new DmPathTO(nodePath);
        String approver =
            (String)
                persistenceManagerService.getProperty(
                    nodeRef, CStudioContentModel.PROP_WEB_APPROVED_BY);
        NotificationService notificationService =
            getServicesManager().getService(NotificationService.class);
        notificationService.sendApprovalNotification(site, submittedBy, path, approver);
        /*
         * Remove this sendmail property as we are done sending email
         */
        persistenceManagerService.removeProperty(
            nodeRef, CStudioContentModel.PROP_WEB_WF_SEND_EMAIL);
      }

      Map<QName, Serializable> nodeProps = persistenceManagerService.getProperties(envNode);
      for (QName propName : DmConstants.SUBMITTED_PROPERTIES) {
        nodeProps.remove(propName);
      }
      persistenceManagerService.setProperties(envNode, nodeProps);

      nodeProps = persistenceManagerService.getProperties(nodeRef);
      for (QName propName : DmConstants.SUBMITTED_PROPERTIES) {
        nodeProps.remove(propName);
      }
      persistenceManagerService.setProperties(nodeRef, nodeProps);
    }
  }