Package com.atlassian.labs.speakeasy.rest

Source Code of com.atlassian.labs.speakeasy.rest.SettingsResource

package com.atlassian.labs.speakeasy.rest;

import com.atlassian.labs.speakeasy.external.SpeakeasyService;
import com.atlassian.labs.speakeasy.external.UnauthorizedAccessException;
import com.atlassian.labs.speakeasy.model.Settings;
import com.atlassian.sal.api.user.UserManager;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;

/**
*
*/
@Path("/admin/settings")
public class SettingsResource
{
    private final SpeakeasyService speakeasyService;
    private final UserManager userManager;

    public SettingsResource(SpeakeasyService speakeasyService, UserManager userManager)
    {
        this.speakeasyService = speakeasyService;
        this.userManager = userManager;
    }

    @GET
    @Produces("application/json")
    public Response getSettings() throws UnauthorizedAccessException
    {
        final Settings settings = speakeasyService.getSettings(userManager.getRemoteUsername());
        return Response.ok(settings).tag(String.valueOf(settings.hashCode())).build();
    }

    @PUT
    @Produces("application/json")
    public Response save(Settings settings) throws UnauthorizedAccessException
    {
        return Response.ok(speakeasyService.saveSettings(settings, userManager.getRemoteUsername())).build();
    }
}
TOP

Related Classes of com.atlassian.labs.speakeasy.rest.SettingsResource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.