Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Download setup-file from GitLab
Download setup-file from GitLab [message #1863355] Mon, 29 January 2024 11:12 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

I'm trying to get a setup file using GitLab API https://docs.gitlab.com/ee/api/repository_files.html

And I use such an URL:

https://gitlab.example.com/api/v4/projects/[project_id]/repository/files/[path_to_setup_file]/raw?private_token=[token]

The setup file can be successfully downloaded, but Eclipse Installer throws the exception:

java.lang.ClassCastException: class org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl cannot be cast to class org.eclipse.oomph.base.util.BaseResource (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @58dea0a5; org.eclipse.oomph.base.util.BaseResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @7446d8d5)
        at org.eclipse.oomph.base.util.BaseUtil.loadResourceSafely(BaseUtil.java:97)
        at org.eclipse.oomph.setup.internal.installer.ProductPage$AddUserProductDialog.processResources(ProductPage.java:2073)
        at org.eclipse.emf.common.ui.dialogs.ResourceDialog.okPressed(ResourceDialog.java:372)
        at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:468)
        at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:619)
        at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84)
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5854)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1529)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5064)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4516)
        at org.eclipse.jface.window.Window.runEventLoop(Window.java:823)
        at org.eclipse.jface.window.Window.open(Window.java:799)
        at org.eclipse.oomph.setup.internal.installer.ProductPage$15.widgetSelected(ProductPage.java:591)
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5854)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1529)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5064)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4516)
        at org.eclipse.oomph.setup.internal.installer.Installer.runEventLoop(Installer.java:359)
        at org.eclipse.oomph.setup.internal.installer.InstallerDialog.show(InstallerDialog.java:434)
        at org.eclipse.oomph.setup.internal.installer.InstallerApplication.run(InstallerApplication.java:295)
        at org.eclipse.oomph.setup.internal.installer.InstallerApplication.start(InstallerApplication.java:401)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1432)


I guess the cause is a wrong file name - raw (because the last segment of URL is raw). The file doesn't have setup extension. Could you suggest a workaround?
Re: Download setup-file from GitLab [message #1863356 is a reply to message #1863355] Mon, 29 January 2024 11:27 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
I don't know how to debug it in Eclipse Installer. I run it with -debug argument, but it doesn't give any details on file downloading.

If I get the file using curl, then GitLab returns the following headers:

content-type: text/plain; charset=utf-8
content-length: 206471
content-disposition: inline; filename="ide.setup"; filename*=UTF-8''ide.setup


It seems to be ok...
Re: Download setup-file from GitLab [message #1863359 is a reply to message #1863356] Mon, 29 January 2024 13:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
Yes that just won't work because the correct resource factory is registered against the file extension. Eclipse GitLab supports URLs like this:

https://gitlab.eclipse.org/eclipse/ease/ease/-/raw/main/releng/org.eclipse.ease.releng/oomph/ease.setup

I don't suppose that's possible? If there is some example URL that I can access to see if perhaps there is a simple way to support such a URL, I could give that a try. But I need a "test case" URL...

To debug you'd need to setup up an IDE and debug launch the installer:

https://github.com/eclipse-oomph/oomph/blob/master/CONTRIBUTING.md

It might work to register the factory against, null...

https://github.com/eclipse-oomph/oomph/blob/152a741028834f4aee1172db672a5fc286616e7d/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java#L122-L136


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Download setup-file from GitLab [message #1863360 is a reply to message #1863359] Mon, 29 January 2024 13:23 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
You can use the following URL as an example:

https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw

Or even this one to be sure that private_token param doesn't affect anything:

https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw?private_token=

The private_token can be empty (if the repository allows anonymous access) or you can generate it here:

https://gitlab.eclipse.org/-/user_settings/personal_access_tokens

Yes, probably one option is to register a fallback resource factory. Maybe one more option is to get somehow a filename from Content-Disposition HTTP header...
Re: Download setup-file from GitLab [message #1863365 is a reply to message #1863360] Mon, 29 January 2024 16:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
Very good. I'll have a look. But still the question, doesn't a URI like https://gitlab.eclipse.org/eclipse/ease/ease/-/raw/main/releng/org.eclipse.ease.releng/oomph/ease.setup work in your case?

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Download setup-file from GitLab [message #1863369 is a reply to message #1863365] Mon, 29 January 2024 16:28 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Yes, such a link works fine. But only if the project is public and doesn't require authentication.

Otherwise it redirects to a login form with 302 HTTP status code (instead of 403), so Eclipse Installer doesn't show any login dialog.
Re: Download setup-file from GitLab [message #1863373 is a reply to message #1863369] Tue, 30 January 2024 07:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
You're sure the token query parameter doesn't work for that URI as well? Another thing to try is the direct URI but like this:

https://raw.githubusercontent.com/merks/xxx/master/setups/xx.setup?oomph_basic_auth=true

The oomph_basic_auth=true query parameter should prompt for your user ID and "password" where the password is actually the personal access token now. I use this for my setups in my private github repos. It has the advantage that the password/PAT is stored in secure storage and not surfaced anywhere that might expose it.

Please give that a try.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Download setup-file from GitLab [message #1863380 is a reply to message #1863373] Tue, 30 January 2024 10:41 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
I've tried to use an URL with ?oomph_basic_auth=true
But Eclipse Installer gives the following error: "The URI ... doesn't contain a valid product."

Tried to get a file using curl:

curl -u 'login:password' https://...
curl -u 'login:token' https://...
curl https://login:password@...
curl https://login:token@...

It doesn't work, just redirects to a login form.

It seems that GitLab doesn't support basic authentication. Here is an open issue https://gitlab.com/gitlab-org/gitlab/-/issues/19189
And also basic auth is not mentioned in documentation: https://docs.gitlab.com/ee/administration/auth/

I guess that files can only be downloaded using API from private GitLab repositories:

Either with Private-Token header:

curl --header 'Private-Token: TOKEN' 'https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw'

or with ?private_token= query parameter:

curl 'https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw?private_token=TOKEN'
Re: Download setup-file from GitLab [message #1863439 is a reply to message #1863380] Fri, 02 February 2024 14:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
Sorry, I've been very busy. Could you please open an issue here:

https://github.com/eclipse-oomph/oomph/issues

Looking at things like this I still get the sense that it ought to work:

https://stackoverflow.com/questions/25409700/using-gitlab-token-to-clone-without-authentication


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Download setup-file from GitLab [message #1863442 is a reply to message #1863439] Fri, 02 February 2024 16:03 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
I've opened an issue https://github.com/eclipse-oomph/oomph/issues/64

Yes, I thought about such an URL too:

git clone https://oauth2:ACCESS_TOKEN@gitlab.eclipse.org/eclipse/ease/ease.git

But I think that it can be used only to clone a repository, not to download a specific file
Re: Download setup-file from GitLab [message #1864849 is a reply to message #1863355] Mon, 15 April 2024 07:39 Go to previous message
Taevion Lucas is currently offline Taevion LucasFriend
Messages: 1
Registered: April 2024
Junior Member
You should see the name of the file in the list shown. Your image is added to your branch in your repository in GitLab.
Previous Topic:Git LFS Error
Goto Forum:
  


Current Time: Tue May 07 21:29:04 GMT 2024

Powered by FUDForum. Page generated in 0.04842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top