Skip to content

Latest commit

 

History

History
162 lines (122 loc) · 6.66 KB

File metadata and controls

162 lines (122 loc) · 6.66 KB

The DAWN Marketplace Server

Everything the server requires to start is contained within the *.war-file. In addition data is held in three different folders that all will be created when the server first starts.

  • database - Holds the server's two databases. One for "solution" data with is serialized using Eclipse Teneo. The other is the system database for user accounts and such.
  • pages - Static content in the form of Markdown formatted files and images.
  • solutions - Solution data. Subfolders are created for each solution using it's identifier. Within these; images and screenshots are stored and an additional folder for the Equinox p2-repository.

Usage

Starting the server

When doing development on this code, you should start the server from within Eclipse. That will allow you to do normal debugging. Make sure the Spring tool suite is installed and launch the org.dawnsci.marketplace.server project as a Spring Boot App

When running the standalone server you need to start it from the command line. E.g. java -jar org.dawnsci.marketplace.server-1.0-SNAPSHOT.war

If the following files are not in place, they will be created. The folder named pages must contain:

  • welcome.md - The welcome text.
  • marketplace-icon - The marketplace icon
  • catalog.icon - The catalog icon

Creating an initial data set

When starting the server a folder named solutions will be created next to the *.jar file, or in the project root when running from the IDE. This contains all file resources for a sample solution, including one plug-in that can be installed.

The data that is loaded can be found in src/main/resources/data. A similar set is found in src/test/resources/data.

Configuring the server

The server configuration is mainly done in a file named application.yml. If the default values must be overridden, this can be done by adding it as a sibling to the *.war file and specify properties in the YAML format. Typical values include:

marketplace:
	base-url: http://localhost:8080
	title: DAWN Plug-in Marketplace
	icon: http://localhost:8080/pages/marketplace-icon.png
	description: The DAWN Plug-in Marketplace
	wizard-title: DAWN Plug-in Catalog
	wizard-icon: http://localhost:8080/pages/catalog-icon.png
	featured:
		maximum: 3
		solutions: 1, 2, 3

All configuration parameters can be controlled from the command line, for example --marketplace.featured.solutions=1,10,12 will specify the list of featured solutions.

There is a separate set of properties used when testing.

Social integration

It is possible to sign in using a Twitter, Google or Github account. For testing purposes one application of each type has been created and configured on the server.

Since the Twitter application registration requires a fully qualified DNS you must in addition add an entry to /etc/hosts when testing:

127.0.0.1       localhost.com

See the server configuration for OAuth secrets and identifiers.

Logging in

An administrative user will be automatically created. The login of this user is "admin" and the password is an UUID automatically generated when starting. This value can be found in the log. It is possible to specify a password for this user in the configuration file using the property marketplace.admin-password.

Adding a solution

  • In order to create a new solution, the logged in user must belong to the UPLOAD group. This is not set per default when a new user is created, so an administrator must assign this role to users.
  • When uploading a solution p2-repository; either using the web-interface or the REST-API, the update site property of the solution will be changed to point to /files/<solution-id>.

The REST API

The REST API is an important part for communicating with the marketplace client that comes as a part of Eclipse. Not all of it is currently implemented, but it can be exercised from within Eclipse in a way that is useful.

Note that this implementation of the server currently prefix all REST calls with "mpc". So for instance getting details of a particular product will look like this: http://localhost:8080/mpc/node/123/api/p.

Supported REST calls

The Eclipse reference implementation provisional API will be identified by ´/api/p´ at the end of most urls. Those that are checked have been fully implemented.

  • /api/p - Returns Markets + Categories
  • /catalogs/api/p - Returns a listing of all catalogs that are browsable with the MPC.
  • /node/%/api/p OR /content/%/api/p - Returns a single listing's detail
  • /taxonomy/term/%/api/p - Returns a category listing of results
  • /featured/api/p - Returns a server-defined number of featured results
  • /recent/api/p - Returns a server-defined number of recent updates
  • /favorites/top/api/p - Returns a server-defined number of top favorites
  • /popular/top/api/p - Returns a server-defined number of most active results
  • /related/api/p - Returns a server-defined number of recommendations based on a list of nodes provided as query parameter
  • /news/api/p - Returns an empty news configuration

There is one exception to adding /api/p at the end and that is for search results.

  • /api/p/search/apachesolr_search/[query]?page=[]&filters=[] - Returns search result from the Solr Search DB.

Extended REST API

This part of the API is different from reference implementation as it has been added to support uploading of solutions and related files such as screenshots and p2-repositories.

  • /token- Returns a CSRF token to use in further communication
  • /upload- Uploads a new or existing solution
  • /upload-p2repo- Uploads a p2-repository for a solution
  • /upload-screenshot- Uploads a screenshot for a solution
  • /upload-image- Uploads a logo image for a solution

Most of these methods take the id parameter and some a file. See the ExtendedRestApiController for details.

Serving Static content

Static content, such as the welcome text and user guide should be placed in the pages folder. These files must be written in the Markdown format. Links can be written as for example [user guide](/pages/user_guide.md), which will link to a Markdown file that will be rendered as HTML. It is also possible to link to other resources:

  • /pages/eclipse.png an image file.
  • /content/123 the solution with the identifier "123"
  • /files/123/screenshot.png a file belonging to the solution.