private void Replace(ImportSyncAction action, ImportContentSession session) { // update the identifier on the item in the local instance // then let the import continue so the existing item gets paved over if (action.Action == "Replace" && !string.IsNullOrWhiteSpace(action.TargetId)) { var item = session.Get(action.TargetId); if (item == null) { return; } var newIdentifier = action.Step.Step.Attribute("Id"); if (newIdentifier == null) return; var newIdentity = new ContentIdentity(newIdentifier.Value); var existingIdentity = new ContentIdentity(action.TargetId); if (!newIdentity.Equals(existingIdentity)) { Logger.Debug("import - items {0} and {1} have different identifiers", existingIdentity.Get("Identifier"), newIdentity.Get("Identifier")); item.As<IdentityPart>().Identifier = newIdentity.Get("Identifier"); session.Store(newIdentity.Get("Identifier"), item); } } }
private bool LocalIdentifierExists(ImportSyncAction identifier, ImportContentSession importContentSession) { var newIdentifier = identifier.Step.Step.Attribute("Id"); if (newIdentifier == null) return false; var contentItem = importContentSession.Get(newIdentifier.Value); if (contentItem == null) return false; return true; }
private void ImportItem(ImportSyncAction action, ImportContentSession session) { _contentManager.Import(action.Step.Step, session); }