Syncs Managed Object.
		
		Method takes the difference object (output of CompareManagedObject) and applies the differences on reference Managed Object.
		- difference specifies the Difference object (output of ComparesManagedObject) which has differences of the properties of two or more Managed Objects.
		- deleteNotPresent, if set as True, any missing MOs in reference Managed Object set will be deleted.
		- noVersionFilter, If set as True, minversion for Mos or properties to be added in reference Managed Object will not be checked.

def SyncManagedObject(self, difference, deleteNotPresent=False, noVersionFilter=False, dumpXml=None):
		"""
		Syncs Managed Object.
		
		Method takes the difference object (output of CompareManagedObject) and applies the differences on reference Managed Object.
		- difference specifies the Difference object (output of ComparesManagedObject) which has differences of the properties of two or more Managed Objects.
		- deleteNotPresent, if set as True, any missing MOs in reference Managed Object set will be deleted.
		- noVersionFilter, If set as True, minversion for Mos or properties to be added in reference Managed Object will not be checked.
		"""
		from UcsBase import WriteUcsWarning, WriteObject, UcsUtils, ManagedObject, AbstractFilter, GenericMO, \
			SyncAction, UcsException, UcsValidationException
		from Ucs import ClassFactory, Pair, ConfigMap

		if ((difference == None) or (isinstance(difference, list) and (len(difference) == 0))):
			raise UcsValidationException("difference object parameter is not provided.")
		# raise Exception("[Error]: SyncManagedObject: Difference Object can not be Null")

		configMap = ConfigMap()

		configDoc = xml.dom.minidom.parse(UcsUtils.GetSyncMoConfigFilePath())

		moConfigMap = {}
		moConfigMap = UcsUtils.GetSyncMoConfig(configDoc)

		for moDiff in difference:
			mo = moDiff.InputObject
			classId = mo.classId
			gMoDiff = None
			metaClassId = UcsUtils.FindClassIdInMoMetaIgnoreCase(classId)
			if metaClassId == None:
				# TODO: Add Warning/Error messages in Logger.
				WriteUcsWarning("Ignoring [%s]. Unknown ClassId [%s]." % (moDiff.InputObject.getattr("Dn"), classId))
				continue

			moConfigs = []
			moConfig = None

			if UcsUtils.WordL(classId) in moConfigMap:
				moConfigs = moConfigMap[UcsUtils.WordL(classId)]

			if moConfigs:
				for conf in moConfigs:
					if (self._version.CompareTo(conf.getActionVersion()) == 0):
						moConfig = conf

			# Removes Difference Object.
			if ((moDiff.SideIndicator == UcsMoDiff.REMOVE) and (deleteNotPresent)):

				if (
										moConfig is not None and moConfig.getAction() == SyncAction.ignore and moConfig.getStatus() is not None and moConfig.getStatus().contains(
							Status.DELETED)):
					if (moConfig.getIgnoreReason() is None or len(moConfig.getIgnoreReason()) == 0):
						continue

					ir = moConfig.getIgnoreReason()
					try:
						for prop in ir:
							propValue = ir[prop]
							if mo.getattr(prop):
								attrValue = mo.getattr(prop)
							else:
								attrValue = None

							if (not propValue or not attrValue or propValue != attrValue):
								ignore = False
								break
					except Exception, err:
						ignore = False

					if ignore:
						continue

				gMoDiff = ManagedObject(classId)
				gMoDiff.setattr("Dn", mo.getattr("Dn"))
				gMoDiff.setattr("Status", Status().DELETED)
				gMoDiff = GenericMO(gMoDiff, WriteXmlOption.AllConfig)  # gMoDiff should be generic object

			if moDiff.SideIndicator == UcsMoDiff.ADD_MODIFY:
				gMoDiff = ManagedObject(classId)
				addExists = False
				moMeta = UcsUtils.IsPropertyInMetaIgnoreCase(classId, "Meta")

				if ((moMeta != None) and ('Add' in moMeta.verbs)):
					addExists = True

				# Add Difference Object.
				if ((addExists) and ((moDiff.DiffProperty == None) or (len(moDiff.DiffProperty) == 0))):
					if (
											moConfig is not None and moConfig.getAction() == SyncAction.ignore and moConfig.getStatus() is not None and moConfig.getStatus().contains(
								Status.CREATED)):
						if (moConfig.getIgnoreReason() is None or len(moConfig.getIgnoreReason()) == 0):
							continue
						ir = moConfig.getIgnoreReason()
						try:
							for prop in ir:
								propValue = ir[prop]
								if mo.getattr(prop):
									attrValue = mo.getattr(prop)
								else:
									attrValue = None

								if (not propValue or not attrValue or propValue != attrValue):
									ignore = False
									break
						except Exception, err:
							ignore = False

						if ignore:
							continue

					for prop in mo.__dict__:
						propMoMeta = UcsUtils.IsPropertyInMetaIgnoreCase(classId, prop)
						if (propMoMeta != None):
							if (
												prop.lower() == "rn" or prop.lower() == "dn" or propMoMeta.access == UcsPropertyMeta.ReadOnly):
								continue
							exclude = False
							if (moConfig is not None and moConfig.getExcludeList() is not None):
								for exProp in moConfig.getExcludeList():
									if prop.lower() == exProp.lower():
										exclude = True
							if not exclude:
								gMoDiff.setattr(propMoMeta.name, mo.getattr(prop))

					gMoDiff.setattr("Dn", mo.getattr("Dn"))

					if (moConfig is not None and moConfig.getAction() == SyncAction.statusChange):
						gMoDiff.setattr("Status", moConfig.getStatus())
					else:
						gMoDiff.setattr("Status", Status().CREATED)

					gMoDiff = GenericMO(gMoDiff, WriteXmlOption.AllConfig)  # gMoDiff should be generic object
					if (not noVersionFilter):
						hReference = mo.GetHandle()
						if ((hReference != None) and (hReference._version != None)):
							gMoDiff.FilterVersion(hReference._version)

				# Modify the Managed Object
				else:

					if (
											moConfig is not None and moConfig.getAction() == SyncAction.ignore and moConfig.getStatus() is not None and moConfig.getStatus().contains(
								Status.DELETED)):
						if (moConfig.getIgnoreReason() is None or len(moConfig.getIgnoreReason()) == 0):
							continue

						ir = moConfig.getIgnoreReason()
						try:
							for prop in ir:
								propValue = ir[prop]
								if mo.getattr(prop):
									attrValue = mo.getattr(prop)
								else:
									attrValue = None

								if (not propValue or not attrValue or propValue != attrValue):
									ignore = False
									break
						except Exception, err:
							ignore = False

						if ignore:
							continue

					if ((moDiff.DiffProperty == None) or (len(moDiff.DiffProperty) == 0)):
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning('Add not supported for classId ' + classId + '. Reverting to modify.')
						continue

					finalDiffPropStr = None
					finalDiffProps = moDiff.DiffProperty
					gMoDiff = ManagedObject(classId)
					for diffprop in finalDiffProps:
						exclude = False
						if (moConfig is not None and moConfig.getExcludeList() is not None):
							for exProp in moConfig.getExcludeList():
								if diffprop.lower() == exProp.lower():
									exclude = True
						if not exclude:
							finalDiffPropStr = finalDiffPropStr + ","

					for prop in finalDiffProps:
						propMoMeta = UcsUtils.IsPropertyInMetaIgnoreCase(classId, prop)
						if (propMoMeta != None):
							if (
												prop.lower() == "rn" or prop.lower() == "dn" or propMoMeta.access == UcsPropertyMeta.ReadOnly):
								continue
							exclude = False
							if (moConfig is not None and moConfig.getExcludeList() is not None):
								for exProp in moConfig.getExcludeList():
									if diffprop.lower() == exProp.lower():
										exclude = True
							if not exclude:
								gMoDiff.setattr(propMoMeta.name, mo.getattr(prop))

					gMoDiff.setattr("Dn", mo.getattr("Dn"))
					gMoDiff.setattr("Status", Status().MODIFIED)

					gMoDiff = GenericMO(gMoDiff,
										WriteXmlOption.AllConfig)  # gMoDiff should be generic object to apply FilterVersion on it.

			# TODO: NoversionFilter functionality discussion.
			if ((gMoDiff != None) and (not noVersionFilter)):
				gMoMeta = UcsUtils.GetUcsPropertyMeta(gMoDiff.classId, "Meta")
				if ((gMoMeta != None) and (self._version != None)):
					if self._version < gMoMeta.version:
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning(
							'Ignoring unsupported classId %s for Dn %s.' % (gMoDiff.classId, gMoDiff.getattr("Dn")))
						gMoDiff = None

					if ((gMoDiff != None) and (self._version != None)):
						gMoDiff.FilterVersion(self._version)

			if (gMoDiff != None):
				if gMoDiff.__dict__.has_key("_excludePropList"):
					for prop in gMoDiff.__dict__["_excludePropList"]:
						if prop == "XtraProperty":
							gMoDiff.__dict__[prop] = {}
							continue
						gMoDiff.__dict__[prop] = None

			if (gMoDiff != None):
				pair = Pair()
				pair.setattr("Key", gMoDiff.getattr("Dn"))
				pair.AddChild(gMoDiff)
				configMap.AddChild(pair)

		if configMap.GetChildCount() == 0:
			return None

		ccm = self.ConfigConfMos(configMap, False, dumpXml)
		if ccm.errorCode == 0:
			moList = []
			for child in ccm.OutConfigs.GetChild():
				if (isinstance(child, Pair) == True):
					for mo in child.GetChild():
						moList.append(mo)
				elif (isinstance(child, ManagedObject) == True):
					moList.append(child)
			# WriteObject(moList)
			return moList
		else:
			raise UcsException(ccm.errorCode, ccm.errorDescr)