package com.cloudmine.api.rest;

import com.cloudmine.api.CMApiCredentials;
import com.cloudmine.api.CMSessionToken;
import com.cloudmine.api.DeviceIdentifier;
import com.cloudmine.api.Strings;
import org.apache.http.Header;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * <br>
 * Copyright CloudMine LLC. All rights reserved<br>
 * See LICENSE file included with SDK for details.
 */
public class AndroidHeaderFactory extends JavaHeaderFactory {
    public static final String CLOUD_MINE_AGENT = "Android/0.6";

    private static Map<String, String> DEFAULT_HEADERS = new HashMap<String, String>();
    static {
        DEFAULT_HEADERS.put(AGENT_HEADER_KEY, CLOUD_MINE_AGENT);
    }

    public static Map<String, String> getHeaderMapping(String sessionTokenString) {
        Map<String, String> headerMap = new HashMap<String, String>(DEFAULT_HEADERS);
        headerMap.put(HeaderFactory.DEVICE_HEADER_KEY, getDeviceHeaderValue());
        headerMap.put(HeaderFactory.API_HEADER_KEY, CMApiCredentials.getApplicationApiKey()); //worry about sync issues? not now but could be an issue

        if(Strings.isNotEmpty(sessionTokenString)) headerMap.put(HeaderFactory.SESSION_TOKEN_HEADER_KEY, sessionTokenString);
        return headerMap;
    }

    public static Map<String, String> getHeaderMapping(CMSessionToken sessionToken) {
        String sessionTokenString = sessionToken == null ? null : sessionToken.getSessionToken();
        return getHeaderMapping(sessionTokenString);
    }


    private static String getDeviceHeaderValue() {
        String deviceId = DeviceIdentifier.getUniqueId();
        String timingHeaders = ResponseTimeDataStore.getContentsAsStringAndClearMap();
        String deviceHeaderValue = deviceId;
        if(Strings.isNotEmpty(timingHeaders)) deviceHeaderValue += "; " + timingHeaders;
        return deviceHeaderValue;
    }

    @Override
    public Set<Header> getCloudMineHeaders() {
        Set<Header> headers = super.getCloudMineHeaders();
        return headers;
    }

    protected String getDeviceIdentifier() {
        return DeviceIdentifier.getUniqueId();
    }

    @Override
    public String getCloudMineAgent() {
        return CLOUD_MINE_AGENT;
    }
}

@@ -190,39 +190,8 @@
 ngs;
-%0Aimport org.apache.http.Header;
 %0A%0Aim
@@ -239,30 +239,8 @@
 Map;
-%0Aimport java.util.Set;
 %0A%0A/*
@@ -480,16 +480,18 @@
 roid/0.6
+.1
 %22;%0A%0A    
@@ -1840,159 +1840,8 @@
  %7D%0A%0A
-    @Override%0A    public Set%3CHeader%3E getCloudMineHeaders() %7B%0A        Set%3CHeader%3E headers = super.getCloudMineHeaders();%0A        return headers;%0A    %7D%0A%0A
     

Remove overrided method that wasn't doing anything