// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java
// public class EgovCompanyConstants {
// 
// 	private EgovCompanyConstants() {}
// 
// 	public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company";
// 
// 	public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin";
// 	public static final String COMPANY_ADMIN_ROLE = "company_admin";
// 	public static final String COMPANY_EMPLOYEE_ROLE = "company_staff";
// 
// 	public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList(
// 			StandardRoles.ROLE_KEY_COMPANY,
// 			COMPANY_SUPER_ADMIN_ROLE,
// 			COMPANY_ADMIN_ROLE,
// 			COMPANY_EMPLOYEE_ROLE
// 	));
// 
// 	public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group";
// 	public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group";
// 	public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList(
// 			CompanyConstants.GROUP_TYPE_COMPANY,
// 			GROUP_TYPE_COMPANY_ADMINS,
// 			GROUP_TYPE_COMPANY_STAFF
// 	));
// 
// 	public static final String CASE_CODE_KEY = "COMPORT";
// 
// 	public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information";
// 
// 	public static final Integer APPLICATION_TYPE_APPROVED = 0;
// 	public static final Integer APPLICATION_TYPE_REJECTED = 1;
// 	public static final Integer APPLICATION_TYPE_UNHANDLED = 2;
// 
// 	public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal";
// 
// 	public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal";
// 	public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins";
// 	public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins";
// 
// 	public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage";
// 	public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage";
// 
// 	public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId";
// 
// 	public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID";
// }
// 
// Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java
// public interface CompanyApplication extends Case, Application {
// 	
// 	public Company getCompany();
// 	
// 	public void setCompany(Company company);
// 	
// 	public User getAdminUser();
// 	
// 	public User getApplicantUser();
// 	
// 	public void setAdminUser(User user);
// 	
// 	public void setApplicantUser(User user);
// 	
// 	public CompanyType getType();
// 	
// 	public void setType(CompanyType type);
// 	
// 	public String getCaseCodeKey();
// 	
// 	public ICFile getContract();
// 	
// 	public void setContract(ICFile contract);
// 	
// }


import is.idega.idegaweb.egov.application.data.Application;
import is.idega.idegaweb.egov.company.EgovCompanyConstants;
import is.idega.idegaweb.egov.company.data.CompanyApplication;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.idega.block.pdf.business.PrintingContext;
import com.idega.block.pdf.business.PrintingContextImpl;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.company.data.Company;
import com.idega.core.location.business.CommuneBusiness;
import com.idega.core.location.data.Commune;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.util.FileUtil;
			setResourceDirectory(FileUtil.getFileAndCreateRecursiveIfNotExists(baseDirectory));
			File file = FileUtil.getFileFromWorkspace(baseDirectory + "company_contract_template.xml");
			setTemplateStream(new FileInputStream(file));
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected String getResourceRealPath(IWBundle iwb, Locale locale) {
		String printFolder = iwb.getApplication().getSettings().getProperty("company_portal.print_contract_folder", "/print/contract/");

		if (locale != null) {
			return iwb.getResourcesRealPath(locale) + printFolder;
		}
		else {
			return iwb.getResourcesRealPath() + printFolder;
		}
	}

	protected FileInputStream getTemplateUrlAsStream(IWBundle iwb, Locale locale, String name, boolean createIfNotExists) throws IOException {
		File template = new File(getTemplateUrl(iwb, locale, name));
		return new FileInputStream(template);
	}

	protected String getTemplateUrl(IWBundle iwb, Locale locale, String name) {
		return getResourceRealPath(iwb, locale) + name;
	}

	private String getBundleIdentifier() {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java
// public class EgovCompanyConstants {
// 
// 	private EgovCompanyConstants() {}
// 
// 	public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company";
// 
// 	public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin";
// 	public static final String COMPANY_ADMIN_ROLE = "company_admin";
// 	public static final String COMPANY_EMPLOYEE_ROLE = "company_staff";
// 
// 	public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList(
// 			StandardRoles.ROLE_KEY_COMPANY,
// 			COMPANY_SUPER_ADMIN_ROLE,
// 			COMPANY_ADMIN_ROLE,
// 			COMPANY_EMPLOYEE_ROLE
// 	));
// 
// 	public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group";
// 	public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group";
// 	public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList(
// 			CompanyConstants.GROUP_TYPE_COMPANY,
// 			GROUP_TYPE_COMPANY_ADMINS,
// 			GROUP_TYPE_COMPANY_STAFF
// 	));
// 
// 	public static final String CASE_CODE_KEY = "COMPORT";
// 
// 	public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information";
// 
// 	public static final Integer APPLICATION_TYPE_APPROVED = 0;
// 	public static final Integer APPLICATION_TYPE_REJECTED = 1;
// 	public static final Integer APPLICATION_TYPE_UNHANDLED = 2;
// 
// 	public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal";
// 
// 	public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal";
// 	public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins";
// 	public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins";
// 
// 	public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage";
// 	public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage";
// 
// 	public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId";
// 
// 	public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID";
// }
// 
// Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java
// public interface CompanyApplication extends Case, Application {
// 	
// 	public Company getCompany();
// 	
// 	public void setCompany(Company company);
// 	
// 	public User getAdminUser();
// 	
// 	public User getApplicantUser();
// 	
// 	public void setAdminUser(User user);
// 	
// 	public void setApplicantUser(User user);
// 	
// 	public CompanyType getType();
// 	
// 	public void setType(CompanyType type);
// 	
// 	public String getCaseCodeKey();
// 	
// 	public ICFile getContract();
// 	
// 	public void setContract(ICFile contract);
// 	
// }


// Path: src/java/is/idega/idegaweb/egov/company/business/CompanyContractPrintingContext.java
import is.idega.idegaweb.egov.application.data.Application;
import is.idega.idegaweb.egov.company.EgovCompanyConstants;
import is.idega.idegaweb.egov.company.data.CompanyApplication;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.idega.block.pdf.business.PrintingContext;
import com.idega.block.pdf.business.PrintingContextImpl;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.company.data.Company;
import com.idega.core.location.business.CommuneBusiness;
import com.idega.core.location.data.Commune;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.util.FileUtil;

			setResourceDirectory(FileUtil.getFileAndCreateRecursiveIfNotExists(baseDirectory));
			File file = FileUtil.getFileFromWorkspace(baseDirectory + "company_contract_template.xml");
			setTemplateStream(new FileInputStream(file));
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected String getResourceRealPath(IWBundle iwb, Locale locale) {
		String printFolder = iwb.getApplication().getSettings().getProperty("company_portal.print_contract_folder", "/print/contract/");

		if (locale != null) {
			return iwb.getResourcesRealPath(locale) + printFolder;
		}
		else {
			return iwb.getResourcesRealPath() + printFolder;
		}
	}

	protected FileInputStream getTemplateUrlAsStream(IWBundle iwb, Locale locale, String name, boolean createIfNotExists) throws IOException {
		File template = new File(getTemplateUrl(iwb, locale, name));
		return new FileInputStream(template);
	}

	protected String getTemplateUrl(IWBundle iwb, Locale locale, String name) {
		return getResourceRealPath(iwb, locale) + name;
	}

	private String getBundleIdentifier() {
		return EgovCompanyConstants.IW_BUNDLE_IDENTIFIER;