Skip to content

Commit

Permalink
Fix #542 Exception in the log files when C1 tries to unpublish a data…
Browse files Browse the repository at this point in the history
… item that has been previously deleted
  • Loading branch information
napernik committed Mar 1, 2018
1 parent df90bc6 commit 81e385f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ protected override void Execute()
var publishSchedule = PublishScheduleHelper.GetPublishSchedule(type, DataId, LocaleName);
DataFacade.Delete(publishSchedule);

var data = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
Verify.IsNotNull(data, "The data with the id '{0}' does not exist", DataId);
var data = (IPublishControlled)DataFacade.TryGetDataByUniqueKey(type, DataId);
if (data == null)
{
Log.LogWarning(LogTitle, $"Failed to find data of type '{type}' by id '{DataId}'.");

transaction.Complete();
return;
}

dataEntityToken = data.GetDataEntityToken();

Expand All @@ -49,11 +55,11 @@ protected override void Execute()

DataFacade.Update(data);

Log.LogVerbose(LogTitle, "Scheduled publishing of data with label '{0}' is complete", data.GetLabel());
Log.LogVerbose(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' is complete");
}
else
{
Log.LogWarning(LogTitle, "Scheduled publishing of data with label '{0}' could not be done because the data is not in a publisheble state", data.GetLabel());
Log.LogWarning(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' could not be done because the data is not in a publisheble state");
}

transaction.Complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ protected override void Execute()

DataFacade.Delete(unpublishSchedule);

var deletePublished = false;
var data = (IPublishControlled)DataFacade.TryGetDataByUniqueKey(type, DataId);
if (data == null)
{
Log.LogWarning(LogTitle, $"Failed to find data of type '{type}' by id '{DataId}'.");

var data = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
Verify.IsNotNull(data, "The data with the id {0} does not exist", DataId);
transaction.Complete();
return;
}

var deletePublished = false;

dataEntityToken = data.GetDataEntityToken();

Expand All @@ -56,7 +62,7 @@ protected override void Execute()
}
else
{
Log.LogWarning(LogTitle, "Scheduled unpublishing of data with label '{0}' could not be done because the data is not in a unpublisheble state", data.GetLabel());
Log.LogWarning(LogTitle, $"Scheduled unpublishing of data with label '{data.GetLabel()}' could not be done because the data is not in a unpublisheble state");
}


Expand All @@ -69,7 +75,7 @@ protected override void Execute()
{
DataFacade.Delete(deletedData, CascadeDeleteType.Disable);

Log.LogVerbose(LogTitle, "Scheduled unpublishing of data with label '{0}' is complete", deletedData.GetLabel());
Log.LogVerbose(LogTitle, $"Scheduled unpublishing of data with label '{deletedData.GetLabel()}' is complete");
}
}
}
Expand Down

0 comments on commit 81e385f

Please sign in to comment.