Hi,<br>
I am traying to create resources programatically, it works fine but I
do not know how to do it for nested content nor for attachments. Can
anyone help me??<br>
<br>
This is my code:<br>
<br>
public boolean createResource(int type, String shema, String path, HashMap simpleData, HashMap nestedData)<br>
{<br>
boolean success = false;<br>
CmsObject cmsObject = cmsJspActionElement.getCmsObject();<br>
boolean exists = cmsObject.existsResource(path);<br>
if(!exists) <br>
{<br>
//Crear carpeta con nombre de usuario y meter ahí el contenido<br>
String resource = path + "/" + name;<br>
//out.println(mfolder);<br>
<br>
//CmsXmlContentDefinition getContentDefinition();!!!!!!!!!<br>
//CmsXmlNestedContentDefinition<br>
try <br>
{ <br>
CmsXmlContentDefinition def =
CmsXmlContentDefinition.unmarshal(schema,new
CmsXmlEntityResolver(cmsObject)); <br>
CmsXmlContent content =
CmsXmlContentFactory.createDocument(cmsObject,
cmsJspActionElement.getRequestContext().getLocale(), "UTF-8",def);<br>
<br>
Locale localizacion = cmsJspActionElement.getRequestContext().getLocale();<br>
I_CmsXmlContentValue contentValue = null;<br>
getIncludes();<br>
Set keys = simpleData.keySet();<br>
Iteartor itKeys = keys.iterator();<br>
<br>
while (itKeys.hasNext())<br>
{<br>
String key = (String)itKeys.next();<br>
Object valor = simpleData.get(key);<br>
<br>
if (valor instanceof String[]) <br>
{<br>
//contentValue = content.getValue(key, localizacion );<br>
//int count = contentValue.getMaxIndex();<br>
String[] values = (String[]) valor;<br>
for (int i=0; i<values.length; i++)<br>
{<br>
if(i==0)<br>
{<br>
contentValue =content.getValue(key, localizacion);<br>
contentValue.setStringValue(cmsObject, values[0]);<br>
}<br>
else<br>
{<br>
contentValue =content.addValue(cmsObject, key, localizacion, i);<br>
contentValue.setStringValue(cmsObject, values[i]);<br>
<br>
}<br>
}<br>
} <br>
else<br>
{<br>
contentValue = content.getValue(key, localizacion );<br>
contentValue.setStringValue(cmsObject, (String)valor);<br>
}<br>
}<br>
<br>
keys = nestedData.keySet();<br>
itKeys = keys.iterator(); <br>
<br>
while(itKeys.hasNext())<br>
{<br>
String key = (String)itKeys.next();<br>
String[] valor = simpleData.get(key);<br>
CmsXmlContentValueSequence nestedSequence = content.getValueSequence(key, localizacion);<br>
int count = nestedSequence.getElementCount();<br>
for (int i=0; valor.length; i++)<br>
{<br>
I_CmsXmlContentValue newValue = nestedSequence.addValue(cmsObject, i); <br>
newValue.setStringValue(cmsObject, "assad");<br>
}<br>
<br>
}<br>
<br>
<br>
<br>
byte[] byteContent= content.marshal(); <br>
cmsObject.createResource(path, type, byteContent, new ArrayList(););<br>
cmsObject.unlockResource(path);<br>
success=true;<br>
}<br>
catch(Exception exc)<br>
{<br>
exc.printStackTrace();<br>
success=false;<br>
}<br>
}<br>
return success;<br>
}<br>