| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Sync |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * Copyright 2008 WebPhotos | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | /* | |
| 17 | * Sync.java | |
| 18 | * | |
| 19 | * Created on 23 de Maio de 2006, 11:40 | |
| 20 | * | |
| 21 | * To change this template, choose Tools | Template Manager | |
| 22 | * and open the template in the editor. | |
| 23 | */ | |
| 24 | ||
| 25 | package net.sf.webphotos.sync; | |
| 26 | ||
| 27 | import java.io.IOException; | |
| 28 | import java.io.InputStream; | |
| 29 | import java.io.OutputStream; | |
| 30 | import java.util.ArrayList; | |
| 31 | import net.sf.webphotos.util.legacy.Arquivo; | |
| 32 | import org.apache.commons.net.ftp.FTPFile; | |
| 33 | import org.apache.commons.net.io.CopyStreamListener; | |
| 34 | ||
| 35 | /** | |
| 36 | * Interface que especifica como webfotos irá | |
| 37 | * sincronizar arquivos. | |
| 38 | * @author guilherme | |
| 39 | */ | |
| 40 | public interface Sync { | |
| 41 | ||
| 42 | /** | |
| 43 | * Retorna um InputStream para o arquivo específico. | |
| 44 | * @param arquivo Nome do arquivo. | |
| 45 | * @return Retorna um InputStream. | |
| 46 | * @throws java.io.IOException Erro durante transmissão de I/O. | |
| 47 | */ | |
| 48 | InputStream retrieveFileStream(String arquivo) throws IOException; | |
| 49 | /** | |
| 50 | * Retorna um OutputStream para o arquivo específico. | |
| 51 | * @param arquivo Nome do arquivo. | |
| 52 | * @return Retorna um OutputStream. | |
| 53 | * @throws java.io.IOException Erro durante transmissão de I/O. | |
| 54 | */ | |
| 55 | OutputStream storeFileStream(String arquivo) throws IOException; | |
| 56 | /** | |
| 57 | * Faz a transferência de um arquivo. | |
| 58 | * @param streamOrigem Arquivo de origem. | |
| 59 | * @param streamDestino Local de destino. | |
| 60 | * @param streamSize Tamanho do arquivo. | |
| 61 | * @throws java.io.IOException Problemas na leitura e escrita dos dados. | |
| 62 | */ | |
| 63 | void transferFile(InputStream streamOrigem, OutputStream streamDestino, long streamSize) throws IOException; | |
| 64 | /** | |
| 65 | * Deleta um arquivo especificado pelos parãmetros. | |
| 66 | * @param string Nome do arquivo. | |
| 67 | * @return Retorna uma confirmação de exclusão. | |
| 68 | * @throws java.io.IOException Erro durante transmissão de I/O. | |
| 69 | */ | |
| 70 | boolean deleteFile(String string) throws IOException; | |
| 71 | ||
| 72 | /** | |
| 73 | * Muda o diretório. | |
| 74 | * @param diretorioFilho Diretório que deve ser acessado. | |
| 75 | * @throws java.io.IOException Erro de sincronização. | |
| 76 | * @throws net.sf.webphotos.sync.SyncException Erro de comunicação entre os dados. | |
| 77 | */ | |
| 78 | void cd(String diretorioFilho) throws IOException, SyncException; | |
| 79 | /** | |
| 80 | * Cria um novo subdiretório no diretório utilizado. | |
| 81 | * @param pathName O nome do diretório a ser criado. | |
| 82 | * @throws java.io.IOException Se um erro de I/O ocorrer enquanto está sendo enviado | |
| 83 | * um comando ao servidor ou recebendo uma resposta do servidor. | |
| 84 | * @return Retorna <I>true</I> caso ocorra com sucesso. | |
| 85 | */ | |
| 86 | boolean makeDirectory(String pathName) throws IOException; | |
| 87 | /** | |
| 88 | * Muda o diretório de trabalho baseado no novo passado como parâmetro. | |
| 89 | * @param pathName Novo diretório de trabalho. | |
| 90 | * @return Retorna uma confirmação. | |
| 91 | * @throws java.io.IOException Erro durante uma transmissão de I/O. | |
| 92 | */ | |
| 93 | boolean changeWorkingDirectory(String pathName) throws IOException; | |
| 94 | /** | |
| 95 | * Retorna o nome do diretório de trabalho. | |
| 96 | * @return Retorna o diretório. | |
| 97 | * @throws java.io.IOException Erro durante transmissão de I/O. | |
| 98 | */ | |
| 99 | String printWorkingDirectory() throws IOException; | |
| 100 | /** | |
| 101 | * Remove um diretório através de um ID de albúm recebido. | |
| 102 | * @param albumID ID do albúm. | |
| 103 | * @return Retorna uma confimação de exclusão do diretório. | |
| 104 | * @throws java.io.IOException Exceção durante transmissão de I/O. | |
| 105 | */ | |
| 106 | boolean removeDirectory(String albumID) throws IOException; | |
| 107 | ||
| 108 | ||
| 109 | /** | |
| 110 | * Conecta ao FTP. | |
| 111 | * @return Retorna uma confirmação para a conexão. | |
| 112 | */ | |
| 113 | boolean connect(); | |
| 114 | /** | |
| 115 | * Desconecta do FTP e apresenta uma mensagem explicando o motivo. | |
| 116 | * @param msg Mensagem do motivo da desconexão. | |
| 117 | */ | |
| 118 | void disconnect(String msg); | |
| 119 | ||
| 120 | /** | |
| 121 | * Seta um objeto CopyStreamListener. | |
| 122 | * TODO: esse método contem objetos específicos - retirá-lo. | |
| 123 | * @param copyStreamListener Objeto da classe CopyStreamListener. | |
| 124 | */ | |
| 125 | void setCopyStreamListener(CopyStreamListener copyStreamListener); | |
| 126 | /** | |
| 127 | * Retorna um objeto CopyStreamListener. | |
| 128 | * TODO: esse método contem objetos específicos - retirá-lo. | |
| 129 | * @return Retorna CopyStreamListener. | |
| 130 | */ | |
| 131 | CopyStreamListener getCopyStreamListener(); | |
| 132 | ||
| 133 | /** | |
| 134 | * Seta o ouvinte syncListener. | |
| 135 | * @param listener Um listener de sincronização. | |
| 136 | */ | |
| 137 | void setSyncListener(SyncListener listener); | |
| 138 | /** | |
| 139 | * Retorna o ouvinte syncListener. | |
| 140 | * @return Retorna um listener de sincronização. | |
| 141 | */ | |
| 142 | SyncListener getSyncListener(); | |
| 143 | ||
| 144 | /** | |
| 145 | * Determina qual caminho usar. | |
| 146 | * @param ftpRoot Parâmetro que recebe a informação. | |
| 147 | */ | |
| 148 | void setSyncFolder(String ftpRoot); | |
| 149 | /** | |
| 150 | * Retorna o caminho que deve usar. | |
| 151 | * @return Mostra o caminho base. | |
| 152 | */ | |
| 153 | String getSyncFolder(); | |
| 154 | ||
| 155 | /** | |
| 156 | * Retorna o usuário. | |
| 157 | * @return Retorna um usuário. | |
| 158 | */ | |
| 159 | String getUsuario(); | |
| 160 | /** | |
| 161 | * Seta um nome de usuário. | |
| 162 | * @param usuario Usuário. | |
| 163 | */ | |
| 164 | void setUsuario(String usuario); | |
| 165 | ||
| 166 | /** | |
| 167 | * Retorna uma senha de usuário. | |
| 168 | * @return Retorna uma senha. | |
| 169 | */ | |
| 170 | char[] getSenha(); | |
| 171 | /** | |
| 172 | * Seta uma senha de usuário. | |
| 173 | * @param senha Senha. | |
| 174 | */ | |
| 175 | void setSenha(char[] senha); | |
| 176 | ||
| 177 | /** | |
| 178 | * Retorna uma lista de arquivos. | |
| 179 | * @throws java.io.IOException Erro durante transmissão de I/O. | |
| 180 | * @return Retorna um vetor com os arquivos. | |
| 181 | */ | |
| 182 | FTPFile[] listFiles() throws IOException; | |
| 183 | ||
| 184 | /** | |
| 185 | * Retorna o tamanho do Buffer. | |
| 186 | * @return Retorna um tamanho inteiro. | |
| 187 | */ | |
| 188 | int getBufferSize(); | |
| 189 | /** | |
| 190 | * Carrega uma linha de comando FTP. | |
| 191 | * @param linha Linha de comando FTP. | |
| 192 | */ | |
| 193 | void loadSyncCacheLine(String linha); | |
| 194 | /** | |
| 195 | * Retorna uma lista de arquivos. | |
| 196 | * @return Retorna uma lista de arquivos. | |
| 197 | */ | |
| 198 | ArrayList<Arquivo> getListaArquivos(); | |
| 199 | ||
| 200 | /** | |
| 201 | * Procure sua utilização em | |
| 202 | * {@link net.sf.webphotos.sync.FTP.SyncObject#loadSyncCache() loadSyncCache}(). | |
| 203 | */ | |
| 204 | void loadSyncCache(); | |
| 205 | /** | |
| 206 | * Retorna a variável boolean enviarAltaResolução para especificar se serão | |
| 207 | * enviadas fotos originais ou não. | |
| 208 | * @return Retorna um valor lógico. | |
| 209 | */ | |
| 210 | boolean isEnviarAltaResolucao(); | |
| 211 | ||
| 212 | } |