Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package nfe.dom; |
| 2 | |||
| 3 | import br.com.samuelweb.certificado.Certificado; |
||
| 4 | import nfe.exception.NfeException; |
||
| 5 | import nfe.util.ConstantesUtil; |
||
| 6 | import nfe.util.Estados; |
||
| 7 | import nfe.util.ProxyUtil; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @author Samuel Oliveira |
||
| 11 | * <p> |
||
| 12 | * Inicia Configurações Nfe. |
||
| 13 | */ |
||
| 14 | public final class ConfiguracoesIniciaisNfe { |
||
| 15 | |||
| 16 | private static ConfiguracoesIniciaisNfe instance; |
||
| 17 | |||
| 18 | private Estados estado; |
||
| 19 | private String ambiente; |
||
| 20 | private Certificado certificado; |
||
| 21 | private String pastaSchemas; |
||
| 22 | private String versaoNfe; |
||
| 23 | private ProxyUtil proxyUtil; |
||
| 24 | private Integer timeout; |
||
| 25 | private boolean contigenciaSCAN; |
||
| 26 | private boolean log = true; |
||
| 27 | |||
| 28 | |||
| 29 | //Construtor Singleton |
||
| 30 | private ConfiguracoesIniciaisNfe() { |
||
| 31 | } |
||
| 32 | |||
| 33 | //Construtor Privado |
||
| 34 | private ConfiguracoesIniciaisNfe(Estados estado, String ambiente, Certificado certificado, String pastaSchemas) { |
||
| 35 | |||
| 36 | instance = new ConfiguracoesIniciaisNfe(); |
||
| 37 | instance.setEstado(estado); |
||
| 38 | instance.setAmbiente(ambiente); |
||
| 39 | instance.setCertificado(certificado); |
||
| 40 | instance.setPastaSchemas(pastaSchemas); |
||
| 41 | instance.setVersaoNfe(ConstantesUtil.VERSAO.NFE); |
||
| 42 | |||
| 43 | } |
||
| 44 | |||
| 45 | public static ConfiguracoesIniciaisNfe iniciaConfiguracoes(Estados estado, String ambiente, Certificado certificado, String pastaSchemas) { |
||
| 46 | new ConfiguracoesIniciaisNfe(estado, ambiente, certificado, pastaSchemas); |
||
| 47 | System.out.println("Api Java Nfe Versão 4.00.2 - Samuel Olivera - samuk.exe@hotmail.com"); |
||
| 48 | System.out.println("Certificado: " + certificado.getTipo().toUpperCase() + " - " + certificado.getNome().toUpperCase() + " - Vencimento: " + certificado.getVencimento()); |
||
| 49 | System.out.println("Ambiente: " + (ambiente.equals("1") ? "Produção" : "Homologação") + " - Estado: " + estado.getNome()); |
||
| 50 | return instance; |
||
| 51 | } |
||
| 52 | |||
| 53 | public static ConfiguracoesIniciaisNfe iniciaConfiguracoes(Estados estado, String ambiente, Certificado certificado, String pastaSchemas, Boolean log) { |
||
| 54 | new ConfiguracoesIniciaisNfe(estado, ambiente, certificado, pastaSchemas); |
||
| 55 | if (log) { |
||
| 56 | System.out.println("Api Java Nfe Versão 4.00.2 - Samuel Olivera - samuk.exe@hotmail.com"); |
||
| 57 | System.out.println("Certificado: " + certificado.getTipo().toUpperCase() + " - " + certificado.getNome().toUpperCase() + " - Vencimento: " + certificado.getVencimento()); |
||
| 58 | System.out.println("Ambiente: " + (ambiente.equals("1") ? "Produção" : "Homologação") + " - Estado: " + estado.getNome()); |
||
| 59 | } |
||
| 60 | return instance; |
||
| 61 | } |
||
| 62 | |||
| 63 | public static ConfiguracoesIniciaisNfe getInstance() throws NfeException { |
||
| 64 | if (instance == null) { |
||
| 65 | throw new NfeException("Configurações Não Foram Inicializadas."); |
||
| 66 | } |
||
| 67 | |||
| 68 | return instance; |
||
| 69 | } |
||
| 70 | |||
| 71 | public void setProxy(String ip, int porta, String usuario, String senha) { |
||
| 72 | proxyUtil = new ProxyUtil(ip, porta, usuario, senha); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return the pastaSchemas |
||
| 77 | */ |
||
| 78 | public String getPastaSchemas() { |
||
| 79 | return pastaSchemas; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param pastaSchemas the pastaSchemas to set |
||
| 84 | */ |
||
| 85 | private void setPastaSchemas(String pastaSchemas) { |
||
| 86 | this.pastaSchemas = pastaSchemas; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return the versaoNfe |
||
| 91 | */ |
||
| 92 | public String getVersaoNfe() { |
||
| 93 | return versaoNfe; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @param versaoNfe the versaoNfe to set |
||
| 98 | */ |
||
| 99 | private void setVersaoNfe(String versaoNfe) { |
||
| 100 | this.versaoNfe = versaoNfe; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @return the ambiente |
||
| 105 | */ |
||
| 106 | public String getAmbiente() { |
||
| 107 | return ambiente; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @param ambiente the ambiente to set |
||
| 112 | */ |
||
| 113 | public void setAmbiente(String ambiente) { |
||
| 114 | this.ambiente = ambiente; |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @return the certificado |
||
| 119 | */ |
||
| 120 | public Certificado getCertificado() { |
||
| 121 | return certificado; |
||
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @param certificado the certificado to set |
||
| 126 | */ |
||
| 127 | public void setCertificado(Certificado certificado) { |
||
| 128 | this.certificado = certificado; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @return configuracao do proxy |
||
| 133 | */ |
||
| 134 | public ProxyUtil getProxy() { |
||
| 135 | return proxyUtil; |
||
| 136 | } |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @return the contigenciaSCAN |
||
| 140 | */ |
||
| 141 | public boolean isContigenciaSCAN() { |
||
| 142 | return contigenciaSCAN; |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @param contigenciaSCAN the contigencia to set |
||
| 147 | */ |
||
| 148 | public void setContigenciaSCAN(boolean contigenciaSCAN) { |
||
| 149 | this.contigenciaSCAN = contigenciaSCAN; |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @return the estado |
||
| 154 | */ |
||
| 155 | public Estados getEstado() { |
||
| 156 | return estado; |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param estado the estado to set |
||
| 161 | */ |
||
| 162 | private void setEstado(Estados estado) { |
||
| 163 | this.estado = estado; |
||
| 164 | } |
||
| 165 | |||
| 166 | public boolean isLog() { |
||
| 167 | return log; |
||
| 168 | } |
||
| 169 | |||
| 170 | public void setLog(boolean log) { |
||
| 171 | this.log = log; |
||
| 172 | } |
||
| 173 | |||
| 174 | public ProxyUtil getProxyUtil() { |
||
| 175 | return proxyUtil; |
||
| 176 | } |
||
| 177 | |||
| 178 | public void setProxyUtil(ProxyUtil proxyUtil) { |
||
| 179 | this.proxyUtil = proxyUtil; |
||
| 180 | } |
||
| 181 | |||
| 182 | public Integer getTimeout() { |
||
| 183 | return timeout; |
||
| 184 | } |
||
| 185 | |||
| 186 | public void setTimeout(Integer timeout) { |
||
| 187 | this.timeout = timeout; |
||
| 188 | } |
||
| 189 | } |