Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public interface IRepositoryService {

String RELATION_PULL = "http://www.sap.com/adt/abapgit/relations/pull"; //$NON-NLS-1$
String RELATION_PULL_WITH_BG_RUN = "http://www.sap.com/adt/abapgit/relations/pull/v2"; //$NON-NLS-1$
String RELATION_STATUS = "http://www.sap.com/adt/abapgit/relations/status"; //$NON-NLS-1$
String RELATION_LOG = "http://www.sap.com/adt/abapgit/relations/log"; //$NON-NLS-1$
String RELATION_STAGE = "http://www.sap.com/adt/abapgit/relations/stage"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public IAbapObjects cloneRepository(String url, String branch, String targetPack
IContentHandler<IAbapObjects> responseContentHandlerV1 = new AbapObjectContentHandlerV1();
restResource.addContentHandler(responseContentHandlerV1);

IAdtCompatibleRestResourceFilter compatibilityFilter = AdtCompatibleRestResourceFilterFactory.createFilter(responseContentHandlerV1);
IAdtCompatibleRestResourceFilter compatibilityFilter = AdtCompatibleRestResourceFilterFactory
.createFilter(responseContentHandlerV1);
restResource.addRequestFilter(compatibilityFilter);

return restResource.post(monitor, IAbapObjects.class, repository);
Expand Down Expand Up @@ -204,8 +205,7 @@ public void repositoryChecks(IProgressMonitor monitor, IExternalRepositoryInfoRe
restResource.addRequestFilter(compatibilityFilter);
restResource.addResponseFilter(compatibilityFilter);
if (credentials != null) {
headers = getHttpHeadersForCredentials(credentials.getUser(),
credentials.getPassword());
headers = getHttpHeadersForCredentials(credentials.getUser(), credentials.getPassword());
}
restResource.post(monitor, headers, null);
}
Expand Down Expand Up @@ -267,8 +267,8 @@ public URI getURIFromAtomLink(IRepository repository, String relation) {
}

@Override
public IAbapGitPullModifiedObjects getModifiedObjects(IProgressMonitor monitor, IRepository currRepository,
String user, String password) throws OutDatedClientException {
public IAbapGitPullModifiedObjects getModifiedObjects(IProgressMonitor monitor, IRepository currRepository, String user,
String password) throws OutDatedClientException {
URI uriToModifiedObjects = getURIFromAtomLink(currRepository, IRepositoryService.RELATION_MODIFIED_OBJECTS);

IHeaders headers = null;
Expand All @@ -277,8 +277,7 @@ public IAbapGitPullModifiedObjects getModifiedObjects(IProgressMonitor monitor,
}

IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory()
.createResourceWithStatelessSession(uriToModifiedObjects,
this.destinationId);
.createResourceWithStatelessSession(uriToModifiedObjects, this.destinationId);

IContentHandler<IAbapGitPullModifiedObjects> responseContentHandlerV1 = new AbapGitPullModifiedObjectsContentHandlerV1();
restResource.addContentHandler(responseContentHandlerV1);
Expand All @@ -295,10 +294,22 @@ public IAbapGitPullModifiedObjects getModifiedObjects(IProgressMonitor monitor,
@Override
public IAbapObjects pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password,
IAbapGitPullModifiedObjects selectedObjectsToPull, IProgressMonitor monitor) {
URI uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL);
IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo,
this.destinationId);

IRestResource restResource = null;
URI uriToRepo = null;
if (isBackgroundJobSupported(monitor)) {
uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL_WITH_BG_RUN);
if (uriToRepo != null) {
restResource = getBackgroundRestResource(uriToRepo.getPath(), this.destinationId, monitor);
}
}
if (restResource == null) {
uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL);
restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo,
this.destinationId);
}
if (restResource == null) {
throw new IllegalStateException("Unable to create REST resource for pull operation."); //$NON-NLS-1$
}
IContentHandler<IAbapGitPullRequest> requestContentHandlerV1 = new AbapGitPullRequestContentHandler();
restResource.addContentHandler(requestContentHandlerV1);

Expand All @@ -316,9 +327,9 @@ public IAbapObjects pullRepository(IRepository existingRepository, String branch
}

if (selectedObjectsToPull != null) {
abapGitPullReq.setPackageWarningObjects(selectedObjectsToPull.getPackageWarningObjects());
abapGitPullReq.setOverwriteObjects(selectedObjectsToPull.getOverwriteObjects());
}
abapGitPullReq.setPackageWarningObjects(selectedObjectsToPull.getPackageWarningObjects());
abapGitPullReq.setOverwriteObjects(selectedObjectsToPull.getOverwriteObjects());
}

IAdtCompatibleRestResourceFilter compatibilityFilter = AdtCompatibleRestResourceFilterFactory.createFilter(new IContentHandler[0]);
restResource.addRequestFilter(compatibilityFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,10 @@ public void run() {
}

WizardDialog wizardDialog = new WizardDialog(AbapGitView.this.viewer.getControl().getShell(),
new AbapGitWizardPull(AbapGitView.this.lastProject, this.selRepo, allRepositories));
new AbapGitWizardPull(AbapGitView.this.lastProject, this.selRepo, allRepositories, AbapGitView.this));
wizardDialog.open();
}

updateView(true);
}
}
};
this.actionPullWizard.setText(Messages.AbapGitView_context_pull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.abapgit.adt.backend.IApackManifest;
import org.abapgit.adt.backend.IApackManifest.IApackDependency;
Expand All @@ -14,11 +15,16 @@
import org.abapgit.adt.backend.model.agitpullmodifiedobjects.IAbapGitPullModifiedObjects;
import org.abapgit.adt.ui.AbapGitUIPlugin;
import org.abapgit.adt.ui.internal.i18n.Messages;
import org.abapgit.adt.ui.internal.repositories.AbapGitView;
import org.abapgit.adt.ui.internal.repositories.IRepositoryModifiedObjects;
import org.abapgit.adt.ui.internal.util.AbapGitUIServiceFactory;
import org.abapgit.adt.ui.internal.wizards.AbapGitWizard.CloneData;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.IPageChangingListener;
Expand Down Expand Up @@ -63,11 +69,12 @@ public class AbapGitWizardPull extends Wizard {
private AbapGitWizardPageObjectsSelectionForPull pageOverwriteObjectsSelection;
private AbapGitWizardPageObjectsSelectionForPull pagePackageWarningObjectsSelection;
public IAdtTransportService transportService;
private final AbapGitView abapGitView;
public IAdtTransportSelectionWizardPage transportPage;
public IRepository selRepoData;
public List<IRepository> allRepositories;

public AbapGitWizardPull(IProject project, IRepository selRepo, List<IRepository> allRepositories) {
public AbapGitWizardPull(IProject project, IRepository selRepo, List<IRepository> allRepositories, AbapGitView view) {
this.project = project;
this.destination = AdtProjectServiceFactory.createProjectService().getDestinationId(project);
this.cloneData = new CloneData();
Expand All @@ -76,7 +83,7 @@ public AbapGitWizardPull(IProject project, IRepository selRepo, List<IRepository
this.cloneData.url = selRepo.getUrl();
this.cloneData.branch = selRepo.getBranchName();
this.repoToSelectedObjects = new HashMap<String, IAbapGitPullModifiedObjects>();

this.abapGitView = view;
getPackageAndRepoType();

setWindowTitle(Messages.AbapGitWizardPull_title);
Expand Down Expand Up @@ -148,61 +155,67 @@ public void addPages() {
@Override
public boolean performFinish() {

try {
getContainer().run(true, true, new IRunnableWithProgress() {
// Extracting variable earlier to ensure consistency in asynchronous code flow
Set<IRepositoryModifiedObjects> overwriteObjects = AbapGitWizardPull.this.pageOverwriteObjectsSelection.getSelectedObjects();
Set<IRepositoryModifiedObjects> packageWarningObjects = AbapGitWizardPull.this.pagePackageWarningObjectsSelection
.getSelectedObjects();

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Job pullRepoJob = new Job(Messages.AbapGitWizard_task_pulling_repository) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.AbapGitWizard_task_pulling_repository, IProgressMonitor.UNKNOWN);

IRepositoryService repoService = RepositoryServiceFactory.createRepositoryService(AbapGitWizardPull.this.destination,
monitor);

//get the selected objects to be pulled
// Get the selected objects to be pulled
AbapGitWizardPull.this.repoToSelectedObjects = AbapGitUIServiceFactory.createAbapGitPullService()
.getSelectedObjectsToPullforRepo(AbapGitWizardPull.this.pageOverwriteObjectsSelection.getSelectedObjects(),
AbapGitWizardPull.this.pagePackageWarningObjectsSelection.getSelectedObjects());
.getSelectedObjectsToPullforRepo(overwriteObjects, packageWarningObjects);

//pull the selected objects
// Pull the selected objects
repoService.pullRepository(AbapGitWizardPull.this.selRepoData, AbapGitWizardPull.this.selRepoData.getBranchName(),
AbapGitWizardPull.this.transportPage.getTransportRequestNumber(), AbapGitWizardPull.this.cloneData.user,
AbapGitWizardPull.this.cloneData.pass,
AbapGitWizardPull.this.repoToSelectedObjects.get(AbapGitWizardPull.this.selRepoData.getUrl()), monitor);

// Pull dependencies if any
if (AbapGitWizardPull.this.cloneData.hasDependencies()) {
pullDependencies(monitor, repoService);
}

return Status.OK_STATUS;
} catch (ResourceException e) {
return new Status(IStatus.ERROR, AbapGitUIPlugin.PLUGIN_ID, e.getMessage(), e);
} finally {
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
AbapGitWizardPull.this.abapGitView.refresh();
});
}
}

private void pullDependencies(IProgressMonitor monitor, IRepositoryService repoService) {
for (IApackDependency apackDependency : AbapGitWizardPull.this.cloneData.apackManifest.getDescriptor()
.getDependencies()) {
if (apackDependency.requiresSynchronization()) {
IRepository dependencyRepository = repoService.getRepositoryByURL(AbapGitWizardPull.this.cloneData.repositories,
apackDependency.getGitUrl());
if (dependencyRepository != null) {
repoService.pullRepository(dependencyRepository, IApackManifest.MASTER_BRANCH,
AbapGitWizardPull.this.transportPage.getTransportRequestNumber(),
AbapGitWizardPull.this.cloneData.user, AbapGitWizardPull.this.cloneData.pass,
AbapGitWizardPull.this.repoToSelectedObjects.get(dependencyRepository.getUrl()), monitor);
private void pullDependencies(IProgressMonitor monitor, IRepositoryService repoService) {
for (IApackDependency apackDependency : AbapGitWizardPull.this.cloneData.apackManifest.getDescriptor().getDependencies()) {
if (apackDependency.requiresSynchronization()) {
IRepository dependencyRepository = repoService.getRepositoryByURL(AbapGitWizardPull.this.cloneData.repositories,
apackDependency.getGitUrl());
if (dependencyRepository != null) {
repoService.pullRepository(dependencyRepository, IApackManifest.MASTER_BRANCH,
AbapGitWizardPull.this.transportPage.getTransportRequestNumber(), AbapGitWizardPull.this.cloneData.user,
AbapGitWizardPull.this.cloneData.pass,
AbapGitWizardPull.this.repoToSelectedObjects.get(dependencyRepository.getUrl()), monitor);
}
}
}
}
}
});

return true;
};

pullRepoJob.setUser(true); // Shows the job in progress view
pullRepoJob.schedule();

return true;
Comment on lines +215 to +217
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow trigger a refresh of the view once the job has finished ?
The status is not updated in the viewer after job has completed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the AbapGitView I see a updateView(true) after pull action is triggered however I also don't see it actually refreshing once the pull is done. Will check why thats happening

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the callback related logic in other comment. What are your thoughts on it.


} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
((WizardPage) getContainer().getCurrentPage()).setPageComplete(false);
((WizardPage) getContainer().getCurrentPage()).setMessage(e.getTargetException().getMessage(), DialogPage.ERROR);
return false;
} catch (ResourceException e) {
((WizardPage) getContainer().getCurrentPage()).setPageComplete(false);
((WizardPage) getContainer().getCurrentPage()).setMessage(e.getMessage(), DialogPage.ERROR);
return false;
}
}

@Override
Expand Down
Loading