Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.ApiKey


    public abstract List<TimespanModel> getTimespans(long startMillis, long endMillis, ApiKey apiKey, String channelName);

    public abstract List<AbstractFacetVO<AbstractFacet>> getFacetVOs(GuestSettings guestSettings, ApiKey apiKey, String objectTypeName,long start,long end,String value);

    protected long getMinTimeForApiKey(long apiKeyId, Integer objectTypeId){
        ApiKey apiKey = guestService.getApiKey(apiKeyId);

        ObjectType[] objectTypes;
        if (objectTypeId != null)
            objectTypes = apiKey.getConnector().getObjectTypesForValue(objectTypeId);
        else
            objectTypes = apiKey.getConnector().objectTypes();
        if (objectTypes == null || objectTypes.length == 0){
            final String minTimeAtt = guestService.getApiKeyAttribute(apiKey, ApiKeyAttribute.MIN_TIME_KEY);
            if (minTimeAtt !=null && StringUtils.isNotEmpty(minTimeAtt)) {
                final DateTime dateTime = ISODateTimeFormat.dateHourMinuteSecondFraction().withZoneUTC().parseDateTime(minTimeAtt);
                return dateTime.getMillis();
View Full Code Here


        else
            return Long.MAX_VALUE;
    }

    protected long getMaxTimeForApiKey(long apiKeyId, Integer objectTypeId){
        ApiKey apiKey = guestService.getApiKey(apiKeyId);

        ObjectType[] objectTypes;
        if (objectTypeId != null)
            objectTypes = apiKey.getConnector().getObjectTypesForValue(objectTypeId);
        else
            objectTypes = apiKey.getConnector().objectTypes();
        if (objectTypes == null || objectTypes.length == 0){
            final String maxTimeAtt = guestService.getApiKeyAttribute(apiKey, ApiKeyAttribute.MAX_TIME_KEY);
            if (maxTimeAtt !=null && StringUtils.isNotEmpty(maxTimeAtt)) {
                final DateTime dateTime = ISODateTimeFormat.dateHourMinuteSecondFraction().withZoneUTC().parseDateTime(maxTimeAtt);
                return dateTime.getMillis();
View Full Code Here

        catch (IOException e) {e.printStackTrace();}
        return res==200 ? gravatarURL : null;
    }

    public String getFacebookAvatarImageURL(Guest guest) {
        final ApiKey facebook = guestService.getApiKey(guest.getId(), Connector.getConnector("facebook"));
        final String meString = guestService.getApiKeyAttribute(facebook, "me");
        JSONObject meJSON = JSONObject.fromObject(meString);
        final String facebookId = meJSON.getString("id");
        try {
            String avatarURL = String.format("http://graph.facebook.com/%s/picture?type=small&redirect=false&return_ssl_resources=true", facebookId);
View Full Code Here

        catch (IOException e) {e.printStackTrace();}
        return res==200 ? gravatarURL : null;
    }

    public String getFacebookAvatarImageURL(Guest guest) {
        final ApiKey facebook = guestService.getApiKey(guest.getId(), Connector.getConnector("facebook"));
        final String meString = guestService.getApiKeyAttribute(facebook, "me");
        JSONObject meJSON = JSONObject.fromObject(meString);
        final String facebookId = meJSON.getString("id");
        try {
            String avatarURL = String.format("http://graph.facebook.com/%s/picture?type=small&redirect=false&return_ssl_resources=true", facebookId);
View Full Code Here

        }
        Collections.addAll(channelSet, channelNames);
    }

    private void addApiDataUpdate(DataUpdate update, GuestService guestService, final SettingsService settingsService){
        ApiKey api = guestService.getApiKey(update.apiKeyId);
        if (api == null || api.getConnector() == null){
            //This means the specific apikeyid was removed
            return;
        }
        String apiName = api.getConnector().getName();
        List<String> facetNames = new ArrayList<String>();
        if (update.objectTypeId == null){     //TODO: determine if this is ever reached
            System.err.println("Unhandled: objectType = null for DataUpdate");
        }
        else{
            ObjectType[] objectTypes = api.getConnector().getObjectTypesForValue(update.objectTypeId.intValue());
            for(ObjectType objectType : objectTypes){
                facetNames.add(objectType.getName());
            }
        }
        if (facetNames.size() == 0){   //TODO: determine if this is ever reached
            System.err.println("ApiDataUpdate with no facetNames!");
            return;
        }
        if (apiData == null){
            apiData = new HashMap<String,Map<String,TimeBoundariesModel>>();
        }
        Map<String,TimeBoundariesModel> connectorMap = apiData.get(apiName);
        if (connectorMap == null){
            connectorMap = new HashMap<String,TimeBoundariesModel>();
            apiData.put(apiName,connectorMap);
        }
        for (String facetName : facetNames){
            connectorMap.put(facetName,new TimeBoundariesModel(update.startTime,update.endTime));
        }
        if (connectorInfo == null){
            connectorInfo = new HashMap<String,ConnectorDigestModel>();
        }
        if (connectorInfo.get(apiName) == null){
            ConnectorDigestModel model = new ConnectorDigestModel();
            model.apiKeyId = update.apiKeyId;
            model.channelNames = settingsService.getChannelsForConnector(api.getGuestId(),api.getConnector());
            model.prettyName = api.getConnector().getPrettyName();
            model.connectorName = api.getConnector().getName();
            for (ObjectType objectType : api.getConnector().objectTypes())
                model.facetTypes.add(model.connectorName + "-" + objectType.getName());
            connectorInfo.put(apiName,model);
        }

    }
View Full Code Here

    @Produces({MediaType.APPLICATION_JSON})
    public Response getUpdateTasks(@PathParam("connector") String connectorName) {
        try{
            long guestId = AuthHelper.getGuestId();

            ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
            final List<UpdateWorkerTask> scheduledUpdates =
                    connectorUpdateService.getScheduledOrInProgressUpdateTasks(apiKey);
            JSONArray array = new JSONArray();
            for (UpdateWorkerTask scheduledUpdate : scheduledUpdates) {
                array.add(toJSON(scheduledUpdate));
View Full Code Here

            long guestId = AuthHelper.getGuestId();
            final Collection<Connector> connectors = Connector.getAllConnectors();
            JSONArray res = new JSONArray();
            for(Connector c : connectors)
            {
                ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(c.getName()));
                final List<UpdateWorkerTask> scheduledUpdates =
                        connectorUpdateService.getScheduledOrInProgressUpdateTasks(apiKey);
                JSONArray array = new JSONArray();
                for (UpdateWorkerTask scheduledUpdate : scheduledUpdates) {
                    array.add(toJSON(scheduledUpdate));
View Full Code Here

    public Response getObjectTypeUpdateTasks(@PathParam("connector") String connectorName, @PathParam("objectType") String objectTypeName) {
        try{
            long guestId = AuthHelper.getGuestId();
            final Connector connector = Connector.getConnector(connectorName);
            final ObjectType objectType = ObjectType.getObjectType(connector, objectTypeName);
            ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
            final UpdateWorkerTask scheduledUpdate =
                    connectorUpdateService.getUpdateWorkerTask(apiKey, objectType.value());
            return Response.ok(scheduledUpdate!=null?toJSON(scheduledUpdate).toString():"{}").build();
        }
        catch (Exception e){
View Full Code Here

    @Path("/{connector}")
    @Produces({MediaType.APPLICATION_JSON})
    public Response deleteUpdateTasks(@PathParam("connector") String connectorName) {
        try{
            long guestId = AuthHelper.getGuestId();
            ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
            connectorUpdateService.flushUpdateWorkerTasks(apiKey, false);
            return Response.ok("successfully deleted pending update tasks for " + connectorName).build();
        }
        catch (Exception e){
            return Response.serverError().entity("Failed to get update tasks: " + e.getMessage()).build();
View Full Code Here

    public Response getUpdates(@PathParam("connector") String connectorName,
                               @QueryParam("pageSize") int pageSize,
                               @QueryParam("page") int page) {
        try {
            long guestId = AuthHelper.getGuestId();
            final ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
            final List<ApiUpdate> updates = connectorUpdateService.getUpdates(apiKey, pageSize, page);
            final ApiUpdatesModel updatesModel = new ApiUpdatesModel(connectorName,
                    updates, !nonRepeatableUpdateQueriesConnectors.contains(connectorName));
            return Response.ok(gson.toJson(updatesModel)).build();
        }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.domain.ApiKey

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.