<commit_before>package com.instructure.canvasapi.api;

import android.content.Context;
import android.net.Uri;
import android.util.Log;

import com.instructure.canvasapi.model.CanvasContext;
import com.instructure.canvasapi.model.KalturaConfig;
import com.instructure.canvasapi.model.KalturaSession;
import com.instructure.canvasapi.model.kaltura.xml;
import com.instructure.canvasapi.utilities.APIHelpers;
import com.instructure.canvasapi.utilities.CanvasCallback;
import com.instructure.canvasapi.utilities.CanvasRestAdapter;
import com.instructure.canvasapi.utilities.FileUtilities;
import com.instructure.canvasapi.utilities.KalturaRestAdapter;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.File;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.http.EncodedQuery;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.Query;

/**
 * Created by <NAME> on 5/22/14.
 * <p/>
 * Copyright (c) 2014 Instructure. All rights reserved.
 */

//Make caching work
public class KalturaAPI {
    private static String getKalturaConfigCache() {
        return "/services/kaltura";
    }
    //Interface talking to Canvas servers
    public interface KalturaConfigInterface {
        @GET("/services/kaltura")
        void getKalturaConfigaration(Callback<KalturaConfig> callback);

        @POST("/services/kaltura_session")
        void startKalturaSession(Callback<KalturaSession> callback);

    }
    //Interface talking to Kaltura servers
    public interface KalturaAPIInterface {

        @POST("/index.php?service=uploadToken&action=add")
        void getKalturaUploadToken(@Query("ks") String ks, Callback<xml> callback);


        @POST("/index.php?service=media&action=addFromUploadedFile")
        xml getMediaIdForUploadedFileTokenSynchronous(@Query("ks") String ks, @Query("uploadTokenId") String uploadToken, @EncodedQuery("mediaEntry:name") String name, @EncodedQuery("mediaEntry:mediaType") String mediaType);

    }
    private static KalturaConfigInterface buildKalturaConfigInterface(CanvasCallback<?> callback, CanvasContext canvasContext) {
        RestAdapter restAdapter = CanvasRestAdapter.buildAdapter(callback, canvasContext);
        return restAdapter.create(KalturaConfigInterface.class);
    }

    private static KalturaAPIInterface buildKalturaAPIInterface(CanvasCallback<?> callback) {
        RestAdapter restAdapter = KalturaRestAdapter.buildAdapter(callback);
        return restAdapter.create(KalturaAPIInterface.class);
    }

    public static void getKalturaConfiguration(final CanvasCallback<KalturaConfig> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        callback.readFromCache(getKalturaConfigCache());
        buildKalturaConfigInterface(callback, null).getKalturaConfigaration(callback);
    }

    public static void startKalturaSession(final CanvasCallback<KalturaSession> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        //callback.readFromCache(getAssignmentCacheFilename(courseID, assignmentID));
        buildKalturaConfigInterface(callback, null).startKalturaSession(callback);
    }

    public static void getKalturaUploadToken(final CanvasCallback<xml> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        String kalturaToken = APIHelpers.getKalturaToken(callback.getContext());

        //callback.readFromCache(getAssignmentCacheFilename(courseID, assignmentID));<commit_msg>Missed some comments.<commit_after>package com.instructure.canvasapi.api;

import android.content.Context;
import android.net.Uri;
import android.util.Log;

import com.instructure.canvasapi.model.CanvasContext;
import com.instructure.canvasapi.model.KalturaConfig;
import com.instructure.canvasapi.model.KalturaSession;
import com.instructure.canvasapi.model.kaltura.xml;
import com.instructure.canvasapi.utilities.APIHelpers;
import com.instructure.canvasapi.utilities.CanvasCallback;
import com.instructure.canvasapi.utilities.CanvasRestAdapter;
import com.instructure.canvasapi.utilities.FileUtilities;
import com.instructure.canvasapi.utilities.KalturaRestAdapter;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.File;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.http.EncodedQuery;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.Query;

/**
 * Created by <NAME> on 5/22/14.
 * <p/>
 * Copyright (c) 2014 Instructure. All rights reserved.
 */

//Make caching work
public class KalturaAPI {
    private static String getKalturaConfigCache() {
        return "/services/kaltura";
    }
    //Interface talking to Canvas servers
    public interface KalturaConfigInterface {
        @GET("/services/kaltura")
        void getKalturaConfigaration(Callback<KalturaConfig> callback);

        @POST("/services/kaltura_session")
        void startKalturaSession(Callback<KalturaSession> callback);

    }
    //Interface talking to Kaltura servers
    public interface KalturaAPIInterface {

        @POST("/index.php?service=uploadToken&action=add")
        void getKalturaUploadToken(@Query("ks") String ks, Callback<xml> callback);


        @POST("/index.php?service=media&action=addFromUploadedFile")
        xml getMediaIdForUploadedFileTokenSynchronous(@Query("ks") String ks, @Query("uploadTokenId") String uploadToken, @EncodedQuery("mediaEntry:name") String name, @EncodedQuery("mediaEntry:mediaType") String mediaType);

    }
    private static KalturaConfigInterface buildKalturaConfigInterface(CanvasCallback<?> callback, CanvasContext canvasContext) {
        RestAdapter restAdapter = CanvasRestAdapter.buildAdapter(callback, canvasContext);
        return restAdapter.create(KalturaConfigInterface.class);
    }

    private static KalturaAPIInterface buildKalturaAPIInterface(CanvasCallback<?> callback) {
        RestAdapter restAdapter = KalturaRestAdapter.buildAdapter(callback);
        return restAdapter.create(KalturaAPIInterface.class);
    }

    public static void getKalturaConfiguration(final CanvasCallback<KalturaConfig> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        callback.readFromCache(getKalturaConfigCache());
        buildKalturaConfigInterface(callback, null).getKalturaConfigaration(callback);
    }

    public static void startKalturaSession(final CanvasCallback<KalturaSession> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        buildKalturaConfigInterface(callback, null).startKalturaSession(callback);
    }

    public static void getKalturaUploadToken(final CanvasCallback<xml> callback) {
        if (APIHelpers.paramIsNull(callback)) {
            return;
        }

        String kalturaToken = APIHelpers.getKalturaToken(callback.getContext());

{'fraction_non_alphanumeric': 0.09729381443298969, 'fraction_numerical': 0.0023195876288659794, 'mean_word_length': 4.640261627906977, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270063', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2188, 'n_words': 381}