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 @@ -145,6 +145,7 @@ public class Messages extends NLS {
public static String AbapGitWizardPageSwitch_credentials_description;
public static String AbapGitWizardSwitch_branch_wizard_title;
public static String AbapGitWizardSwitch_branch_package_ref_not_found_error;
public static String AbapGitWizardPageTransportSelection_transport_check;

//ABAPGIT STAGING MESSAGES
public static String AbapGitStaging_no_repository_selected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ AbapGitWizardPageRepositoryAndCredentials_title=Link abapGit Repository
AbapGitWizardPageRepositoryAndCredentials_validate_password_error=Specify password or personal access token
AbapGitWizardPageRepositoryAndCredentials_validate_url_error=Enter a valid Git URL
AbapGitWizardPageRepositoryAndCredentials_validate_user_error=Specify user
AbapGitWizardPageTransportSelection_transport_check=Performing Transport Checks..
AbapGitWizardSwitch_branch_package_ref_not_found_error=Could not find package ref for {0}

AbapGitStaging_no_repository_selected=No Repository Selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import com.sap.adt.communication.resources.ResourceException;
import com.sap.adt.compatibility.exceptions.OutDatedClientException;
import com.sap.adt.tools.core.model.adtcore.IAdtCoreFactory;
import com.sap.adt.tools.core.model.adtcore.IAdtObjectReference;
import com.sap.adt.tools.core.project.AdtProjectServiceFactory;
Expand All @@ -43,6 +45,7 @@
import com.sap.adt.transport.IAdtTransportService;
import com.sap.adt.transport.ui.wizard.AdtTransportSelectionWizardPageFactory;
import com.sap.adt.transport.ui.wizard.IAdtTransportSelectionWizardPage;
import com.sap.adt.util.ui.AdtUtilUiPlugin;

/**
* This is wizard that handles pull action on a repository. Includes selective
Expand Down Expand Up @@ -303,22 +306,12 @@ public void handlePageChanging(final PageChangingEvent event) {

//-> Prepare transport page
if (event.getTargetPage() == AbapGitWizardPull.this.transportPage) {
try {
// The transport service requires URIs to objects we want to create in the
// target package.
// However, we do not know these URIs from the client.
// Instead, give it the URI of the package in which we clone.
IAdtObjectReference packageRef = AbapGitWizardPull.this.cloneData.packageRef;
IAdtObjectReference checkRef = IAdtCoreFactory.eINSTANCE.createAdtObjectReference();
checkRef.setUri(packageRef.getUri());
IAdtTransportCheckData checkData = AbapGitWizardPull.this.transportService.check(checkRef, packageRef.getPackageName(),
true);
AbapGitWizardPull.this.transportPage.setCheckData(checkData);
} catch (Exception e) {
AbapGitWizardPull.this.pageBranchAndPackage.setMessage(e.getMessage(), DialogPage.ERROR);
}
IAdtObjectReference packageRef = AbapGitWizardPull.this.cloneData.packageRef;
IAdtTransportCheckData transportCheckData = getTransportCheckData(packageRef);
AbapGitWizardPull.this.transportPage.setCheckData(transportCheckData);
}


//-> APACK page -> Any page
if (event.getCurrentPage() == AbapGitWizardPull.this.pageApack) {
if (!AbapGitWizardPull.this.pageApack.validateAll()) {
Expand All @@ -327,5 +320,55 @@ public void handlePageChanging(final PageChangingEvent event) {
}
}
}

private IAdtTransportCheckData getTransportCheckData(IAdtObjectReference packageRef) {

IAdtObjectReference checkRef = IAdtCoreFactory.eINSTANCE.createAdtObjectReference();
checkRef.setUri(packageRef.getUri());

final IAdtTransportCheckData[] checkData = new IAdtTransportCheckData[1];

try {
getContainer().run(true, true, monitor -> {
monitor.beginTask(Messages.AbapGitWizardPageTransportSelection_transport_check, IProgressMonitor.UNKNOWN);
checkData[0] = AbapGitWizardPull.this.transportService.check(checkRef, packageRef.getPackageName(), true);
});
return checkData[0];

} catch (Exception e) {
// Catches InterruptedException and other general exceptions
WizardPage currentPage = ((WizardPage) getContainer().getCurrentPage());
handleException(e, currentPage);
return null;
}
}

private void handleOutdatedClientException(Throwable e) {

Display.getDefault().asyncExec(() -> {
WizardDialog d = (WizardDialog) getContainer();
Copy link
Collaborator

Choose a reason for hiding this comment

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

d -> dialog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure


if (d != null) {
// Check if the dialog is still open before attempting to close
if (d.getShell() != null && !d.getShell().isDisposed()) {
d.close();
AdtUtilUiPlugin.getDefault().getAdtStatusService().handle(e, null);
}
}
});

}

private void handleException(Exception exception, WizardPage page) {

page.setPageComplete(false);
Throwable cause = exception instanceof InvocationTargetException ? exception.getCause() : exception;
if (cause != null && cause instanceof OutDatedClientException) {
handleOutdatedClientException(cause);
} else {
page.setMessage(cause != null ? cause.getMessage() : exception.getMessage(), DialogPage.ERROR);
}
}

}
}