예제 #1
0
  private Configurable getComponentFromAnnotation(String name, S4Component s4Component) {
    Configurable configurable;
    Class<? extends Configurable> defClass = s4Component.defaultClass();

    if (defClass.equals(Configurable.class) && s4Component.mandatory()) {
      throw new InternalConfigurationException(
          getInstanceName(), name, "mandatory property is not set!");
    }

    if (Modifier.isAbstract(defClass.getModifiers()) && s4Component.mandatory())
      throw new InternalConfigurationException(
          getInstanceName(), name, defClass.getName() + " is abstract!");

    // because we're forced to use the default type, make sure that it
    // is set
    if (defClass.equals(Configurable.class)) {
      if (s4Component.mandatory()) {
        throw new InternalConfigurationException(
            getInstanceName(), name, instanceName + ": no default class defined for " + name);
      } else {
        return null;
      }
    }

    configurable = ConfigurationManager.getInstance(defClass);
    if (configurable == null) {
      throw new InternalConfigurationException(
          getInstanceName(), name, "instantiation of referenenced configurable failed");
    }

    return configurable;
  }
예제 #2
0
  /** Initializes and constructs this panel. */
  private void init() {
    this.phoneNumberCombo.setEditable(true);

    this.callViaPanel.add(callViaLabel);
    this.callViaPanel.add(accountSelectorBox);

    this.comboPanel.add(phoneNumberCombo, BorderLayout.CENTER);

    this.callButton.setName("call");
    this.hangupButton.setName("hangup");
    this.minimizeButton.setName("minimize");
    this.restoreButton.setName("restore");

    this.minimizeButton.setToolTipText(
        Messages.getI18NString("hideCallPanel").getText() + " Ctrl - H");
    this.restoreButton.setToolTipText(
        Messages.getI18NString("showCallPanel").getText() + " Ctrl - H");

    this.callButton.addActionListener(this);
    this.hangupButton.addActionListener(this);
    this.minimizeButton.addActionListener(this);
    this.restoreButton.addActionListener(this);

    this.buttonsPanel.add(callButton);
    this.buttonsPanel.add(hangupButton);

    this.callButton.setEnabled(false);

    this.hangupButton.setEnabled(false);

    this.add(minimizeButtonPanel, BorderLayout.SOUTH);

    this.setCallPanelVisible(ConfigurationManager.isCallPanelShown());
  }
예제 #3
0
  /**
   * Gets a component associated with the given parameter name. First search the component in
   * property table, then try to get component by name from the manager, then creates component with
   * default properties.
   *
   * @param name the parameter name
   * @return the component associated with the name
   * @throws edu.cmu.sphinx.util.props.PropertyException if the component does not exist or is of
   *     the wrong type.
   */
  public Configurable getComponent(String name) throws PropertyException {
    S4PropWrapper s4PropWrapper = getProperty(name, S4Component.class);
    Configurable configurable = null;

    S4Component s4Component = (S4Component) s4PropWrapper.getAnnotation();
    Class<? extends Configurable> expectedType = s4Component.type();

    Object propVal = propValues.get(name);

    if (propVal != null && propVal instanceof Configurable) {
      return (Configurable) propVal;
    }

    if (propVal != null && propVal instanceof String) {
      PropertySheet ps = cm.getPropertySheet(flattenProp(name));
      if (ps != null) configurable = ps.getOwner();
      else
        throw new InternalConfigurationException(
            getInstanceName(), name, "component '" + flattenProp(name) + "' is missing");
    }

    if (configurable != null && !expectedType.isInstance(configurable))
      throw new InternalConfigurationException(
          getInstanceName(), name, "mismatch between annotation and component type");

    if (configurable != null) {
      propValues.put(name, configurable);
      return configurable;
    }

    configurable = getComponentFromAnnotation(name, s4Component);

    propValues.put(name, configurable);
    return configurable;
  }
예제 #4
0
  private void applyConfigurationChange(String propName, Object cmName, Object value)
      throws PropertyException {
    rawProps.put(propName, cmName);
    propValues.put(propName, value != null ? value : cmName);

    if (getInstanceName() != null) cm.fireConfChanged(getInstanceName(), propName);

    if (owner != null) owner.newProperties(this);
  }
  public static ConfigurationManager getInstance() {
    try {
      class_mon.enter();

      if (config == null) {

        // this is nasty but I can't see an easy way around it. Unfortunately while reading the
        // config
        // we hit other code (logging for example) that needs access to the config data. Things are
        // cunningly (?) arranged so that a recursive call here *won't* result in a further
        // (looping)
        // recursive call if we attempt to load the config again. Hence this disgusting code that
        // goes for a second load attempt

        if (config_temp == null) {

          config_temp = new ConfigurationManager();

          config_temp.load();

          config_temp.initialise();

          config = config_temp;

        } else {

          if (config_temp.propertiesMap == null) {

            config_temp.load();
          }

          return (config_temp);
        }
      }

      return config;

    } finally {
      class_mon.exit();
    }
  }
예제 #6
0
  /** Hides the panel containing call and hangup buttons. */
  public void setCallPanelVisible(boolean isVisible) {
    if (isVisible) {
      this.add(comboPanel, BorderLayout.NORTH);
      this.add(buttonsPanel, BorderLayout.CENTER);

      this.minimizeButtonPanel.removeAll();
      this.minimizeButtonPanel.add(minimizeButton);
    } else {
      this.remove(comboPanel);
      this.remove(buttonsPanel);

      this.minimizeButtonPanel.removeAll();
      this.minimizeButtonPanel.add(restoreButton);

      if (mainFrame.isVisible())
        this.mainFrame.getContactListPanel().getContactList().requestFocus();
    }

    if (ConfigurationManager.isCallPanelShown() != isVisible)
      ConfigurationManager.setShowCallPanel(isVisible);

    this.mainFrame.validate();
  }
예제 #7
0
  /**
   * Returns the class of of a registered component property without instantiating it.
   *
   * @param propName the name of the property
   * @return class of the component corresponding to that property
   */
  public Class<? extends Configurable> getComponentClass(String propName) {
    Class<? extends Configurable> defClass = null;

    if (propValues.get(propName) != null)
      try {
        Class<?> objClass = Class.forName((String) propValues.get(propName));
        defClass = objClass.asSubclass(Configurable.class);
      } catch (ClassNotFoundException e) {
        PropertySheet ps = cm.getPropertySheet(flattenProp(propName));
        defClass = ps.ownerClass;
      }
    else {
      S4Component comAnno = (S4Component) registeredProperties.get(propName).getAnnotation();
      defClass = comAnno.defaultClass();
      if (comAnno.mandatory()) defClass = null;
    }

    return defClass;
  }
예제 #8
0
  protected void notifyOfReject(Context c, XmlWorkflowItem wi, EPerson e, String reason) {
    try {
      // Get the item title
      String title = wi.getItem().getName();

      // Get the collection
      Collection coll = wi.getCollection();

      // Get rejector's name
      String rejector = getEPersonName(e);
      Locale supportedLocale = I18nUtil.getEPersonLocale(e);
      Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "submit_reject"));

      email.addRecipient(wi.getSubmitter().getEmail());
      email.addArgument(title);
      email.addArgument(coll.getName());
      email.addArgument(rejector);
      email.addArgument(reason);
      email.addArgument(ConfigurationManager.getProperty("dspace.url") + "/mydspace");

      email.send();
    } catch (Exception ex) {
      // log this email error
      log.warn(
          LogManager.getHeader(
              c,
              "notify_of_reject",
              "cannot email user"
                  + " eperson_id"
                  + e.getID()
                  + " eperson_email"
                  + e.getEmail()
                  + " workflow_item_id"
                  + wi.getID()));
    }
  }
 @Override
 public String getMyDSpaceLink() {
   return ConfigurationManager.getProperty("dspace.url") + "/mydspace";
 }
예제 #10
0
  /**
   * Gets a list of components associated with the given parameter name
   *
   * @param <T> parent component
   * @param name the parameter name
   * @param tclass the class of the list elements
   * @return the component associated with the name
   * @throws PropertyException if the component does not exist or is of the wrong type.
   */
  public <T> List<T> getComponentList(String name, Class<T> tclass)
      throws InternalConfigurationException {
    getProperty(name, S4ComponentList.class);

    List<?> components = (List<?>) propValues.get(name);

    assert registeredProperties.get(name).getAnnotation() instanceof S4ComponentList;
    S4ComponentList annotation = (S4ComponentList) registeredProperties.get(name).getAnnotation();

    // no components names are available and no component list was yet
    // loaded therefore load the default list of components from the
    // annotation
    if (components == null) {
      List<Class<? extends Configurable>> defClasses = Arrays.asList(annotation.defaultList());

      // if (annotation.mandatory() && defClasses.isEmpty())
      // throw new InternalConfigurationException(getInstanceName(), name,
      // "mandatory property is not set!");

      List<Configurable> defaultComponents = new ArrayList<Configurable>();

      for (Class<? extends Configurable> defClass : defClasses) {
        defaultComponents.add(ConfigurationManager.getInstance(defClass));
      }

      propValues.put(name, defaultComponents);

    } else if (!components.isEmpty() && !(components.get(0) instanceof Configurable)) {

      List<Configurable> resolvedComponents = new ArrayList<Configurable>();

      for (Object componentName : components) {
        Configurable configurable = cm.lookup((String) componentName);

        if (configurable != null) {
          resolvedComponents.add(configurable);
        } else if (!annotation.beTolerant()) {
          throw new InternalConfigurationException(
              name,
              (String) componentName,
              "lookup of list-element '" + componentName + "' failed!");
        }
      }

      propValues.put(name, resolvedComponents);
    }

    List<?> values = (List<?>) propValues.get(name);
    ArrayList<T> result = new ArrayList<T>();
    for (Object obj : values) {
      if (tclass.isInstance(obj)) {
        result.add(tclass.cast(obj));
      } else {
        throw new InternalConfigurationException(
            getInstanceName(),
            name,
            "Not all elements have required type "
                + tclass
                + " Found one of type "
                + obj.getClass());
      }
    }
    return result;
  }
예제 #11
0
  /** Sherpa romeo submission support */
  public void make_sherpaRomeo_submission(Item item, Division divIn) throws WingException {

    if (ConfigurationManager.getBooleanProperty(
        "webui.submission.sherparomeo-policy-enabled", true)) {

      SHERPASubmitService sherpaSubmitService =
          new DSpace().getSingletonService(SHERPASubmitService.class);

      if (sherpaSubmitService.hasISSNs(context, item)) {
        List div = divIn.addList("submit-upload-new", List.TYPE_FORM);
        div.setHead(T_sherpa_title);

        // Since sherpa web service doesn't work reliable with more than 1 issn, perform the service
        // for each issn
        Set<String> issns = sherpaSubmitService.getISSNs(context, item);
        Iterator<String> issnsIterator = issns.iterator();

        int i = 0;
        while (issnsIterator.hasNext()) {
          SHERPAResponse shresp =
              sherpaSubmitService.searchRelatedJournalsByISSN(issnsIterator.next());
          java.util.List<SHERPAJournal> journals = shresp.getJournals();
          java.util.List<SHERPAPublisher> publishers = shresp.getPublishers();

          if (CollectionUtils.isNotEmpty(journals)) {
            for (SHERPAJournal journ : journals) {
              SHERPAPublisher pub = publishers.get(0);

              List sherpaList = div.addList("sherpaList" + (i + 1), "simple", "sherpaList");
              sherpaList
                  .addItem()
                  .addFigure(
                      contextPath + "/static/images/" + (i == 0 ? "romeosmall" : "clear") + ".gif",
                      "http://www.sherpa.ac.uk/romeo/",
                      "sherpaLogo");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_journal);
              sherpaList.addItem(journ.getTitle() + " (" + journ.getIssn() + ")");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_publisher);
              sherpaList.addItemXref(pub.getHomeurl(), pub.getName());

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_colour);
              sherpaList
                  .addItem()
                  .addHighlight("sherpaStyle " + pub.getRomeocolour())
                  .addContent(message("xmlui.aspect.sherpa.submission." + pub.getRomeocolour()));
              sherpaList
                  .addItem()
                  .addXref(
                      "http://www.sherpa.ac.uk/romeo/search.php?issn=" + journ.getIssn(),
                      T_sherpa_more,
                      "sherpaMoreInfo");

              i = i + 1;
            }
          }
        }

        List sherpaList = div.addList("sherpaListEnd", "simple", "sherpaList");
        sherpaList.addItem(T_sherpa_consult);
      }
    }
  }
예제 #12
0
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // If we are actually editing information of an uploaded file,
    // then display that body instead!
    if (this.editFile != null) {
      editFile.addBody(body);
      return;
    }

    // Get a list of all files in the original bundle
    Item item = submission.getItem();
    Collection collection = submission.getCollection();
    String actionURL =
        contextPath + "/handle/" + collection.getHandle() + "/submit/" + knot.getId() + ".continue";
    boolean disableFileEditing =
        (submissionInfo.isInWorkflow())
            && !ConfigurationManager.getBooleanProperty("workflow", "reviewer.file-edit");
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    // Part A:
    //  First ask the user if they would like to upload a new file (may be the first one)
    Division div =
        body.addInteractiveDivision(
            "submit-upload", actionURL, Division.METHOD_MULTIPART, "primary submission");
    div.setHead(T_submission_head);
    addSubmissionProgressList(div);

    List upload = null;
    if (!disableFileEditing) {
      // Only add the upload capabilities for new item submissions
      upload = div.addList("submit-upload-new", List.TYPE_FORM);
      upload.setHead(T_head);
      addRioxxVersionSection(upload, item);

      File file = upload.addItem().addFile("file");
      file.setLabel(T_file);
      file.setHelp(T_file_help);
      file.setRequired();

      // if no files found error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_NO_FILES_ERROR) {
        file.addError(T_file_error);
      }

      // if an upload error was thrown by processing class, display it!
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_UPLOAD_ERROR) {
        file.addError(T_upload_error);
      }

      // if virus checking was attempted and failed in error then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_VIRUS_CHECKER_UNAVAILABLE) {
        file.addError(T_virus_checker_error);
      }

      // if virus checking was attempted and a virus found then let the user know
      if (this.errorFlag == org.dspace.submit.step.UploadStep.STATUS_CONTAINS_VIRUS) {
        file.addError(T_virus_error);
      }

      Text description = upload.addItem().addText("description");
      description.setLabel(T_description);
      description.setHelp(T_description_help);

      Button uploadSubmit = upload.addItem().addButton("submit_upload");
      uploadSubmit.setValue(T_submit_upload);
    }

    make_sherpaRomeo_submission(item, div);

    // Part B:
    //  If the user has already uploaded files provide a list for the user.
    if (bitstreams.length > 0 || disableFileEditing) {
      Table summary = div.addTable("submit-upload-summary", (bitstreams.length * 2) + 2, 7);
      summary.setHead(T_head2);

      Row header = summary.addRow(Row.ROLE_HEADER);
      header.addCellContent(T_column0); // primary bitstream
      header.addCellContent(T_column1); // select checkbox
      header.addCellContent(T_column2); // file name
      header.addCellContent(T_column3); // size
      header.addCellContent(T_column4); // description
      header.addCellContent(T_column5); // format
      header.addCellContent(T_column6); // edit button

      for (Bitstream bitstream : bitstreams) {
        int id = bitstream.getID();
        String name = bitstream.getName();
        String url = makeBitstreamLink(item, bitstream);
        long bytes = bitstream.getSize();
        String desc = bitstream.getDescription();
        String algorithm = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();

        Row row = summary.addRow();

        // Add radio-button to select this as the primary bitstream
        Radio primary = row.addCell().addRadio("primary_bitstream_id");
        primary.addOption(String.valueOf(id));

        // If this bitstream is already marked as the primary bitstream
        // mark it as such.
        if (bundles[0].getPrimaryBitstreamID() == id) {
          primary.setOptionSelected(String.valueOf(id));
        }

        if (!disableFileEditing) {
          // Workflow users can not remove files.
          CheckBox remove = row.addCell().addCheckBox("remove");
          remove.setLabel("remove");
          remove.addOption(id);
        } else {
          row.addCell();
        }

        row.addCell().addXref(url, name);
        row.addCellContent(bytes + " bytes");
        if (desc == null || desc.length() == 0) {
          row.addCellContent(T_unknown_name);
        } else {
          row.addCellContent(desc);
        }

        BitstreamFormat format = bitstream.getFormat();
        if (format == null) {
          row.addCellContent(T_unknown_format);
        } else {
          int support = format.getSupportLevel();
          Cell cell = row.addCell();
          cell.addContent(format.getMIMEType());
          cell.addContent(" ");
          switch (support) {
            case 1:
              cell.addContent(T_supported);
              break;
            case 2:
              cell.addContent(T_known);
              break;
            case 3:
              cell.addContent(T_unsupported);
              break;
          }
        }

        Button edit = row.addCell().addButton("submit_edit_" + id);
        edit.setValue(T_submit_edit);

        Row checksumRow = summary.addRow();
        checksumRow.addCell();
        Cell checksumCell = checksumRow.addCell(null, null, 0, 6, null);
        checksumCell.addHighlight("bold").addContent(T_checksum);
        checksumCell.addContent(" ");
        checksumCell.addContent(algorithm + ":" + checksum);
      }

      if (!disableFileEditing) {
        // Workflow users can not remove files.
        Row actionRow = summary.addRow();
        actionRow.addCell();
        Button removeSeleceted =
            actionRow.addCell(null, null, 0, 6, null).addButton("submit_remove_selected");
        removeSeleceted.setValue(T_submit_remove);
      }

      upload = div.addList("submit-upload-new-part2", List.TYPE_FORM);
    }

    // Part C:
    // add standard control/paging buttons
    addControlButtons(upload);
  }
예제 #13
0
  /**
   * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the
   * appropriate operations.
   *
   * @param e the event.
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemName = menuItem.getName();

    ConferenceChatManager conferenceManager =
        GuiActivator.getUIService().getConferenceChatManager();

    if (itemName.equals("removeChatRoom")) {
      conferenceManager.removeChatRoom(chatRoomWrapper);
    } else if (itemName.equals("leaveChatRoom")) {
      conferenceManager.leaveChatRoom(chatRoomWrapper);
    } else if (itemName.equals("joinChatRoom")) {
      String nickName = null;

      nickName =
          ConfigurationManager.getChatRoomProperty(
              chatRoomWrapper.getParentProvider().getProtocolProvider(),
              chatRoomWrapper.getChatRoomID(),
              "userNickName");
      if (nickName == null) nickName = getNickname();

      if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
      else conferenceManager.joinChatRoom(chatRoomWrapper);
    } else if (itemName.equals("openChatRoom")) {
      if (chatRoomWrapper.getChatRoom() != null) {
        if (!chatRoomWrapper.getChatRoom().isJoined()) {
          String nickName = null;

          nickName =
              ConfigurationManager.getChatRoomProperty(
                  chatRoomWrapper.getParentProvider().getProtocolProvider(),
                  chatRoomWrapper.getChatRoomID(),
                  "userNickName");
          if (nickName == null) nickName = getNickname();

          if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
          else conferenceManager.joinChatRoom(chatRoomWrapper);
        }
      } else {
        // this is not a server persistent room we must create it
        // and join
        chatRoomWrapper =
            GuiActivator.getUIService()
                .getConferenceChatManager()
                .createChatRoom(
                    chatRoomWrapper.getChatRoomName(),
                    chatRoomWrapper.getParentProvider().getProtocolProvider(),
                    new ArrayList<String>(),
                    "",
                    false,
                    true);

        String nickName = null;

        nickName =
            ConfigurationManager.getChatRoomProperty(
                chatRoomWrapper.getParentProvider().getProtocolProvider(),
                chatRoomWrapper.getChatRoomID(),
                "userNickName");

        if (nickName == null) nickName = getNickname();

        if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
        else conferenceManager.joinChatRoom(chatRoomWrapper);
      }

      ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
      ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

      chatWindowManager.openChat(chatPanel, true);
    } else if (itemName.equals("joinAsChatRoom")) {
      ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper);

      authWindow.setVisible(true);
    } else if (itemName.equals("nickNameChatRoom")) {
      String nickName = null;

      nickName =
          ConfigurationManager.getChatRoomProperty(
              chatRoomWrapper.getParentProvider().getProtocolProvider(),
              chatRoomWrapper.getChatRoomID(),
              "userNickName");

      ChatOperationReasonDialog reasonDialog =
          new ChatOperationReasonDialog(
              GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"),
              GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL"));

      reasonDialog.setReasonFieldText(
          nickName == null
              ? chatRoomWrapper.getParentProvider().getProtocolProvider().getAccountID().getUserID()
              : nickName);

      int result = reasonDialog.showDialog();

      if (result == MessageDialog.OK_RETURN_CODE) {
        nickName = reasonDialog.getReason().trim();
      }

      ConfigurationManager.updateChatRoomProperty(
          chatRoomWrapper.getParentProvider().getProtocolProvider(),
          chatRoomWrapper.getChatRoomID(),
          "userNickName",
          nickName);
    }
  }