Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Account


        if (isEmpty(message)) {
            return error(ErrorMessages.MISSING_REQUIRED_FIELD + " message", Response.status(Response.Status.BAD_REQUEST));
        }

        Account account;
        try {

            // this will allow the message to be saved in the inbox of the account
            account = applicationManager.getUserService().getAccount(new ObjectId(accountId));
View Full Code Here


    public Response createAccount(JSONObject json) {
        if (getJSON(json, "name") == null) {
            return error("Accounts must have a name", Response.status(Response.Status.BAD_REQUEST));
        }

        Account account = new Account.Builder()
                .name(getJSON(json, "name"))
                .description(getJSON(json, "description"))
                .url(getJSON(json, "url"))
                .build();
        userService.createAccount(account);
View Full Code Here

     */
    @GET
    @Path("{id}")
    public Response getAccount(@PathParam("id") ObjectId accountId) {
        logger.debug("Get accountId " + accountId);
        Account account;
        try {
            account = userService.getAccount(accountId);
        } catch (AccountNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
View Full Code Here

            return error("alias path param can not be empty.", Response.status(Response.Status.BAD_REQUEST));
        }

        logger.debug("Check alias availability for " + alias);

        Account account = null;
        try {
            userService.getAccount(new ObjectId(id));
        } catch (AccountNotFoundException e) {
            return error("Account not found", Response.status(Response.Status.BAD_REQUEST));
        }
View Full Code Here

    @Path("{id}/disable")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response disableAccount(@PathParam("id") ObjectId id) {

        try {
            Account account = userService.getAccount(id);

            // TODO: need a better way to lock this...
            User superUser = userService.getSuperUser();
            if (superUser.getAccount().getId().equals(id)) {
                return error("Cannot disable Nodeable account.", Response.status(Response.Status.BAD_REQUEST));
            }

            account.setConfigValue(Account.ConfigKey.ACCOUNT_LOCKED, true);
            userService.updateAccount(account);
        } catch (AccountNotFoundException e) {
            return error("Account not found.", Response.status(Response.Status.BAD_REQUEST));
        }
        return Response.status(Response.Status.NO_CONTENT).build();
View Full Code Here

    @Path("{id}/enable")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response enableAccount(@PathParam("id") ObjectId id) {

        try {
            Account account = userService.getAccount(id);
            account.setConfigValue(Account.ConfigKey.ACCOUNT_LOCKED, false);
            userService.updateAccount(account);
        } catch (AccountNotFoundException e) {
            return error("Account not found.", Response.status(Response.Status.BAD_REQUEST));
        }
        return Response.status(Response.Status.NO_CONTENT).build();
View Full Code Here

    @Path("{id}/disable/api")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response disableInboundAPIForAccount(@PathParam("id") ObjectId id) {

        try {
            Account account = userService.getAccount(id);

            // TODO: need a better way to lock this...
            User superUser = userService.getSuperUser();
            if (superUser.getAccount().getId().equals(id)) {
                return error("Can not disable Nodeable account.", Response.status(Response.Status.BAD_REQUEST));
            }

            account.setConfigValue(Account.ConfigKey.DISABLE_INBOUND_API, true);
            userService.updateAccount(account);
        } catch (AccountNotFoundException e) {
            return error("Account not found.", Response.status(Response.Status.BAD_REQUEST));
        }
        return Response.status(Response.Status.NO_CONTENT).build();
View Full Code Here

    @Path("{id}/enable/api")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response enableInboundAPIForAccount(@PathParam("id") ObjectId id) {

        try {
            Account account = userService.getAccount(id);
            account.setConfigValue(Account.ConfigKey.DISABLE_INBOUND_API, false);
            userService.updateAccount(account);
        } catch (AccountNotFoundException e) {
            return error("Account not found.", Response.status(Response.Status.BAD_REQUEST));
        }
        return Response
View Full Code Here

     * @resource.representation.200 Returned when the account is successfully deleted
     */
    @DELETE
    @Path("{id}")
    public Response removeAccount(@PathParam("id") ObjectId accountId) {
        Account account = null;
        try {
            account = userService.getAccount(accountId);
        } catch (AccountNotFoundException e) {
            return error("Account not found.", Response.status(Response.Status.BAD_REQUEST));
        }
View Full Code Here

     */
    private void verifyEvent(Event event) {
        Map<String, Object> eventMetadata = event.getMetadata();
        String eventType = (String) eventMetadata.get("targetType");
        User eventUser = null;
        Account eventAccount = null;
        ObjectWithId eventTarget = null;

        // TODO: Bubble the event participants lookup to event service methods

        if (event.getUserId() != null) {
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.Account

Copyright © 2018 www.massapicom. 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.