Skip to content

Commit

Permalink
authentication and selective pull related fixes (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamWaghmare-sap authored May 3, 2023
1 parent f8ed2e7 commit 60067b1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public static boolean isAuthenticationIssue(ResourceException exception) {
if (httpStatus == 401 || httpStatus == 403 || httpStatus == 404) {
return true;
}
} else if (exception.getMessage().contains("401")) { //$NON-NLS-1$
//Temporary fix for handling authentication issue.
//We were sending the HTTP status code from backend, again checking the message.
//But the message in backend is changed and it no more sends the correct HTTP status code.
//TODO This has to be better handled in the backend.
return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.abapgit.adt.ui.internal.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.abapgit.adt.backend.IRepositoryService;
import org.abapgit.adt.backend.model.abapgitrepositories.IRepository;
Expand Down Expand Up @@ -59,7 +61,13 @@ public static void fetchAndExtractModifiedObjectsToPull(IRepository repository,
IAbapGitPullModifiedObjects abapPullModifiedObjects = repoService.getModifiedObjects(new NullProgressMonitor(), repository,
cloneData.user, cloneData.pass);

//Client side adjustment to the overwrite objects, and remove any objects from the package warning objects.
//TODO Fix this in the backend.
adjust_overwrite_objects(abapPullModifiedObjects);

if (!abapPullModifiedObjects.getOverwriteObjects().getAbapgitobjects().isEmpty()) {


cloneData.repoToModifiedOverwriteObjects.add(new RepositoryModifiedObjects(repository.getUrl(),
new ArrayList<IAbapGitObject>(abapPullModifiedObjects.getOverwriteObjects().getAbapgitobjects())));
}
Expand All @@ -70,4 +78,30 @@ public static void fetchAndExtractModifiedObjectsToPull(IRepository repository,
}

}

private static void adjust_overwrite_objects(IAbapGitPullModifiedObjects abapPullModifiedObjects) {

if (abapPullModifiedObjects.getOverwriteObjects() == null
|| abapPullModifiedObjects.getOverwriteObjects().getAbapgitobjects().isEmpty()) {
return;
}

if (abapPullModifiedObjects.getPackageWarningObjects() != null) {
List<IAbapGitObject> warningObjects = abapPullModifiedObjects.getPackageWarningObjects().getAbapgitobjects();

for (IAbapGitObject abapGitObject : warningObjects) {
Iterator<IAbapGitObject> iterator = abapPullModifiedObjects.getOverwriteObjects().getAbapgitobjects().iterator();
while (iterator.hasNext()) {
IAbapGitObject overwriteObject = iterator.next();
if (overwriteObject.getName().equals(abapGitObject.getName())
&& overwriteObject.getType().equals(abapGitObject.getType())) {
iterator.remove();
break;
}
}
}
}


}
}

0 comments on commit 60067b1

Please sign in to comment.