package org.cru.godtools.s3;

import com.google.common.base.Strings;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by ryancarlson on 7/11/15.
 */
public class AmazonS3GodToolsConfig
{
	public static final String BUCKET_NAME = "cru-godtools";

	private static final String BASE_URL = "https://s3.amazonaws.com/cru-godtools/";

	private static final String META = "meta/";
	private static final String PACKAGES = "packages/";
	private static final String TRANSLATIONS = "translations/";
	private static final String META_FILE = "meta";
	private static final String ALL_FILE = "all";
	private static final String ALL = "all/";
	private static final String CURRENT = "current/";
	private static final String XML = ".xml";
	private static final String ZIP = ".zip";

	/**
	 * e.g. meta/current/en/kgp/meta.xml  OR
	 *      meta/current/en/meta.xml      OR
	 *      meta/current/meta.xml
	 */
	@Deprecated
	public static String getMetaKey(String languageCode, String packageCode)
	{
		if(!Strings.isNullOrEmpty(languageCode) && !Strings.isNullOrEmpty(packageCode))
		{
			return META + CURRENT + languageCode + "/" + packageCode + "/" + META_FILE + XML;
		}
		if(!Strings.isNullOrEmpty(languageCode))
		{
			return META + CURRENT + languageCode + "/" + META_FILE + XML;
		}

		return META + CURRENT + META_FILE + XML;
	}

	public static String getMetaKeyV2()
	{
		return META + ALL_FILE + XML;
	}

	/**
	 * e.g. packages/current/en/all/en.zip  OR
	 */
	@Deprecated
	public static String getPackagesKey(String languageCode, String packageCode)
	{
		return PACKAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP;
	}

	/**
	 * e.g. translations/current/en/all/en.zip  OR
	 */
	@Deprecated
	public static String getLanguagesKey(String languageCode, String packagesCode)
	{
		return TRANSLATIONS + CURRENT + languageCode + "/" + ALL + languageCode + ZIP;
	}

	/**
	 * e.g. packages/en/all.zip  OR
	 */
	public static String getPackagesKeyV2(String languageCode)
	{
		return PACKAGES + languageCode + "/" + ALL_FILE + ZIP;
	}

	/**
	 * e.g. translations/en/all.zip  OR
	 */
	public static String getTranslationsKeyV2(String languageCode)
	{
		return TRANSLATIONS + languageCode + "/" + ALL_FILE + ZIP;
	}

	/**
	 * e.g. translations/en/kgp.zip
	 */
	public static String getTranslationsAndPackageKeyV2(String languageCode, String packageCode)
	{
		return TRANSLATIONS + languageCode + "/" + packageCode + ZIP;
	}

	public static URL getPackagesRedirectUrl(String languageCode) throws MalformedURLException
	{
		return getPackagesRedirectUrl(languageCode, null);
	}

	public static URL getPackagesRedirectUrl(String languageCode, String packageCode) throws MalformedURLException
	{
		if(Strings.isNullOrEmpty(packageCode))
		{
			return new URL(BASE_URL + PACKAGES + languageCode + "/" + ALL_FILE + ZIP);
		}
		else
		{
			return new URL(BASE_URL + PACKAGES + languageCode + "/" +  packageCode + ZIP);
		}
	}

	public static URL getMetaRedirectUrl() throws MalformedURLException
	{
		return new URL(BASE_URL + META + ALL_FILE + XML);
	}

	public static URL getTranslationsRedirectUrl(String languageCode) throws MalformedURLException
	{
		return getTranslationsRedirectUrl(languageCode, null);
	}

	public static URL getTranslationsRedirectUrl(String languageCode, String packageCode) throws MalformedURLException
	{
		if(Strings.isNullOrEmpty(packageCode))
		{
			return new URL(BASE_URL + TRANSLATIONS + languageCode + "/" + ALL_FILE + ZIP);
		}
		else
		{
			return new URL(BASE_URL + TRANSLATIONS + languageCode + "/" + packageCode + ZIP);
		}
	}
}

@@ -542,1348 +542,183 @@
 ing 
-META_FILE = %22meta%22;%0A%09private static final String ALL_FILE = %22all%22;%0A%09private static final String ALL = %22all/%22;%0A%09private static final String CURRENT = %22current/%22;%0A%09private static final String XML = %22.xml%22;%0A%09private static final String ZIP = %22.zip%22;%0A%0A%09/**%0A%09 * e.g. meta/current/en/kgp/meta.xml  OR%0A%09 *      meta/current/en/meta.xml      OR%0A%09 *      meta/current/meta.xml%0A%09 */%0A%09@Deprecated%0A%09public static String getMetaKey(String languageCode, String packageCode)%0A%09%7B%0A%09%09if(!Strings.isNullOrEmpty(languageCode) && !Strings.isNullOrEmpty(packageCode))%0A%09%09%7B%0A%09%09%09return META + CURRENT + languageCode + %22/%22 + packageCode + %22/%22 + META_FILE + XML;%0A%09%09%7D%0A%09%09if(!Strings.isNullOrEmpty(languageCode))%0A%09%09%7B%0A%09%09%09return META + CURRENT + languageCode + %22/%22 + META_FILE + XML;%0A%09%09%7D%0A%0A%09%09return META + CURRENT + META_FILE + XML;%0A%09%7D%0A%0A%09public static String getMetaKeyV2()%0A%09%7B%0A%09%09return META + ALL_FILE + XML;%0A%09%7D%0A%0A%09/**%0A%09 * e.g. packages/current/en/all/en.zip  OR%0A%09 */%0A%09@Deprecated%0A%09public static String getPackagesKey(String languageCode, String packageCode)%0A%09%7B%0A%09%09return PACKAGES + CURRENT + languageCode + %22/%22 + ALL + languageCode + ZIP;%0A%09%7D%0A%0A%09/**%0A%09 * e.g. translations/current/en/all/en.zip  OR%0A%09 */%0A%09@Deprecated%0A%09public static String getLanguagesKey(String languageCode, String packagesCode)%0A%09%7B%0A%09%09return TRANSLATIONS + CURRENT + languageCode + %22/%22 + ALL + languageCode + ZIP
+ALL_FILE = %22all%22;%0A%09private static final String XML = %22.xml%22;%0A%09private static final String ZIP = %22.zip%22;%0A%0A%09public static String getMetaKeyV2()%0A%09%7B%0A%09%09return META + ALL_FILE + XML
 ;%0A%09%7D

Remove unused