Greenhouse Documentation

repository·master·Indexed 23 days ago

https://github.com/spring-attic/greenhouse

An open-source Java web application serving as a reference implementation for the Spring ecosystem. It demonstrates the integration of Spring MVC, Security, Integration, Social, and Mobile projects, featuring a badge awarding system via StandardBadgeSystem and client application management through the App class.

Tokens
936
Snippets
3
Records
8
Agent score
80%

What's inside Greenhouse

  1. Run Greenhouse from the command line

    master

    The application can be run in 'embedded' mode using the Tomcat 7 Maven plugin, which is pre-configured in the pom.xml. This mode does not require external servlet container setup.

    1. Execute the Tomcat run command: mvn t7:run
    2. Access the application at http://localhost:8080/greenhouse.
    mvn t7:run
  2. Build Greenhouse from source

    master

    Greenhouse is a Java web application that uses Maven for its build lifecycle. To build the project, clone the repository and run the Maven install command from the project root.

    git clone git://github.com/SpringSource/greenhouse.git
    cd greenhouse
    mvn clean install
  3. Register badge awarders in the StandardBadgeSystem

    master

    The StandardBadgeSystem manages the logic for awarding community participation badges based on user actions. You can register awarders using two primary methods depending on whether you are using typed Action classes or string-based SimpleAction types.

    1. Typed Action Awarders: Use add(BadgeAwarder<? extends Action> badgeAwarder) to register an awarder associated with a specific class of Action. The system uses reflection to resolve the action type from the awarder.
    2. Simple Action Awarders: Use add(SimpleBadgeAwarder badgeAwarder, String simpleActionType) to register an awarder for actions that use a string identifier via SimpleAction.getType().
  4. Access App credentials and configuration

    master

    The App class provides methods to retrieve the configuration used for API interaction:

    • getSummary(): Returns an AppSummary containing a short description of the client application.
    • getApiKey(): Returns the unique identifier used by the client app to identify itself to the server. This must be presented when establishing a connection.
    • getSecret(): Returns the secret used for signature verification. This is specifically required for OAuth 1.0-based client applications.
    • getCallbackUrl(): Returns the URL where the server should redirect a member after authorization. If this returns null, the client application is expected to provide the callbackURL as a parameter during the connection handshake.
  5. Award badges for an action

    master

    To determine if an action qualifies for a badge, call awardBadgeForAction(Action action).

    • If the action is an instance of SimpleAction, the system looks up the awarder using the string returned by SimpleAction.getType().
    • For other action types, the system looks up the awarder based on the specific class of the Action object.

    If no matching awarder is found, the method returns null.

  6. Structure of EventData for event loading

    master

    The EventData class is a data model used to represent event information during the loading or importing process. It encapsulates the necessary fields to define an event, its timeframe, and its origin. When constructing or interacting with EventData, the following fields are available:

    // Fields available in EventData:
    long memberGroupId
    String name
    String description
    String abbreviation
    String firstDay
    String lastDay
    String timeZone
    String source
    long sourceId
  7. Represent a client application with the App class

    master

    The App class represents a client application capable of invoking the Greenhouse server API on behalf of a member. It holds the necessary credentials and configuration required for establishing connections and performing authenticated requests.

    To instantiate an App, you must provide an AppSummary, an apiKey, a secret, and a callbackUrl.