Package org.fluxtream.core.mvc.models

Examples of org.fluxtream.core.mvc.models.StatusModel


                                          @FormParam("attributeKey") String attributeKey,
                                          @FormParam("attributeValue") String attributeValue) throws IOException {
        final ApiKey apiKey = guestService.getApiKey(apiKeyId);
        final String existingValue = guestService.getApiKeyAttribute(apiKey, attributeKey);
        if (existingValue!=null)
            return new StatusModel(false, "This attribute already exists. Please edit the value if you want to change it.");
        guestService.setApiKeyAttribute(apiKey, attributeKey, attributeValue);
        return new StatusModel(true, "attribute was created");
    }
View Full Code Here


    @Produces({MediaType.APPLICATION_JSON})
    public StatusModel deleteApiKeyAttribute(@PathParam("apiKeyId") long apiKeyId,
                                             @QueryParam("attributeKey") String attributeKey) throws IOException {
        attributeKey = URLDecoder.decode(attributeKey, "UTF-8");
        guestService.removeApiKeyAttribute(apiKeyId, attributeKey);
        return new StatusModel(true, "attribute was deleted");
    }
View Full Code Here

    public StatusModel resetConnector(@PathParam("username") String username,
                                      @PathParam("connector") String connectorName) {
        final long guestId = guestService.getGuest(username).getId();
        final ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
        connectorUpdateService.flushUpdateWorkerTasks(apiKey, true);
        return new StatusModel(true, "reset controller " + connectorName);
    }
View Full Code Here

    @Produces({MediaType.APPLICATION_JSON})
    public StatusModel setPassword(@PathParam("username") String username,
                                   @QueryParam("password") String password){
        final long guestId = guestService.getGuest(username).getId();
        guestService.setPassword(guestId, password);
        return new StatusModel(true, "set password for user " + username);
    }
View Full Code Here

    private String sync(final long guestId, final String connectorName, final boolean force) {
        try{
            final ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
            final List<ScheduleResult> scheduleResults = connectorUpdateService.updateConnector(apiKey, force);
            StatusModel statusModel = new StatusModel(true, "successfully added update worker tasks to the queue (see details)");
            statusModel.payload = scheduleResults;
            return gson.toJson(scheduleResults);
        }
        catch (Exception e){
            return gson.toJson(new StatusModel(false,"Failed to schedule update: " + e.getMessage()));
        }
    }
View Full Code Here

            throws InstantiationException, IllegalAccessException,
                   ClassNotFoundException {
        final long guestId = guestService.getGuest(username).getId();
        try {
            final List<ScheduleResult> scheduleResults = connectorUpdateService.updateAllConnectors(guestId, false);
            StatusModel statusModel = new StatusModel(true, "successfully added update worker tasks to the queue (see details)");
            statusModel.payload = scheduleResults;
            return gson.toJson(scheduleResults);
        } catch (Throwable t) {
            StatusModel failure = new StatusModel(false, ExceptionUtils.getStackTrace(t));
            return gson.toJson(failure);
        }
    }
View Full Code Here

            if (apiKey != null) {
                final Map<String,String> atts = apiKey.getAttributes(env);

                return gson.toJson(atts);
            } else {
                StatusModel result = new StatusModel(false,
                                                     "Guest does not have that connector: " + connectorName);
                return gson.toJson(result);
            }
        }
        catch (Exception e){
            return gson.toJson(new StatusModel(false,"Failed to get OAuth Tokens: " + e.getMessage()));
        }
    }
View Full Code Here

                                                   Connector.getConnector(connectorName));
            if (apiKey != null) {
                guestService.setApiKeyAttribute(apiKey, "accessToken", accessToken);
                guestService.setApiKeyAttribute(apiKey, "tokenSecret", tokenSecret);

                StatusModel result = new StatusModel(true,
                                                     "Successfully updated oauth tokens: " + connectorName);
                return gson.toJson(result);
            } else {
                StatusModel result = new StatusModel(false,
                                                     "Guest does not have that connector: " + connectorName);
                return gson.toJson(result);
            }
        }
        catch (Exception e){
            return gson.toJson(new StatusModel(false,"Failed to set OAuth Tokens: " + e.getMessage()));
        }
    }
View Full Code Here

                guestService.setApiKeyAttribute(apiKey, "accessToken", accessToken);
                guestService.setApiKeyAttribute(apiKey, "tokenExpires", tokenExpires);
                guestService.setApiKeyAttribute(apiKey, "refreshTokenRemoveURL", refreshTokenRemoveURL);
                guestService.setApiKeyAttribute(apiKey, "refreshToken", refreshToken);

                StatusModel result = new StatusModel(true,
                                                     "Successfully updated oauth2 tokens: " + connectorName);
                return gson.toJson(result);
            } else {
                StatusModel result = new StatusModel(false,
                                                     "Guest does not have that connector: " + connectorName);
                return gson.toJson(result);
            }
        }
        catch (Exception e){
            return gson.toJson(new StatusModel(false,"Failed to set OAuth2 Tokens: " + e.getMessage()));
        }
    }
View Full Code Here

                              @FormParam("password") String password,
                              @FormParam("email") String email) throws InstantiationException, IllegalAccessException,
                                                                       ClassNotFoundException, UsernameAlreadyTakenException, ExistingEmailException {
        try {
            guestService.createGuest(username, firstname, lastname, password, email, Guest.RegistrationMethod.REGISTRATION_METHOD_FORM, null);
            StatusModel result = new StatusModel(true, "User " + username
                                                       + " was successfully created");
            return gson.toJson(result);
        } catch (Exception e) {
            StatusModel result = new StatusModel(false,
                                                 "Could not create guest: " + e.getMessage());
            return gson.toJson(result);
        }

    }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.mvc.models.StatusModel

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.