コード例 #1
0
  public HashMap<String, String> getFormValues(String language) {
    HashMap<String, String> formValues = new HashMap<String, String>();
    if ("0".equals(getInfoId())) {
      // this publication does not use a form
      return formValues;
    }

    DataRecord data = null;
    PublicationTemplate pub = null;
    try {
      pub =
          PublicationTemplateManager.getInstance()
              .getPublicationTemplate(getPK().getInstanceId() + ":" + getInfoId());
      data = pub.getRecordSet().getRecord(pk.getId());
    } catch (Exception e) {
      SilverTrace.warn(
          "publication",
          "PublicationDetail.getFormValues",
          "CANT_GET_FORM_RECORD",
          "pubId = " + getPK().getId() + "infoId = " + getInfoId());
    }

    if (data == null) {
      return formValues;
    }

    String fieldNames[] = data.getFieldNames();
    PagesContext pageContext = new PagesContext();
    pageContext.setLanguage(language);
    for (String fieldName : fieldNames) {
      try {
        Field field = data.getField(fieldName);
        GenericFieldTemplate fieldTemplate =
            (GenericFieldTemplate) pub.getRecordTemplate().getFieldTemplate(fieldName);
        FieldDisplayer fieldDisplayer =
            TypeManager.getInstance().getDisplayer(fieldTemplate.getTypeName(), "simpletext");
        StringWriter sw = new StringWriter();
        PrintWriter out = new PrintWriter(sw);
        fieldDisplayer.display(out, field, fieldTemplate, pageContext);
        formValues.put(fieldName, sw.toString());
      } catch (Exception e) {
        SilverTrace.warn(
            "publication",
            "PublicationDetail.getFormValues",
            "CANT_GET_FIELD_VALUE",
            "pubId = " + getPK().getId() + "fieldName = " + fieldName,
            e);
      }
    }
    return formValues;
  }
 private PublicationTemplate getXMLTemplate() throws WebPagesException {
   try {
     PublicationTemplate pubTemplate =
         PublicationTemplateManager.getInstance()
             .getPublicationTemplate(getComponentId() + ":" + getUsedXMLTemplateShortname());
     return pubTemplate;
   } catch (PublicationTemplateException e) {
     throw new WebPagesException(
         "WebPagesSessionController.getXMLTemplate()",
         SilverpeasException.ERROR,
         "webPages.EX_CANT_GET_TEMPLATE",
         e);
   }
 }
コード例 #3
0
  private void createIndex_Resource(ResourceDetail resource) {
    SilverTrace.info(
        "resourceManager",
        "resourceManagerBmEJB.createIndex_Resource()",
        "root.MSG_GEN_ENTER_METHOD",
        "resource = " + resource.toString());
    FullIndexEntry indexEntry = null;

    if (resource != null) {
      // Index the Reservation
      indexEntry = new FullIndexEntry(resource.getInstanceId(), "Resource", resource.getId());
      indexEntry.setTitle(resource.getName());
      indexEntry.setPreView(resource.getDescription());
      if (resource.getUpdateDate() != null) indexEntry.setCreationDate(resource.getUpdateDate());
      else indexEntry.setCreationDate(resource.getCreationDate());
      indexEntry.setCreationUser(resource.getCreaterId());

      String categoryId = resource.getCategoryId();
      if (StringUtil.isDefined(categoryId)) {
        CategoryDetail category = getCategory(categoryId);
        if (category != null) {
          String xmlFormName = category.getForm();
          if (StringUtil.isDefined(xmlFormName)) {
            // indéxation du contenu du formulaire XML
            String xmlFormShortName =
                xmlFormName.substring(xmlFormName.indexOf("/") + 1, xmlFormName.indexOf("."));
            PublicationTemplate pubTemplate;
            try {
              pubTemplate =
                  PublicationTemplateManager.getInstance()
                      .getPublicationTemplate(resource.getInstanceId() + ":" + xmlFormShortName);
              RecordSet set = pubTemplate.getRecordSet();
              set.indexRecord(resource.getId(), xmlFormName, indexEntry);
            } catch (Exception e) {
              throw new ResourcesManagerRuntimeException(
                  "ResourceManagerBmEJB.createIndex_Resource()",
                  SilverpeasRuntimeException.ERROR,
                  "resourcesManager.EX_CREATE_INDEX_FAILED",
                  e);
            }
          }
        }
      }

      IndexEngineProxy.addIndexEntry(indexEntry);
    }
  }
  /**
   * Standard Session Controller Constructeur
   *
   * @param mainSessionCtrl The user's profile
   * @param componentContext The component's profile
   * @see
   */
  public WebPagesSessionController(
      MainSessionController mainSessionCtrl, ComponentContext componentContext) {
    super(
        mainSessionCtrl,
        componentContext,
        "com.silverpeas.webpages.multilang.webPagesBundle",
        "com.silverpeas.webpages.settings.webPagesIcons");

    if (isXMLTemplateUsed()) {
      // register xmlForm to component
      try {
        PublicationTemplateManager.getInstance()
            .addDynamicPublicationTemplate(
                getComponentId() + ":" + getUsedXMLTemplateShortname(), getUsedXMLTemplate());
      } catch (PublicationTemplateException e) {
        SilverTrace.error(
            "webPages", "WebPagesSessionController()", "", "template = " + getUsedXMLTemplate(), e);
      }
    }
  }