-
Notifications
You must be signed in to change notification settings - Fork 24
Feature/background job implementation #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
b1b9252
fea7118
c09cf6d
9a415ac
bafaae2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,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); | ||
|
|
@@ -205,8 +206,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); | ||
| } | ||
|
|
@@ -268,8 +268,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; | ||
|
|
@@ -278,8 +278,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); | ||
|
|
@@ -297,13 +296,27 @@ 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_WITHOUT_BG); | ||
| URI backgroundUri = AdtBackgroundRunUriDiscoveryFactory.createBackgroundRunUriDiscovery(this.destinationId) | ||
| .getBackgroundRunUriIfAuthorized(monitor); | ||
| IRestResource restResource = AdtBackgroundRestResourceFactory.createBackgroundRestResourceFactory() | ||
| .createResourceWithStatelessSession(backgroundUri, uriToRepo, this.destinationId); | ||
| // IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo, | ||
| // this.destinationId); | ||
| IRestResource restResource = null; | ||
| URI uriToRepo = null; | ||
| // check if background job framework is available and is accessible by the user. | ||
|
||
| if (isBackgroundJobSupported(monitor)) { | ||
| // get new pull without background resource URI | ||
| uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL_WITHOUT_BG); | ||
| // check whether URI is available in the system (this depends on the back end version) | ||
| if (uriToRepo != null) { | ||
| restResource = getBackgroundRestResource(uriToRepo.getPath(), this.destinationId, monitor); | ||
| } | ||
| } | ||
| // if rest resource is still null, rollback to normal pull URI | ||
| if (restResource == null) { | ||
| uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL); | ||
| restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo, | ||
| this.destinationId); | ||
| } | ||
| if (restResource == null) { | ||
| // if rest resource could not be created, throw exception | ||
| throw new IllegalStateException("Unable to create REST resource for pull operation."); //$NON-NLS-1$ | ||
| } | ||
| IContentHandler<IAbapGitPullRequest> requestContentHandlerV1 = new AbapGitPullRequestContentHandler(); | ||
| restResource.addContentHandler(requestContentHandlerV1); | ||
|
|
||
|
|
@@ -321,9 +334,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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.abapgit.adt.ui.internal.repositories; | ||
|
|
||
| import org.eclipse.ui.IViewPart; | ||
| import org.eclipse.ui.IWorkbenchPage; | ||
| import org.eclipse.ui.PlatformUI; | ||
|
|
||
| public class AbapGitViewUtils { | ||
| private static AbapGitViewUtils instance; | ||
|
|
||
| private AbapGitViewUtils() {} | ||
|
|
||
| public static synchronized AbapGitViewUtils getInstance() { | ||
| if (instance == null) { | ||
| instance = new AbapGitViewUtils(); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| public void refreshView() { | ||
| org.eclipse.swt.widgets.Display.getDefault().asyncExec(() -> { | ||
|
||
| IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null | ||
| ? PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() | ||
| : null; | ||
| if (page != null) { | ||
| IViewPart view = page.findView(AbapGitView.ID); | ||
| if (view instanceof AbapGitView) { | ||
| ((AbapGitView) view).refresh(); | ||
|
||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name, could be RELATION_PULL_WITH_BG_RUN