Skip to content

Commit 950d0e2

Browse files
Minor refactorings
1 parent bc757a3 commit 950d0e2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

client/src/main/java/org/ldp4j/tutorial/client/CachedRepresentationManager.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ private CachedRepresentationManager(File cacheDirectory) {
7878

7979
private void init() {
8080
if(!this.cacheDirectory.exists()) {
81-
this.cacheDirectory.mkdirs();
82-
this.created=true;
83-
LOGGER.debug("Created cache directory {}",this.cacheDirectory.getAbsolutePath());
84-
} else if(!this.cacheDirectory.isDirectory()) {
81+
this.created=this.cacheDirectory.mkdirs();
82+
}
83+
84+
if(!this.created && !this.cacheDirectory.isDirectory()) {
8585
LOGGER.debug("Path {} cannot be used as cache directory. Resorting to default temp directory {}",this.cacheDirectory.getAbsolutePath(),FileUtils.getTempDirectoryPath());
8686
this.cacheDirectory=FileUtils.getTempDirectory();
87-
this.created=false;
88-
} else {
89-
this.created=false;
87+
}
88+
89+
if(this.created){
90+
LOGGER.debug("Created cache directory {}",this.cacheDirectory.getAbsolutePath());
9091
}
9192
}
9293

@@ -153,10 +154,10 @@ String get(String resource) throws IOException {
153154
}
154155

155156
void dispose() {
156-
LOGGER.debug("Disposing resources persisted at {}...",this.cacheDirectory);
157+
LOGGER.debug("Disposing representations cached at {}...",this.cacheDirectory);
157158
for(ContentEntry entry:this.loadedResources.values()) {
158159
if(entry.file().exists()) {
159-
LOGGER.debug("- Deleting resource {} ({})...",entry.resource(),entry.file());
160+
LOGGER.debug("- Deleting representation for resource {} ({})...",entry.resource(),entry.file());
160161
if(!entry.file().delete()) {
161162
entry.file().deleteOnExit();
162163
LOGGER.debug(" + Could not delete {}. Scheduling for deletion on exit.",entry.resource());
@@ -172,7 +173,7 @@ void dispose() {
172173
LOGGER.debug(" + Could not delete cache directory: {}",e.getMessage());
173174
}
174175
}
175-
LOGGER.debug("Resources persisted at {} deleted.",this.cacheDirectory);
176+
LOGGER.debug("Representations cached at {} deleted.",this.cacheDirectory);
176177
}
177178

178179
static CachedRepresentationManager create(File cacheDirectory) {

client/src/main/java/org/ldp4j/tutorial/client/ContactsShell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private ContactsShell(ShellConsole console, ResourceRepository repository, Cache
136136
addOption("et","entity-tag", true, "use entity tag").
137137
addOption("lm","last-modified", true, "use last modified date").
138138
addOption("ct","content-type", true, "use content type").
139-
addOption("e","entity", true, "use entity");
139+
addOption("e", "entity", true, "use entity");
140140
}
141141

142142
private CommandContext createCommandContext(String rawCommandLine) throws ParseException {

0 commit comments

Comments
 (0)