public Form getUpdateForm() throws WebPagesException { try { PublicationTemplate pubTemplate = getXMLTemplate(); return pubTemplate.getUpdateForm(); } catch (PublicationTemplateException e) { throw new WebPagesException( "WebPagesSessionController.getUpdateForm()", SilverpeasException.ERROR, "webPages.EX_CANT_GET_UPDATEFORM", e); } }
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; }
public boolean isXMLContentDefined() throws WebPagesException { DataRecord data; try { PublicationTemplate pubTemplate = getXMLTemplate(); RecordSet recordSet = pubTemplate.getRecordSet(); data = recordSet.getRecord("0", getLanguage()); return data != null; } catch (Exception e) { throw new WebPagesException( "WebPagesSessionController.isXMLContentDefined()", SilverpeasException.ERROR, "webPages.EX_CANT_GET_DATA", e); } }
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); } }
public DataRecord getDataRecord() throws WebPagesException { try { PublicationTemplate pubTemplate = getXMLTemplate(); RecordSet recordSet = pubTemplate.getRecordSet(); DataRecord data = recordSet.getRecord("0", getLanguage()); if (data == null) { data = recordSet.getEmptyRecord(); data.setId("0"); data.setLanguage(getLanguage()); } return data; } catch (Exception e) { throw new WebPagesException( "WebPagesSessionController.getDataRecord()", SilverpeasException.ERROR, "webPages.EX_CANT_GET_DATA", e); } }
private void indexForm(RecordSet recordSet) throws WebPagesException { try { if (recordSet == null) { PublicationTemplate pub = getXMLTemplate(); recordSet = pub.getRecordSet(); } } catch (Exception e) { throw new WebPagesException( "WebPagesSessionController.indexForm()", SilverpeasException.ERROR, "webPages.EX_CANT_GET_FORM", e); } // index data try { FullIndexEntry indexEntry = new FullIndexEntry(getComponentId(), "Component", getComponentId()); indexEntry.setCreationDate(new Date()); indexEntry.setCreationUser(getUserId()); indexEntry.setTitle(getComponentLabel()); ComponentInstLight component = getOrganizationController().getComponentInstLight(getComponentId()); if (component != null) { indexEntry.setPreView(component.getDescription()); } recordSet.indexRecord("0", getUsedXMLTemplateShortname(), indexEntry); IndexEngineProxy.addIndexEntry(indexEntry); } catch (FormException e) { throw new WebPagesException( "WebPagesSessionController.indexForm()", SilverpeasException.ERROR, "webPages.EX_CANT_INDEX_DATA", e); } }
public void saveDataRecord(List<FileItem> items) throws WebPagesException { // save data in database RecordSet set; try { PublicationTemplate pub = getXMLTemplate(); set = pub.getRecordSet(); Form form = pub.getUpdateForm(); DataRecord data = set.getRecord("0", getLanguage()); if (data == null) { data = set.getEmptyRecord(); data.setId("0"); data.setLanguage(getLanguage()); } PagesContext context = new PagesContext("useless", "0", getLanguage(), false, getComponentId(), getUserId()); context.setEncoding("UTF-8"); context.setObjectId("0"); context.setContentLanguage(getLanguage()); form.update(items, data, context); set.save(data); } catch (Exception e) { throw new WebPagesException( "WebPagesSessionController.saveDataRecord()", SilverpeasException.ERROR, "webPages.EX_CANT_SAVE_DATA", e); } // send subscriptions getNotifier().sendSubscriptionsNotification(getNodePK(), getUserId()); // index updated data indexForm(set); }