Program: 88581
Project: 88581
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void run(ProgressStatus progressStatus){
  progressStatus.setDescription("String_Node_Str");
  if (ProjectUtilities.isFromEsiServer(project.getPrimaryProject()) && EsiUtils.getLoggedUserName() == null) {
    Utils.guilog("String_Node_Str");
    return;
  }
  if (!TicketUtils.isTicketValid(project)) {
    Utils.guilog("String_Node_Str");
    return;
  }
  ProjectValidator pv=new ProjectValidator(project);
  pv.validate();
  if (pv.hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    return;
  }
  if (pv.getValidationSuite().hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    Utils.displayValidationWindow(project,pv.getValidationSuite(),"String_Node_Str");
    return;
  }
  BranchValidator bv=new BranchValidator(project);
  bv.validate(null,false);
  if (bv.hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    return;
  }
  if (bv.getValidationSuite().hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    Utils.displayValidationWindow(project,bv.getValidationSuite(),"String_Node_Str");
    return;
  }
  LocalSyncTransactionCommitListener listener=LocalSyncProjectEventListenerAdapter.getProjectMapping(project).getLocalSyncTransactionCommitListener();
  listener.setDisabled(true);
  SyncElements.lockSyncFolder(project);
  listener.setDisabled(false);
  JMSSyncProjectEventListenerAdapter.JMSSyncProjectMapping jmsSyncProjectMapping=JMSSyncProjectEventListenerAdapter.getProjectMapping(Application.getInstance().getProject());
  JMSMessageListener jmsMessageListener=jmsSyncProjectMapping.getJmsMessageListener();
  if (jmsMessageListener == null) {
    if (MDKOptionsGroup.getMDKOptions().isChangeListenerEnabled()) {
      Application.getInstance().getGUILog().log("String_Node_Str");
    }
    return;
  }
  Changelog<String,Element> persistedLocalChangelog=new Changelog<>();
  Collection<SyncElement> persistedLocalSyncElements=SyncElements.getAllOfType(project,SyncElement.Type.LOCAL);
  for (  SyncElement syncElement : persistedLocalSyncElements) {
    persistedLocalChangelog=persistedLocalChangelog.and(SyncElements.buildChangelog(syncElement),(key,value) -> Converters.getIdToElementConverter().apply(key,project));
  }
  Changelog<String,Element> localChangelog=persistedLocalChangelog.and(listener.getInMemoryLocalChangelog());
  Map<String,Element> localCreated=localChangelog.get(Changelog.ChangeType.CREATED), localUpdated=localChangelog.get(Changelog.ChangeType.UPDATED), localDeleted=localChangelog.get(Changelog.ChangeType.DELETED);
  Changelog<String,Void> persistedJmsChangelog=new Changelog<>();
  Collection<SyncElement> persistedJmsSyncElements=SyncElements.getAllOfType(project,SyncElement.Type.MMS);
  for (  SyncElement syncElement : persistedJmsSyncElements) {
    persistedJmsChangelog=persistedJmsChangelog.and(SyncElements.buildChangelog(syncElement));
  }
  Changelog<String,Void> jmsChangelog=persistedJmsChangelog.and(jmsMessageListener.getInMemoryJMSChangelog(),(key,objectNode) -> null);
  Map<String,Void> jmsCreated=jmsChangelog.get(Changelog.ChangeType.CREATED), jmsUpdated=jmsChangelog.get(Changelog.ChangeType.UPDATED), jmsDeleted=jmsChangelog.get(Changelog.ChangeType.DELETED);
  Set<String> elementIdsToGet=new HashSet<>(jmsUpdated.keySet());
  elementIdsToGet.addAll(jmsCreated.keySet());
  if (shouldUpdate && !jmsChangelog.isEmpty()) {
    int size=jmsChangelog.flattenedSize();
    Application.getInstance().getGUILog().log("String_Node_Str" + size + "String_Node_Str"+ (size != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  }
  Map<String,ObjectNode> jmsJsons=new HashMap<>(elementIdsToGet.size());
  if (!elementIdsToGet.isEmpty()) {
    progressStatus.setDescription("String_Node_Str" + elementIdsToGet.size() + "String_Node_Str"+ (elementIdsToGet.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
    ObjectNode response=null;
    try {
      response=JacksonUtils.parseJsonObject(MMSUtils.getElements(project,elementIdsToGet,progressStatus));
    }
 catch (    ServerException|IOException|URISyntaxException e) {
      if (e instanceof ServerException && ((ServerException)e).getCode() == 404) {
        (response=JacksonUtils.getObjectMapper().createObjectNode()).putArray("String_Node_Str");
      }
 else       if (!progressStatus.isCancel()) {
        Application.getInstance().getGUILog().log("String_Node_Str");
        e.printStackTrace();
        return;
      }
    }
    if (progressStatus.isCancel()) {
      Application.getInstance().getGUILog().log("String_Node_Str");
      return;
    }
    JsonNode elementsArrayNode;
    if (response == null || (elementsArrayNode=response.get("String_Node_Str")) == null || !elementsArrayNode.isArray()) {
      Utils.guilog("String_Node_Str");
      return;
    }
    for (    JsonNode jsonNode : elementsArrayNode) {
      if (!jsonNode.isObject()) {
        continue;
      }
      String webId=jsonNode.get(MDKConstants.ID_KEY).asText();
      jmsJsons.put(webId,(ObjectNode)jsonNode);
    }
  }
  progressStatus.setDescription("String_Node_Str");
  Map<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedChanges=new LinkedHashMap<>(), unconflictedChanges=new LinkedHashMap<>();
  localChangelog.findConflicts(jmsChangelog,(change,change2) -> change != null && change2 != null,conflictedChanges,unconflictedChanges);
  Map<String,Element> localElementsToPost=new LinkedHashMap<>(localCreated.size() + localUpdated.size());
  Set<String> deleteElements=new HashSet<>(localDeleted.size());
  Map<String,ObjectNode> jmsElementsToCreateLocally=new LinkedHashMap<>(jmsCreated.size());
  Map<String,Pair<ObjectNode,Element>> jmsElementsToUpdateLocally=new LinkedHashMap<>(jmsUpdated.size());
  Map<String,Element> jmsElementsToDeleteLocally=new LinkedHashMap<>(jmsDeleted.size());
  for (  Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> unconflictedEntry : unconflictedChanges.entrySet()) {
    String id=unconflictedEntry.getKey();
    Changelog.Change<Element> localChange=unconflictedEntry.getValue().getKey();
    Changelog.Change<ObjectNode> jmsChange=unconflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),unconflictedEntry.getValue().getValue().getType()) : null;
    if (shouldCommit && localChange != null) {
      Element element=localChange.getChanged();
switch (localChange.getType()) {
case CREATED:
case UPDATED:
        if (element == null) {
          Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
          continue;
        }
      localElementsToPost.put(id,element);
    break;
case DELETED:
  if (element != null && !project.isDisposed(element)) {
    Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
    continue;
  }
deleteElements.add(id);
break;
}
}
 else if (shouldUpdate && jmsChange != null) {
ObjectNode objectNode=jmsChange.getChanged();
Element element=Converters.getIdToElementConverter().apply(id,project);
switch (jmsChange.getType()) {
case CREATED:
if (objectNode == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (element != null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
jmsElementsToCreateLocally.put(id,objectNode);
break;
case UPDATED:
if (objectNode == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (element == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (!element.isEditable()) {
if (MDUtils.isDeveloperMode()) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
}
failedJmsChangelog.addChange(id,null,Changelog.ChangeType.UPDATED);
continue;
}
jmsElementsToUpdateLocally.put(id,new Pair<>(objectNode,element));
break;
case DELETED:
if (element == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (!element.isEditable()) {
if (MDUtils.isDeveloperMode()) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
}
failedJmsChangelog.addChange(id,null,Changelog.ChangeType.DELETED);
continue;
}
jmsElementsToDeleteLocally.put(id,element);
break;
}
}
}
if (progressStatus.isCancel()) {
Application.getInstance().getGUILog().log("String_Node_Str");
return;
}
boolean shouldLogNoLocalChanges=shouldCommit;
if (shouldCommit && !localElementsToPost.isEmpty()) {
progressStatus.setDescription("String_Node_Str");
LinkedList<ObjectNode> postElements=new LinkedList<>();
for (Element element : localElementsToPost.values()) {
ObjectNode elementObjectNode=Converters.getElementToJsonConverter().apply(element,project);
if (elementObjectNode != null) {
postElements.add(elementObjectNode);
}
}
if (postElements.size() > 0) {
Application.getInstance().getGUILog().log("String_Node_Str" + NumberFormat.getInstance().format(postElements.size()) + "String_Node_Str"+ (postElements.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
URIBuilder requestUri=MMSUtils.getServiceProjectsRefsElementsUri(project);
try {
File sendData=MMSUtils.createEntityFile(this.getClass(),ContentType.APPLICATION_JSON,postElements,MMSUtils.JsonBlobType.ELEMENT_JSON);
OutputQueue.getInstance().offer(new Request(project,MMSUtils.HttpRequestType.POST,requestUri,sendData,ContentType.APPLICATION_JSON,true,postElements.size(),"String_Node_Str"));
}
 catch (IOException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
catch (URISyntaxException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
shouldLogNoLocalChanges=false;
}
}
if (shouldCommit && shouldCommitDeletes && !deleteElements.isEmpty()) {
progressStatus.setDescription("String_Node_Str");
Application.getInstance().getGUILog().log("String_Node_Str" + NumberFormat.getInstance().format(deleteElements.size()) + "String_Node_Str"+ (deleteElements.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
URIBuilder requestUri=MMSUtils.getServiceProjectsRefsElementsUri(project);
try {
File sendData=MMSUtils.createEntityFile(this.getClass(),ContentType.APPLICATION_JSON,deleteElements,MMSUtils.JsonBlobType.ELEMENT_ID);
OutputQueue.getInstance().offer(new Request(project,MMSUtils.HttpRequestType.DELETE,requestUri,sendData,ContentType.APPLICATION_JSON,true,deleteElements.size(),"String_Node_Str"));
}
 catch (IOException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
catch (URISyntaxException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
shouldLogNoLocalChanges=false;
}
if (shouldLogNoLocalChanges) {
Application.getInstance().getGUILog().log("String_Node_Str");
}
if (shouldUpdate) {
listener.setDisabled(true);
List<ObjectNode> jmsElementsToCreateOrUpdateLocally=new ArrayList<>(jmsElementsToCreateLocally.size() + jmsElementsToUpdateLocally.size());
jmsElementsToCreateOrUpdateLocally.addAll(jmsElementsToCreateLocally.values());
jmsElementsToUpdateLocally.values().forEach(pair -> jmsElementsToCreateOrUpdateLocally.add(pair.getKey()));
UpdateClientElementAction updateClientElementAction=new UpdateClientElementAction(project);
updateClientElementAction.setElementsToUpdate(jmsElementsToCreateOrUpdateLocally);
updateClientElementAction.setElementsToDelete(jmsElementsToDeleteLocally.values().stream().map(Converters.getElementToIdConverter()).filter(id -> id != null).filter(id -> !id.isEmpty()).collect(Collectors.toList()));
updateClientElementAction.run(progressStatus);
failedJmsChangelog=failedJmsChangelog.and(updateClientElementAction.getFailedChangelog(),(id,objectNode) -> null);
listener.setDisabled(false);
}
progressStatus.setDescription("String_Node_Str");
Set<Element> localConflictedElements=new HashSet<>();
Set<ObjectNode> jmsConflictedElements=new HashSet<>();
for (Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedEntry : conflictedChanges.entrySet()) {
String id=conflictedEntry.getKey();
Changelog.Change<Element> localChange=conflictedEntry.getValue().getKey();
Changelog.Change<ObjectNode> jmsChange=conflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),conflictedEntry.getValue().getValue().getType()) : null;
if (localChange != null && localChange.getChanged() != null && !project.isDisposed(localChange.getChanged())) {
localConflictedElements.add(localChange.getChanged());
}
if (jmsChange != null && jmsChange.getChanged() != null) {
jmsConflictedElements.add(jmsChange.getChanged());
}
}
ElementValidator elementValidator=new ElementValidator(ElementValidator.buildElementPairs(localConflictedElements,project),jmsConflictedElements,project);
elementValidator.run(progressStatus);
if (!elementValidator.getInvalidElements().isEmpty()) {
Application.getInstance().getGUILog().log("String_Node_Str" + elementValidator.getInvalidElements().size() + "String_Node_Str"+ (elementValidator.getInvalidElements().size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
vss.add(elementValidator.getValidationSuite());
Utils.displayValidationWindow(project,elementValidator.getValidationSuite(),"String_Node_Str");
for (Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedEntry : conflictedChanges.entrySet()) {
String id=conflictedEntry.getKey();
if (!elementValidator.getInvalidElements().containsKey(id)) {
continue;
}
Changelog.Change<Element> localChange=conflictedEntry.getValue().getKey();
Changelog.Change<ObjectNode> jmsChange=conflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),conflictedEntry.getValue().getValue().getType()) : null;
if (localChange != null && localChange.getChanged() != null || Changelog.ChangeType.DELETED.equals(localChange.getType())) {
failedLocalChangelog.addChange(conflictedEntry.getKey(),localChange.getChanged(),localChange.getType());
}
if (jmsChange != null && jmsChange.getChanged() != null || Changelog.ChangeType.DELETED.equals(jmsChange.getType())) {
failedJmsChangelog.addChange(conflictedEntry.getKey(),null,jmsChange.getType());
}
}
}
listener.getInMemoryLocalChangelog().clear();
jmsMessageListener.getInMemoryJMSChangelog().clear();
listener.setDisabled(true);
if (!SessionManager.getInstance().isSessionCreated()) {
SessionManager.getInstance().createSession("String_Node_Str");
}
Changelog<String,Void> unprocessedLocalChangelog=new Changelog<>();
if (!shouldCommit) {
unprocessedLocalChangelog=unprocessedLocalChangelog.and(localChangelog,(s,element) -> null);
}
if (shouldCommit && !shouldCommitDeletes) {
Map<String,Void> unprocessedLocalDeletedChanges=unprocessedLocalChangelog.get(Changelog.ChangeType.DELETED);
for (String key : localChangelog.get(Changelog.ChangeType.DELETED).keySet()) {
unprocessedLocalDeletedChanges.put(key,null);
}
}
unprocessedLocalChangelog=unprocessedLocalChangelog.and(failedLocalChangelog,(s,element) -> null);
try {
SyncElements.setByType(project,SyncElement.Type.LOCAL,JacksonUtils.getObjectMapper().writeValueAsString(SyncElements.buildJson(unprocessedLocalChangelog)));
}
 catch (JsonProcessingException e) {
e.printStackTrace();
}
Changelog<String,Void> unprocessedJmsChangelog=new Changelog<>();
if (!shouldUpdate) {
unprocessedJmsChangelog=unprocessedJmsChangelog.and(jmsChangelog);
}
unprocessedJmsChangelog=unprocessedJmsChangelog.and(failedJmsChangelog);
try {
SyncElements.setByType(project,SyncElement.Type.MMS,JacksonUtils.getObjectMapper().writeValueAsString(SyncElements.buildJson(unprocessedJmsChangelog)));
}
 catch (JsonProcessingException e) {
e.printStackTrace();
}
SessionManager.getInstance().closeSession();
listener.setDisabled(false);
failure=false;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void run(ProgressStatus progressStatus){
  progressStatus.setDescription("String_Node_Str");
  if (ProjectUtilities.isFromEsiServer(project.getPrimaryProject()) && EsiUtils.getLoggedUserName() == null) {
    Utils.guilog("String_Node_Str");
    return;
  }
  if (!TicketUtils.isTicketSet(project)) {
    Utils.guilog("String_Node_Str");
    return;
  }
  ProjectValidator pv=new ProjectValidator(project);
  pv.validate();
  if (pv.hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    return;
  }
  if (pv.getValidationSuite().hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    Utils.displayValidationWindow(project,pv.getValidationSuite(),"String_Node_Str");
    return;
  }
  BranchValidator bv=new BranchValidator(project);
  bv.validate(null,false);
  if (bv.hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    return;
  }
  if (bv.getValidationSuite().hasErrors()) {
    Application.getInstance().getGUILog().log("String_Node_Str");
    Utils.displayValidationWindow(project,bv.getValidationSuite(),"String_Node_Str");
    return;
  }
  LocalSyncTransactionCommitListener listener=LocalSyncProjectEventListenerAdapter.getProjectMapping(project).getLocalSyncTransactionCommitListener();
  listener.setDisabled(true);
  SyncElements.lockSyncFolder(project);
  listener.setDisabled(false);
  JMSSyncProjectEventListenerAdapter.JMSSyncProjectMapping jmsSyncProjectMapping=JMSSyncProjectEventListenerAdapter.getProjectMapping(Application.getInstance().getProject());
  JMSMessageListener jmsMessageListener=jmsSyncProjectMapping.getJmsMessageListener();
  if (jmsMessageListener == null) {
    if (MDKOptionsGroup.getMDKOptions().isChangeListenerEnabled()) {
      Application.getInstance().getGUILog().log("String_Node_Str");
    }
    return;
  }
  Changelog<String,Element> persistedLocalChangelog=new Changelog<>();
  Collection<SyncElement> persistedLocalSyncElements=SyncElements.getAllOfType(project,SyncElement.Type.LOCAL);
  for (  SyncElement syncElement : persistedLocalSyncElements) {
    persistedLocalChangelog=persistedLocalChangelog.and(SyncElements.buildChangelog(syncElement),(key,value) -> Converters.getIdToElementConverter().apply(key,project));
  }
  Changelog<String,Element> localChangelog=persistedLocalChangelog.and(listener.getInMemoryLocalChangelog());
  Map<String,Element> localCreated=localChangelog.get(Changelog.ChangeType.CREATED), localUpdated=localChangelog.get(Changelog.ChangeType.UPDATED), localDeleted=localChangelog.get(Changelog.ChangeType.DELETED);
  Changelog<String,Void> persistedJmsChangelog=new Changelog<>();
  Collection<SyncElement> persistedJmsSyncElements=SyncElements.getAllOfType(project,SyncElement.Type.MMS);
  for (  SyncElement syncElement : persistedJmsSyncElements) {
    persistedJmsChangelog=persistedJmsChangelog.and(SyncElements.buildChangelog(syncElement));
  }
  Changelog<String,Void> jmsChangelog=persistedJmsChangelog.and(jmsMessageListener.getInMemoryJMSChangelog(),(key,objectNode) -> null);
  Map<String,Void> jmsCreated=jmsChangelog.get(Changelog.ChangeType.CREATED), jmsUpdated=jmsChangelog.get(Changelog.ChangeType.UPDATED), jmsDeleted=jmsChangelog.get(Changelog.ChangeType.DELETED);
  Set<String> elementIdsToGet=new HashSet<>(jmsUpdated.keySet());
  elementIdsToGet.addAll(jmsCreated.keySet());
  if (shouldUpdate && !jmsChangelog.isEmpty()) {
    int size=jmsChangelog.flattenedSize();
    Application.getInstance().getGUILog().log("String_Node_Str" + size + "String_Node_Str"+ (size != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  }
  Map<String,ObjectNode> jmsJsons=new HashMap<>(elementIdsToGet.size());
  if (!elementIdsToGet.isEmpty()) {
    progressStatus.setDescription("String_Node_Str" + elementIdsToGet.size() + "String_Node_Str"+ (elementIdsToGet.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
    ObjectNode response=null;
    try {
      response=JacksonUtils.parseJsonObject(MMSUtils.getElements(project,elementIdsToGet,progressStatus));
    }
 catch (    ServerException|IOException|URISyntaxException e) {
      if (e instanceof ServerException && ((ServerException)e).getCode() == 404) {
        (response=JacksonUtils.getObjectMapper().createObjectNode()).putArray("String_Node_Str");
      }
 else       if (!progressStatus.isCancel()) {
        Application.getInstance().getGUILog().log("String_Node_Str");
        e.printStackTrace();
        return;
      }
    }
    if (progressStatus.isCancel()) {
      Application.getInstance().getGUILog().log("String_Node_Str");
      return;
    }
    JsonNode elementsArrayNode;
    if (response == null || (elementsArrayNode=response.get("String_Node_Str")) == null || !elementsArrayNode.isArray()) {
      Utils.guilog("String_Node_Str");
      return;
    }
    for (    JsonNode jsonNode : elementsArrayNode) {
      if (!jsonNode.isObject()) {
        continue;
      }
      String webId=jsonNode.get(MDKConstants.ID_KEY).asText();
      jmsJsons.put(webId,(ObjectNode)jsonNode);
    }
  }
  progressStatus.setDescription("String_Node_Str");
  Map<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedChanges=new LinkedHashMap<>(), unconflictedChanges=new LinkedHashMap<>();
  localChangelog.findConflicts(jmsChangelog,(change,change2) -> change != null && change2 != null,conflictedChanges,unconflictedChanges);
  Map<String,Element> localElementsToPost=new LinkedHashMap<>(localCreated.size() + localUpdated.size());
  Set<String> deleteElements=new HashSet<>(localDeleted.size());
  Map<String,ObjectNode> jmsElementsToCreateLocally=new LinkedHashMap<>(jmsCreated.size());
  Map<String,Pair<ObjectNode,Element>> jmsElementsToUpdateLocally=new LinkedHashMap<>(jmsUpdated.size());
  Map<String,Element> jmsElementsToDeleteLocally=new LinkedHashMap<>(jmsDeleted.size());
  for (  Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> unconflictedEntry : unconflictedChanges.entrySet()) {
    String id=unconflictedEntry.getKey();
    Changelog.Change<Element> localChange=unconflictedEntry.getValue().getKey();
    Changelog.Change<ObjectNode> jmsChange=unconflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),unconflictedEntry.getValue().getValue().getType()) : null;
    if (shouldCommit && localChange != null) {
      Element element=localChange.getChanged();
switch (localChange.getType()) {
case CREATED:
case UPDATED:
        if (element == null) {
          Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
          continue;
        }
      localElementsToPost.put(id,element);
    break;
case DELETED:
  if (element != null && !project.isDisposed(element)) {
    Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
    continue;
  }
deleteElements.add(id);
break;
}
}
 else if (shouldUpdate && jmsChange != null) {
ObjectNode objectNode=jmsChange.getChanged();
Element element=Converters.getIdToElementConverter().apply(id,project);
switch (jmsChange.getType()) {
case CREATED:
if (objectNode == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (element != null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
jmsElementsToCreateLocally.put(id,objectNode);
break;
case UPDATED:
if (objectNode == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (element == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (!element.isEditable()) {
if (MDUtils.isDeveloperMode()) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
}
failedJmsChangelog.addChange(id,null,Changelog.ChangeType.UPDATED);
continue;
}
jmsElementsToUpdateLocally.put(id,new Pair<>(objectNode,element));
break;
case DELETED:
if (element == null) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
continue;
}
if (!element.isEditable()) {
if (MDUtils.isDeveloperMode()) {
Application.getInstance().getGUILog().log("String_Node_Str" + id + "String_Node_Str");
}
failedJmsChangelog.addChange(id,null,Changelog.ChangeType.DELETED);
continue;
}
jmsElementsToDeleteLocally.put(id,element);
break;
}
}
}
if (progressStatus.isCancel()) {
Application.getInstance().getGUILog().log("String_Node_Str");
return;
}
boolean shouldLogNoLocalChanges=shouldCommit;
if (shouldCommit && !localElementsToPost.isEmpty()) {
progressStatus.setDescription("String_Node_Str");
LinkedList<ObjectNode> postElements=new LinkedList<>();
for (Element element : localElementsToPost.values()) {
ObjectNode elementObjectNode=Converters.getElementToJsonConverter().apply(element,project);
if (elementObjectNode != null) {
postElements.add(elementObjectNode);
}
}
if (postElements.size() > 0) {
Application.getInstance().getGUILog().log("String_Node_Str" + NumberFormat.getInstance().format(postElements.size()) + "String_Node_Str"+ (postElements.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
URIBuilder requestUri=MMSUtils.getServiceProjectsRefsElementsUri(project);
try {
File sendData=MMSUtils.createEntityFile(this.getClass(),ContentType.APPLICATION_JSON,postElements,MMSUtils.JsonBlobType.ELEMENT_JSON);
OutputQueue.getInstance().offer(new Request(project,MMSUtils.HttpRequestType.POST,requestUri,sendData,ContentType.APPLICATION_JSON,true,postElements.size(),"String_Node_Str"));
}
 catch (IOException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
catch (URISyntaxException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
shouldLogNoLocalChanges=false;
}
}
if (shouldCommit && shouldCommitDeletes && !deleteElements.isEmpty()) {
progressStatus.setDescription("String_Node_Str");
Application.getInstance().getGUILog().log("String_Node_Str" + NumberFormat.getInstance().format(deleteElements.size()) + "String_Node_Str"+ (deleteElements.size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
URIBuilder requestUri=MMSUtils.getServiceProjectsRefsElementsUri(project);
try {
File sendData=MMSUtils.createEntityFile(this.getClass(),ContentType.APPLICATION_JSON,deleteElements,MMSUtils.JsonBlobType.ELEMENT_ID);
OutputQueue.getInstance().offer(new Request(project,MMSUtils.HttpRequestType.DELETE,requestUri,sendData,ContentType.APPLICATION_JSON,true,deleteElements.size(),"String_Node_Str"));
}
 catch (IOException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
catch (URISyntaxException e) {
Application.getInstance().getGUILog().log("String_Node_Str");
e.printStackTrace();
}
shouldLogNoLocalChanges=false;
}
if (shouldLogNoLocalChanges) {
Application.getInstance().getGUILog().log("String_Node_Str");
}
if (shouldUpdate) {
listener.setDisabled(true);
List<ObjectNode> jmsElementsToCreateOrUpdateLocally=new ArrayList<>(jmsElementsToCreateLocally.size() + jmsElementsToUpdateLocally.size());
jmsElementsToCreateOrUpdateLocally.addAll(jmsElementsToCreateLocally.values());
jmsElementsToUpdateLocally.values().forEach(pair -> jmsElementsToCreateOrUpdateLocally.add(pair.getKey()));
UpdateClientElementAction updateClientElementAction=new UpdateClientElementAction(project);
updateClientElementAction.setElementsToUpdate(jmsElementsToCreateOrUpdateLocally);
updateClientElementAction.setElementsToDelete(jmsElementsToDeleteLocally.values().stream().map(Converters.getElementToIdConverter()).filter(id -> id != null).filter(id -> !id.isEmpty()).collect(Collectors.toList()));
updateClientElementAction.run(progressStatus);
failedJmsChangelog=failedJmsChangelog.and(updateClientElementAction.getFailedChangelog(),(id,objectNode) -> null);
listener.setDisabled(false);
}
progressStatus.setDescription("String_Node_Str");
Set<Element> localConflictedElements=new HashSet<>();
Set<ObjectNode> jmsConflictedElements=new HashSet<>();
for (Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedEntry : conflictedChanges.entrySet()) {
String id=conflictedEntry.getKey();
Changelog.Change<Element> localChange=conflictedEntry.getValue().getKey();
Changelog.Change<ObjectNode> jmsChange=conflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),conflictedEntry.getValue().getValue().getType()) : null;
if (localChange != null && localChange.getChanged() != null && !project.isDisposed(localChange.getChanged())) {
localConflictedElements.add(localChange.getChanged());
}
if (jmsChange != null && jmsChange.getChanged() != null) {
jmsConflictedElements.add(jmsChange.getChanged());
}
}
ElementValidator elementValidator=new ElementValidator(ElementValidator.buildElementPairs(localConflictedElements,project),jmsConflictedElements,project);
elementValidator.run(progressStatus);
if (!elementValidator.getInvalidElements().isEmpty()) {
Application.getInstance().getGUILog().log("String_Node_Str" + elementValidator.getInvalidElements().size() + "String_Node_Str"+ (elementValidator.getInvalidElements().size() != 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
vss.add(elementValidator.getValidationSuite());
Utils.displayValidationWindow(project,elementValidator.getValidationSuite(),"String_Node_Str");
for (Map.Entry<String,Pair<Changelog.Change<Element>,Changelog.Change<Void>>> conflictedEntry : conflictedChanges.entrySet()) {
String id=conflictedEntry.getKey();
if (!elementValidator.getInvalidElements().containsKey(id)) {
continue;
}
Changelog.Change<Element> localChange=conflictedEntry.getValue().getKey();
Changelog.Change<ObjectNode> jmsChange=conflictedEntry.getValue().getValue() != null ? new Changelog.Change<>(jmsJsons.get(id),conflictedEntry.getValue().getValue().getType()) : null;
if (localChange != null && localChange.getChanged() != null || Changelog.ChangeType.DELETED.equals(localChange.getType())) {
failedLocalChangelog.addChange(conflictedEntry.getKey(),localChange.getChanged(),localChange.getType());
}
if (jmsChange != null && jmsChange.getChanged() != null || Changelog.ChangeType.DELETED.equals(jmsChange.getType())) {
failedJmsChangelog.addChange(conflictedEntry.getKey(),null,jmsChange.getType());
}
}
}
listener.getInMemoryLocalChangelog().clear();
jmsMessageListener.getInMemoryJMSChangelog().clear();
listener.setDisabled(true);
if (!SessionManager.getInstance().isSessionCreated()) {
SessionManager.getInstance().createSession("String_Node_Str");
}
Changelog<String,Void> unprocessedLocalChangelog=new Changelog<>();
if (!shouldCommit) {
unprocessedLocalChangelog=unprocessedLocalChangelog.and(localChangelog,(s,element) -> null);
}
if (shouldCommit && !shouldCommitDeletes) {
Map<String,Void> unprocessedLocalDeletedChanges=unprocessedLocalChangelog.get(Changelog.ChangeType.DELETED);
for (String key : localChangelog.get(Changelog.ChangeType.DELETED).keySet()) {
unprocessedLocalDeletedChanges.put(key,null);
}
}
unprocessedLocalChangelog=unprocessedLocalChangelog.and(failedLocalChangelog,(s,element) -> null);
try {
SyncElements.setByType(project,SyncElement.Type.LOCAL,JacksonUtils.getObjectMapper().writeValueAsString(SyncElements.buildJson(unprocessedLocalChangelog)));
}
 catch (JsonProcessingException e) {
e.printStackTrace();
}
Changelog<String,Void> unprocessedJmsChangelog=new Changelog<>();
if (!shouldUpdate) {
unprocessedJmsChangelog=unprocessedJmsChangelog.and(jmsChangelog);
}
unprocessedJmsChangelog=unprocessedJmsChangelog.and(failedJmsChangelog);
try {
SyncElements.setByType(project,SyncElement.Type.MMS,JacksonUtils.getObjectMapper().writeValueAsString(SyncElements.buildJson(unprocessedJmsChangelog)));
}
 catch (JsonProcessingException e) {
e.printStackTrace();
}
SessionManager.getInstance().closeSession();
listener.setDisabled(false);
failure=false;
}