Program: 89363
Project: 89363
Buggy source:
/** 
 * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName,org.alfresco.service.namespace.QName,java.lang.String,org.alfresco.service.namespace.QName,java.lang.String,java.lang.String,java.lang.String,boolean,boolean,boolean,org.alfresco.service.namespace.QName)
 */
public QName addCustomPropertyDefinition(QName propId,QName aspectName,String label,QName dataType,String title,String description,String defaultValue,boolean multiValued,boolean mandatory,boolean isProtected,QName lovConstraint) throws CustomMetadataException {
  if (isCustomisable(aspectName) == false) {
    throw new NotCustomisableMetadataException(aspectName.toPrefixString(namespaceService));
  }
  if (propId == null) {
    propId=this.generateQNameFor(label);
  }
  ParameterCheck.mandatory("String_Node_Str",aspectName);
  ParameterCheck.mandatory("String_Node_Str",label);
  ParameterCheck.mandatory("String_Node_Str",dataType);
  NodeRef modelRef=getCustomModelRef(propId.getNamespaceURI());
  M2Model deserializedModel=readCustomContentModel(modelRef);
  QName customAspect=getCustomAspect(aspectName);
  M2Aspect customPropsAspect=deserializedModel.getAspect(customAspect.toPrefixString(namespaceService));
  if (customPropsAspect == null) {
    throw new InvalidCustomAspectMetadataException(customAspect,aspectName.toPrefixString(namespaceService));
  }
  String propIdAsString=propId.toPrefixString(namespaceService);
  M2Property customProp=customPropsAspect.getProperty(propIdAsString);
  if (customProp != null) {
    throw new PropertyAlreadyExistsMetadataException(propIdAsString);
  }
  M2Property newProp=customPropsAspect.createProperty(propIdAsString);
  newProp.setName(propIdAsString);
  newProp.setType(dataType.toPrefixString(namespaceService));
  newProp.setTitle(label);
  newProp.setDescription(description);
  newProp.setDefaultValue(defaultValue);
  newProp.setMandatory(mandatory);
  newProp.setProtected(isProtected);
  newProp.setMultiValued(multiValued);
  newProp.setIndexed(true);
  newProp.setIndexedAtomically(true);
  newProp.setStoredInIndex(false);
  newProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE);
  if (lovConstraint != null) {
    if (!dataType.equals(DataTypeDefinition.TEXT)) {
      throw new CannotApplyConstraintMetadataException(lovConstraint,propIdAsString,dataType);
    }
    String lovConstraintQNameAsString=lovConstraint.toPrefixString(namespaceService);
    newProp.addConstraintRef(lovConstraintQNameAsString);
  }
  writeCustomContentModel(modelRef,deserializedModel);
  if (logger.isInfoEnabled()) {
    logger.info("String_Node_Str" + label + "String_Node_Str"+ propIdAsString+ "String_Node_Str"+ aspectName);
  }
  return propId;
}

Fixed version (ground truth):
/** 
 * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName,org.alfresco.service.namespace.QName,java.lang.String,org.alfresco.service.namespace.QName,java.lang.String,java.lang.String,java.lang.String,boolean,boolean,boolean,org.alfresco.service.namespace.QName)
 */
public QName addCustomPropertyDefinition(QName propId,QName aspectName,String label,QName dataType,String title,String description,String defaultValue,boolean multiValued,boolean mandatory,boolean isProtected,QName lovConstraint) throws CustomMetadataException {
  if (!isCustomisable(aspectName)) {
    throw new NotCustomisableMetadataException(aspectName.toPrefixString(namespaceService));
  }
  if (propId == null) {
    propId=this.generateQNameFor(label);
  }
  ParameterCheck.mandatory("String_Node_Str",aspectName);
  ParameterCheck.mandatory("String_Node_Str",label);
  ParameterCheck.mandatory("String_Node_Str",dataType);
  NodeRef modelRef=getCustomModelRef(propId.getNamespaceURI());
  M2Model deserializedModel=readCustomContentModel(modelRef);
  QName customAspect=getCustomAspect(aspectName);
  M2Aspect customPropsAspect=deserializedModel.getAspect(customAspect.toPrefixString(namespaceService));
  if (customPropsAspect == null) {
    throw new InvalidCustomAspectMetadataException(customAspect,aspectName.toPrefixString(namespaceService));
  }
  String propIdAsString=propId.toPrefixString(namespaceService);
  M2Property customProp=customPropsAspect.getProperty(propIdAsString);
  if (customProp != null) {
    throw new PropertyAlreadyExistsMetadataException(propIdAsString);
  }
  M2Property newProp=customPropsAspect.createProperty(propIdAsString);
  newProp.setName(propIdAsString);
  newProp.setType(dataType.toPrefixString(namespaceService));
  newProp.setTitle(label);
  newProp.setDescription(description);
  newProp.setDefaultValue(defaultValue);
  newProp.setMandatory(mandatory);
  newProp.setProtected(isProtected);
  newProp.setMultiValued(multiValued);
  newProp.setIndexed(true);
  newProp.setIndexedAtomically(true);
  newProp.setStoredInIndex(false);
  newProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE);
  if (lovConstraint != null) {
    if (!dataType.equals(DataTypeDefinition.TEXT)) {
      throw new CannotApplyConstraintMetadataException(lovConstraint,propIdAsString,dataType);
    }
    String lovConstraintQNameAsString=lovConstraint.toPrefixString(namespaceService);
    newProp.addConstraintRef(lovConstraintQNameAsString);
  }
  writeCustomContentModel(modelRef,deserializedModel);
  if (logger.isInfoEnabled()) {
    logger.info("String_Node_Str" + label + "String_Node_Str"+ propIdAsString+ "String_Node_Str"+ aspectName);
  }
  return propId;
}