Skip to content
Snippets Groups Projects
Commit e00a3dce authored by gakin's avatar gakin
Browse files

SSDM-4903 Black-listed data sets should be skipped even if they are modified since last sync

SVN: 38195
parent c6864819
No related branches found
No related tags found
No related merge requests found
...@@ -336,7 +336,6 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I ...@@ -336,7 +336,6 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
private Set<String> getBlackListedDataSetCodes(String fileName) private Set<String> getBlackListedDataSetCodes(String fileName)
{ {
return getDataSetCodeLines(fileName, "#DATA_SET"); return getDataSetCodeLines(fileName, "#DATA_SET");
} }
private void sendErrorEmail(SyncConfig config, String subject) private void sendErrorEmail(SyncConfig config, String subject)
......
...@@ -265,7 +265,7 @@ public class EntitySynchronizer ...@@ -265,7 +265,7 @@ public class EntitySynchronizer
// Note that container/component and parent/child relationships are established post-reg. // Note that container/component and parent/child relationships are established post-reg.
// setParentDataSetsOnTheChildren(data); // setParentDataSetsOnTheChildren(data);
Map<String, IncomingDataSet> physicalDSMap = Map<String, IncomingDataSet> physicalDSMap =
data.filterPhysicalDataSetsByLastModificationDate(lastSyncTimestamp, dataSetsCodesToRetry); data.filterPhysicalDataSetsByLastModificationDate(lastSyncTimestamp, dataSetsCodesToRetry, blackListedDataSetCodes);
operationLog.info("\n"); operationLog.info("\n");
operationLog.info("Registering data sets..."); operationLog.info("Registering data sets...");
...@@ -287,14 +287,19 @@ public class EntitySynchronizer ...@@ -287,14 +287,19 @@ public class EntitySynchronizer
+ dsRegistrationSummary.updatedDsCount + dsRegistrationSummary.updatedDsCount
+ " data set(s) were updated.\n" + " data set(s) were updated.\n"
+ notRegisteredDataSetCodes.size() + notRegisteredDataSetCodes.size()
+ " data set(s) FAILED to register "); + " data set(s) FAILED to register.\n"
+ blackListedDataSetCodes.size() + " data set(s)"
+ " were skipped because they were BLACK-LISTED.");
} }
// link physical data sets registered above to container data sets // link physical data sets registered above to container data sets
// and set parent/child relationships // and set parent/child relationships
operationLog.info("\n"); operationLog.info("\n");
operationLog.info("Start establishing data set hierarchies..."); operationLog.info("Start establishing data set hierarchies...");
establishDataSetRelationships(data.getDataSetsToProcess(), notRegisteredDataSetCodes, physicalDSMap); List<String> skippedDataSets = new ArrayList<String>();
skippedDataSets.addAll(notRegisteredDataSetCodes);
skippedDataSets.addAll(blackListedDataSetCodes);
establishDataSetRelationships(data.getDataSetsToProcess(), skippedDataSets, physicalDSMap);
// cleanup(); // cleanup();
...@@ -470,7 +475,7 @@ public class EntitySynchronizer ...@@ -470,7 +475,7 @@ public class EntitySynchronizer
// } // }
private void establishDataSetRelationships(Map<String, IncomingDataSet> dataSetsToProcess, private void establishDataSetRelationships(Map<String, IncomingDataSet> dataSetsToProcess,
List<String> notRegisteredDataSets, Map<String, IncomingDataSet> physicalDSMap) List<String> skippedDataSets, Map<String, IncomingDataSet> physicalDSMap)
{ {
// set parent and container data set codes before everything else // set parent and container data set codes before everything else
// container and physical data sets can both be parents/children of each other // container and physical data sets can both be parents/children of each other
...@@ -485,7 +490,7 @@ public class EntitySynchronizer ...@@ -485,7 +490,7 @@ public class EntitySynchronizer
NewExternalData dataSet = dsWithConn.getDataSet(); NewExternalData dataSet = dsWithConn.getDataSet();
if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Child")) if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Child"))
{ {
if (notRegisteredDataSets.contains(dataSet.getCode()) == false) if (skippedDataSets.contains(dataSet.getCode()) == false)
{ {
NewExternalData childDataSet = dataSetsToProcess.get(conn.getToPermId()).getDataSet(); NewExternalData childDataSet = dataSetsToProcess.get(conn.getToPermId()).getDataSet();
List<String> parentDataSetCodes = childDataSet.getParentDataSetCodes(); List<String> parentDataSetCodes = childDataSet.getParentDataSetCodes();
...@@ -496,7 +501,7 @@ public class EntitySynchronizer ...@@ -496,7 +501,7 @@ public class EntitySynchronizer
else if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Component")) else if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Component"))
{ {
NewExternalData componentDataSet = dataSetsToProcess.get(conn.getToPermId()).getDataSet(); NewExternalData componentDataSet = dataSetsToProcess.get(conn.getToPermId()).getDataSet();
if (notRegisteredDataSets.contains(componentDataSet.getCode()) == false) if (skippedDataSets.contains(componentDataSet.getCode()) == false)
{ {
NewContainerDataSet containerDataSet = (NewContainerDataSet) dataSet; NewContainerDataSet containerDataSet = (NewContainerDataSet) dataSet;
List<String> containedDataSetCodes = containerDataSet.getContainedDataSetCodes(); List<String> containedDataSetCodes = containerDataSet.getContainedDataSetCodes();
...@@ -515,13 +520,16 @@ public class EntitySynchronizer ...@@ -515,13 +520,16 @@ public class EntitySynchronizer
|| dataSetsCodesToRetry.contains(dataSet.getCode()) == true || dataSetsCodesToRetry.contains(dataSet.getCode()) == true
|| isParentModified(dsToParents, dataSet)) || isParentModified(dsToParents, dataSet))
{ {
if (physicalDSMap.containsKey(dataSet.getCode()) == false && service.tryGetDataSet(dataSet.getCode()) == null) if (blackListedDataSetCodes.contains(dataSet.getCode()) == false)
{ {
builder.dataSet(dataSet); if (physicalDSMap.containsKey(dataSet.getCode()) == false && service.tryGetDataSet(dataSet.getCode()) == null)
} {
else builder.dataSet(dataSet);
{ }
datasetsToUpdate.put(dataSet.getCode(), dataSet); else
{
datasetsToUpdate.put(dataSet.getCode(), dataSet);
}
} }
} }
} }
...@@ -644,26 +652,26 @@ public class EntitySynchronizer ...@@ -644,26 +652,26 @@ public class EntitySynchronizer
private void saveFailedEntitiesFile(List<String> notRegisteredDataSetCodes, List<String> notSyncedAttachmentsHolders) throws IOException private void saveFailedEntitiesFile(List<String> notRegisteredDataSetCodes, List<String> notSyncedAttachmentsHolders) throws IOException
{ {
File notSyncedDataSetsFile = new File(config.getNotSyncedEntitiesFileName()); File notSyncedEntitiesFile = new File(config.getNotSyncedEntitiesFileName());
if (notSyncedDataSetsFile.exists()) if (notSyncedEntitiesFile.exists())
{ {
backupAndResetNotSyncedDataSetsFile(notSyncedDataSetsFile); backupAndResetNotSyncedDataSetsFile(notSyncedEntitiesFile);
} }
// first write the data set codes to be retried next time we sync // first write the data set codes to be retried next time we sync
for (String dsCode : notRegisteredDataSetCodes) for (String dsCode : notRegisteredDataSetCodes)
{ {
FileUtilities.appendToFile(notSyncedDataSetsFile, SyncEntityKind.DATA_SET.getLabel() + "-" + dsCode, true); FileUtilities.appendToFile(notSyncedEntitiesFile, SyncEntityKind.DATA_SET.getLabel() + "-" + dsCode, true);
} }
// append the ids of holder entities for the failed attachment synchronizations // append the ids of holder entities for the failed attachment synchronizations
for (String holderCode : notSyncedAttachmentsHolders) for (String holderCode : notSyncedAttachmentsHolders)
{ {
FileUtilities.appendToFile(notSyncedDataSetsFile, holderCode, true); FileUtilities.appendToFile(notSyncedEntitiesFile, holderCode, true);
} }
// append the blacklisted codes to the end of the file // append the blacklisted codes to the end of the file
for (String dsCode : blackListedDataSetCodes) for (String dsCode : blackListedDataSetCodes)
{ {
FileUtilities.appendToFile(notSyncedDataSetsFile, dsCode, true); FileUtilities.appendToFile(notSyncedEntitiesFile, ("#" + SyncEntityKind.DATA_SET.getLabel() + "-" + dsCode), true);
} }
} }
......
...@@ -114,16 +114,21 @@ public class ResourceListParserData ...@@ -114,16 +114,21 @@ public class ResourceListParserData
return materialsToProcess; return materialsToProcess;
} }
public Map<String, IncomingDataSet> filterPhysicalDataSetsByLastModificationDate(Date lastSyncDate, Set<String> dataSetsCodesToRetry) public Map<String, IncomingDataSet> filterPhysicalDataSetsByLastModificationDate(Date lastSyncDate, Set<String> dataSetsCodesToRetry,
Set<String> blackListedDataSetCodes)
{ {
Map<String, IncomingDataSet> dsMap = new HashMap<String, ResourceListParserData.IncomingDataSet>(); Map<String, IncomingDataSet> dsMap = new HashMap<String, ResourceListParserData.IncomingDataSet>();
for (String permId : dataSetsToProcess.keySet()) for (String permId : dataSetsToProcess.keySet())
{ {
IncomingDataSet ds = dataSetsToProcess.get(permId); IncomingDataSet ds = dataSetsToProcess.get(permId);
String dataSetCode = ds.getDataSet().getCode();
if (ds.getKind() == DataSetKind.PHYSICAL if (ds.getKind() == DataSetKind.PHYSICAL
&& (ds.lastModificationDate.after(lastSyncDate) || dataSetsCodesToRetry.contains(ds.getDataSet().getCode()))) && (ds.lastModificationDate.after(lastSyncDate) == true || dataSetsCodesToRetry.contains(dataSetCode)) == true)
{ {
dsMap.put(permId, ds); if (blackListedDataSetCodes.contains(dataSetCode) == false)
{
dsMap.put(permId, ds);
}
} }
} }
return dsMap; return dsMap;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment