-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientImp.java
More file actions
82 lines (58 loc) · 2.35 KB
/
Copy pathClientImp.java
File metadata and controls
82 lines (58 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import java.nio.file.Paths;
import java.rmi.RemoteException;
/**
*
*
* @version 1.0 Jun 2018
* @author Amanda Camacho,
* Benjamin Amos <benjamin.oxi@gmail.com>
*/
// Esta clase es la que utiliza todo la parte de rmi, de la interfaz de Client implements
public class ClientImp extends
java.rmi.server.UnicastRemoteObject
implements ClientOperations {
private Repo newRepo; // esta es la copia que se manda a commitear
private ServerOperations operatiosServerToServer;
private int replicates;
public ClientImp(ServerOperations newServerOperation) throws RemoteException{
super();
repoTemp= new Repo();
this.operatiosServerToServer= newServerOperation;
}
/**
* Commit Method
* @throws Repo name
*/
/* El metodo commit que recibe un repositorio completo, implementamos como en git
que al actualizar se crea un nuevo repositorio y se actualiza la version de este
entonces cuando se hace commit enviamos un repositorio completo
*/
public boolean commit( Repo filesAndUpdates) throws RemoteException{
List<Files> newFiles = filesAndUpdates.getFiles();
String repoName= filesAndUpdates.getRepoName();
byte[] buffer;
if (filesAndUpdates!= null){
File newFile= new File(repoName);
/*como es una operacion de cliente a servidor y esto se ejecuta en el servidor
*/
}
}
public Repo pullRepo( String repoName) throws RemoteException{
//Falta implementar esto en el operaciones de servidor a servidor
return this.operatiosServerToServer.findRepo( repoName);
}
public String fileList(String repoName) throws RemoteException{
// buscar como obtener un path en java
Path path= Paths.get(repoName);
String filesList = "";
// verifico si el archivo exite o si lo encontro
if (Files.exist(path)){
//tengo que leer el repo y agregar todos los nombres de los archivos a un string
}else {
// En el print \u001B[31m lo que hace es poner ese string en color rojo
System.out.println("\u001B[31m"+repoName+"\u001B[31m no existe.");
System.out.print("\u001B[0m"); // para volver al color original del terminal
return null;
}
}
}