Topic
No replies
SystemAdmin
SystemAdmin
1731 Posts
ACCEPTED ANSWER

Pinned topic There is no item type relation defined for the document being created.

‏2012-10-17T04:33:56Z |
When I try to create item I get the exception com.ibm.mm.beans.CMBException: ICM7097: There is no item type relation defined for the document being created. (STATE) : LS RC = 7097

CMBEntity entityBean = schemaManagement.getEntity(entity); 

if (entityBean == 

null) 
{ 

throw 

new IllegalArgumentException(
"Entity not found: " + entity); 
} CMBItem item = 

new CMBItem();   

switch (entityBean.getClassification()) 
{ 

case (CMBBaseConstant.CMB_CLASS_UNDEFINED) : 

throw 

new IllegalArgumentException(
"Entity must be defined in CM v8"); 

case (CMBBaseConstant.CMB_CLASS_ITEM) : logger.debug(
"Warning. Entity is of type Item.  Content will not be stored."); 
//fall thru 

case (CMBBaseConstant.CMB_CLASS_RESOURCE_ITEM) : item.setItemType(CMBBaseConstant.CMB_TYPE_ITEM); 

break; 

default : 
//must be document item.setItemType(CMBBaseConstant.CMB_TYPE_DOCUMENT); 
} item.setConnection(dataManagement.getConnection()); item.setServerType(dataManagement.getConnection().getDsType()); item.setServerName(dataManagement.getConnection().getServerName()); item.setEntityName(entity); Set<String> set = attrNameVal.keySet(); Iterator<String> iterator = set.iterator(); 

while (iterator.hasNext()) 
{ String attrKey=(String)iterator.next(); String attrVal=(String)attrNameVal.get(attrKey); 
//System.out.println("Key="+attrKey); 
//System.out.println("Value="+attrVal); CM_CreateItem.setItemAttr(entityBean, item, attrKey, attrVal); 
} 
//Construct a CMBObject object for the content part CMBObject obj = 

new CMBObject(); obj.setMimeType(getMimeType(filename)); 
//Read the document data into the CMBObject logger.debug(
"Reading content file"); File file = 

new File(filename); FileInputStream fileStream = 

new FileInputStream(file); 

byte[] data = 

new 

byte[(

int)file.length()]; 

int dataread = 0; 

while (dataread < data.length) 
{ dataread += fileStream.read(data, dataread, data.length - dataread); 
} fileStream.close(); obj.setData(data); 

if (dataManagement.getConnection().getDsType().equals(
"ICM")) 
{ logger.debug(
"true.."); obj.setPartType(
"ICMBASE"); 
} obj.setOriginalFileName(
"TPD_COMMISSION"); 
//Add a content part to the item. dataManagement.setDataObject(item); dataManagement.addContent(obj); 
//Create the item (including the content part) on the server dataManagement.createItem(entity);