public String getFieldValue(String fieldNameAndLanguage) { SilverTrace.info( "publication", "PublicationDetail.getModelContent()", "root.MSG_GEN_ENTER_METHOD", "fieldNameAndLanguage = " + fieldNameAndLanguage); String[] params = fieldNameAndLanguage.split(","); String fieldName = params[0]; String language = null; if (params.length > 1) { language = params[1]; } String fieldValue = ""; List<XMLField> xmlFieldsForLanguage = getXmlFields(language); for (XMLField xmlField : xmlFieldsForLanguage) { if (fieldName.equals(xmlField.getName())) { fieldValue = getValueOfField(xmlField, language); } } SilverTrace.info( "publication", "PublicationDetail.getModelContent('" + fieldName + "')", "root.MSG_GEN_EXIT_METHOD", "fieldValue = " + fieldValue); return fieldValue; }
private String getValueOfField(XMLField xmlField, String language) { String fieldValue = xmlField.getValue(); if (fieldValue == null) { fieldValue = ""; } else { if (fieldValue.startsWith("image_") || fieldValue.startsWith("file_")) { String attachmentId = fieldValue.substring(fieldValue.indexOf("_") + 1, fieldValue.length()); if (StringUtil.isDefined(attachmentId)) { if (attachmentId.startsWith("/")) { // case of an image provided by a gallery fieldValue = attachmentId; } else { SimpleDocument attachment = AttachmentServiceFactory.getAttachmentService() .searchDocumentById( new SimpleDocumentPK(attachmentId, getPK().getInstanceId()), language); if (attachment != null) { fieldValue = attachment.getAttachmentURL(); } } } else { fieldValue = ""; } } else if (fieldValue.startsWith(WysiwygFCKFieldDisplayer.dbKey)) { fieldValue = WysiwygFCKFieldDisplayer.getContentFromFile( getPK().getInstanceId(), getPK().getId(), xmlField.getName(), language); } else { fieldValue = EncodeHelper.javaStringToHtmlParagraphe(fieldValue); } } return fieldValue; }