@Override
  protected void setProperties(UIComponent component) {
    if (component instanceof SiteTreeViewer) {
      if (rootNodeExpression == null) {
        new IllegalArgumentException("Provide root node");
      }

      Object o = null;
      IWContext iwc = CoreUtil.getIWContext();
      if (iwc == null) {
        return;
      }

      ValueExpression ve =
          WFUtil.createValueExpression(getELContext(), rootNodeExpression, TreeNode.class);
      o = ve.getValue(getELContext());
      if (!(o instanceof TreeNode)) {
        new IllegalArgumentException("Provide root node");
      }
      rootNode = (TreeNode) o;

      SiteTreeViewer treeViewer = (SiteTreeViewer) component;

      treeViewer.setRootNode(rootNode);
      treeViewer.setLinkStyleClass(linkStyleClass);
      treeViewer.setIwTreeId(iwTreeId);
      treeViewer.setRendererType(rendererType);
      treeViewer.setFacetName(facetName);
      treeViewer.setVarName(varName);
      treeViewer.setSourceTree(sourceTree);
      treeViewer.setShowRootNode(showRootNode);
      treeViewer.setShowLines(showLines);
      treeViewer.setAddStyleClassForLink(addStyleClassForLink);
    }
  }
  @SuppressWarnings("unchecked")
  public List<String> getEmails(List<? extends Entry> entries, String commentAuthorEmail) {
    if (entries == null) {
      return null;
    }

    if (commentAuthorEmail == null) {
      commentAuthorEmail = CoreConstants.EMPTY;
    }

    List<String> emails = new ArrayList<String>();
    List<Person> authors = null;
    String email = null;
    for (Entry entry : entries) {
      authors = entry.getAuthors();
      if (authors != null) {
        for (Person author : authors) {
          email = author.getEmail();
          if (email != null) {
            email = CoreUtil.getDecodedValue(email);
            if (!email.equals(commentAuthorEmail) && !emails.contains(email)) {
              emails.add(email);
            }
          }
        }
      }
    }

    return emails;
  }
Ejemplo n.º 3
0
  protected Locale getCurrentLocale() {
    IWContext iwc = CoreUtil.getIWContext();
    Locale locale = iwc == null ? null : iwc.getCurrentLocale();

    if (locale == null) {
      locale = IWMainApplication.getDefaultIWMainApplication().getDefaultLocale();
    }

    return locale == null ? Locale.ENGLISH : locale;
  }
Ejemplo n.º 4
0
  protected String getHost() {
    ICDomain domain = null;
    IWContext iwc = CoreUtil.getIWContext();
    if (iwc == null) {
      domain = IWMainApplication.getDefaultIWApplicationContext().getDomain();
    } else domain = iwc.getDomain();

    int port = domain.getServerPort();
    String host = domain.getServerProtocol().concat("://").concat(domain.getServerName());
    if (port > 0) host = host.concat(":").concat(String.valueOf(port));
    return host;
  }
Ejemplo n.º 5
0
 private UserBusiness getUserBusiness() {
   try {
     if (userBusiness == null) {
       this.userBusiness =
           IBOLookup.getServiceInstance(
               iwc == null ? CoreUtil.getIWContext() : iwc, UserBusiness.class);
     }
   } catch (IBOLookupException e) {
     Logger.getLogger("ContentShareComponent")
         .log(Level.WARNING, "Failed getting UserBusiness", e);
   }
   return userBusiness;
 }
Ejemplo n.º 6
0
  protected User getCurrentUser() {
    User user = null;
    try {
      LoginSession loginSession = ELUtil.getInstance().getBean(LoginSession.class);
      user = loginSession.getUser();
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Error getting current user");
    }

    if (user == null) {
      IWContext iwc = CoreUtil.getIWContext();
      user = iwc == null ? null : iwc.isLoggedOn() ? iwc.getCurrentUser() : null;
    }

    return user;
  }
Ejemplo n.º 7
0
  protected IWResourceBundle getResourceBundle(IWBundle bundle) {
    Locale locale = getCurrentLocale();
    IWContext iwc = null;
    if (locale == null) {
      iwc = CoreUtil.getIWContext();
    }

    if (locale == null && iwc == null) {
      locale = Locale.ENGLISH;
      LOGGER.warning(
          "Will use default locale ("
              + locale
              + ") for resource bundle, because was unable to resolve both - IWContext and current locale");
    }

    return locale == null ? bundle.getResourceBundle(iwc) : bundle.getResourceBundle(locale);
  }
  public void saveCategoriesSettings() {
    if (this.resourcePath == null) {
      throw new RuntimeException("resourcePath is null");
    }

    IWContext iwc = CoreUtil.getIWContext();

    //	Save the selection of categories to the article
    String categories = getEnabledCategories(iwc);

    try {
      WebDAVMetadataResource resource =
          (WebDAVMetadataResource) IBOLookup.getSessionInstance(iwc, WebDAVMetadataResource.class);
      resource.setCategories(resourcePath, categories.toString(), getSetCategoriesOnParent());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 9
0
  protected HttpSession getSession() {
    RequestResponseProvider provider = null;
    try {
      provider = ELUtil.getInstance().getBean(RequestResponseProvider.class);
    } catch (Exception e) {
    }

    HttpSession session = null;
    if (provider != null && provider.getRequest() != null)
      session = provider.getRequest().getSession(Boolean.TRUE);

    if (session == null) {
      IWContext iwc = CoreUtil.getIWContext();
      if (iwc != null) session = iwc.getSession();
    }

    return session;
  }
Ejemplo n.º 10
0
  public PresentationObject getChooser(IWContext iwc, IWBundle bundle) {
    if (useOldLogic) { //	Old chooser
      Table table = new Table(2, 1);
      table.setCellpadding(0);
      table.setCellspacing(0);

      Parameter value = new Parameter(getChooserParameter(), "");
      if (this._stringValue != null) {
        value.setValue(this._stringValue);
      }
      table.add(value);

      PresentationObject object = getPresentationObject(iwc);

      table.add(new Parameter(VALUE_PARAMETER_NAME, value.getName()));
      // GenericButton button = new
      // GenericButton("chooserbutton",bundle.getResourceBundle(iwc).getLocalizedString(chooserText,"Choose"));
      if (this._addForm) {
        SubmitButton button = new SubmitButton(this._iwrb.getLocalizedString("choose", "Choose"));
        table.add(button, 2, 1);
        this._form.addParameter(CHOOSER_SELECTION_PARAMETER, getChooserParameter());
        this._form.addParameter(
            FORM_ID_PARAMETER,
            "window.opener.document.getElementById(\"" + this._form.getID() + "\").");
        this._form.addParameter(SCRIPT_SUFFIX_PARAMETER, "value");
        if (this.filter != null) {
          if (this.filter.length() > 0) {
            this._form.addParameter(FILTER_PARAMETER, this.filter);
          }
        }
        addParametersToForm(this._form);
      } else {
        getLink(this._iwrb);

        if (getUsePublicWindowOpener()) {
          this.link.setPublicWindowToOpen(getChooserWindowClass());
        } else {
          this.link.setWindowToOpen(getChooserWindowClass());
        }
        this.link.addParameter(CHOOSER_SELECTION_PARAMETER, getChooserParameter());

        this.link.addParameter(FORM_ID_PARAMETER, getParentFormID());

        // TODO Make the javascript work for other objects than form elements,
        // e.g. a Link
        /*
         * if(object instanceof Layer){
         * link.addParameter(SCRIPT_SUFFIX_PARAMETER,"title"); }
         */
        this.link.addParameter(SCRIPT_SUFFIX_PARAMETER, "value");
        // }

        // this was object.getID() but the id could change if this object was kept in session but
        // the form changed
        // by using getName() the reference is not lost, however we might need to add extra steps
        // for handling more than one
        // chooser of the same type in the same form.
        this.link.addParameter(DISPLAYSTRING_PARAMETER_NAME, object.getName());
        this.link.addParameter(VALUE_PARAMETER_NAME, value.getName());
        if (this._attributeName != null && this._attributeValue != null) {
          this.link.addParameter(this._attributeName, this._attributeValue);
        }
        if (this.filter != null) {
          if (this.filter.length() > 0) {
            this.link.addParameter(FILTER_PARAMETER, this.filter);
          }
        }

        addParametersToLink(this.link);

        table.add(this.link, 2, 1);
      }

      table.add(object, 1, 1);
      table.add(new Parameter(DISPLAYSTRING_PARAMETER_NAME, "151324213"));
      return (table);
    } else { //	New chooser
      Layer container = new Layer();

      String chooserObject = getChooserHelperVarName();
      if (chooserObject == null) {
        chooserObject = AbstractChooserBlock.GLOBAL_HELPER_NAME;
      } else {
        add(
            PresentationUtil.getJavaScriptAction(
                PresentationUtil.getJavaScriptLinesLoadedLazily(
                    CoreUtil.getResourcesForChooser(iwc),
                    new StringBuilder("if (!")
                        .append(chooserObject)
                        .append(") var ")
                        .append(chooserObject)
                        .append(" = new ChooserHelper();")
                        .toString())));
      }

      PresentationObject object = getPresentationObject(iwc);
      container.add(object);

      Image chooser = getChooser(bundle);
      chooser.setStyleClass("chooserStyle");

      chooser.setMarkupAttribute("choosername", chooserObject);

      //	OnClick action
      StringBuffer action =
          new StringBuffer("addChooserObject('").append(chooser.getId()).append("', '");
      action.append(getChooserWindowClass().getName());
      if (getHiddenInputAttribute() == null) {
        action.append("', null, '");
      } else {
        action.append("', '").append(getHiddenInputAttribute()).append("', '");
      }
      action.append(ICBuilderConstants.CHOOSER_VALUE_VIEWER_ID_ATTRIBUTE).append("', '");
      action
          .append(getResourceBundle().getLocalizedString("loading", "Loading..."))
          .append("', ")
          .append(
              _stringValue == null
                  ? "null"
                  : new StringBuilder("'").append(_stringValue).append("'").toString())
          .append(", ")
          .append(
              _stringDisplay == null
                  ? "null"
                  : new StringBuilder("'").append(_stringDisplay).append("'").toString())
          .append(");");
      chooser.setOnClick(action.toString());

      container.add(chooser);

      return container;
    }
  }
  private IWContext getIwc() {
    if (iwc == null) iwc = CoreUtil.getIWContext();

    return iwc;
  }