-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepository.java
More file actions
150 lines (112 loc) · 3.27 KB
/
Copy pathRepository.java
File metadata and controls
150 lines (112 loc) · 3.27 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
/**
*
*
* @version 1.0 Jun 2018
* @author Amanda Camacho,
* Benjamin Amos <benjamin.oxi@gmail.com>
*/
public class Repository{
private String repoName; /* Repo name its the the unique identifierfor repository */
private List <Files> documents; /* Collection of documents */
private Date dateCreated; /* Date asociate to repo*/
private int version;
private String user; /* Maybe necesary, the administrator name*/
private Date lastModify;
/* Maybe necesary use a stack of versions, diferents states the repository*/
/**
* Constructs a Repository object.
* @param repoName
*/
public Repository (String repoName){
if(repoName==null) throw new IllegalArgumentException();
this.repoName = repoName;
this.documents= new ArrayList<Files>();
this.dateCreated = new Date();
this.lastModify = new Date();
this.version=0;
}
/**
* Return a especific file in the repo
* @param fileName the name of the file that we want
* @throws list of Files
*/
public Files getFile(String fileName){
if ( fileName == null) throw new IllegalArgumentException();
for (Files f : this.documents) {
if (f.getFileName().equals(fileName)) {
return f;
}
}
return null;
}
/**
* Return true if the new file was add to repo
* @param file the file thar we want to add
* @throws booelan with the result
*/
public boolean addFile(Files file){
if ( file == null) throw new IllegalArgumentException("Indique un nombre valido");
for (Files f : this.documents) {
if (f.getFileName().equals(file.getFileName())) {
this.documents.remove(f);
this.documents.add(file);
this.version+=1;
this.lastModify= new Date();
return true;
}
}
this.documents.add(file);
this.version +=1;
return true;
}
// IDK if necesary but
/**
* Return true if the file was remove to repo
* @param file the file thar we want to remove
* @throws booelan with the result
*/
public boolean deleteFile(Files file){
if ( file == null) throw new IllegalArgumentException();
for (Files f : this.documents) {
if (f.getFileName().equals(file.getFileName())) {
documents.remove(f);
this.lastModify= new Date();
return true;
}
}
return false;
}
/*#####################################################################*/
/* GETERS */
/**
* Return a list of files in the repo
* @throws list of Files
*/
public List<Files> getFiles(){
return this.documents;
}
/**
* Return repo version
* @throws number of version
*/
public int getVersion(){
return this.version;
}
/**
* Return repo name
* @throws name of Repo
*/
public String getName(){
return this.repoName;
}
/**
* Return repo name
* @throws name of Repo
*/
public Date getRepoDate(){
return this.dateCreated;
}
}