Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hopmann committed Jul 26, 2013
1 parent c7a08d3 commit 852793d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class CodebaseApplication extends Application {

private static final String ROUTE_APK = ROUTE__BASE + "{" + PARAM_ID
+ "}/apk";

private static final String ROUTE_IMAGE = ROUTE__BASE + "{" + PARAM_ID
+ "}/image";

Expand Down Expand Up @@ -74,6 +74,7 @@ public synchronized Restlet createInboundRoot() {
router.attach(ROUTE_APK + "/", ApkFileResource.class);
router.attach(ROUTE_IMAGE, ImageFileResource.class);
router.attach(ROUTE_IMAGE + "/", ImageFileResource.class);


return router;
}
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/org/n52/ar/geoarCodebase/CodebaseDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,27 @@ public boolean deleteResource(String id) {
if (this.resources.containsKey(id)) {
this.resources.remove(id);

String path = CodebaseProperties.getInstance().getApkPath(id);
File apkFile = new File(path);
File apkFile = new File(CodebaseProperties.getInstance().getApkPath(id));

if (!apkFile.exists())
log.error("Cannot delete non-existing file {}", apkFile);
else {
delete = apkFile.delete();
if (!delete)
if (!apkFile.delete())
log.error("Error deleting file {}", apkFile);
else
log.debug("Deleted file {}", apkFile);
}

File imageFile = new File(CodebaseProperties.getInstance().getImagePath(id));

if (!imageFile.exists())
log.error("Cannot delete non-existing file {}", imageFile);
else {
if (!imageFile.delete())
log.error("Error deleting file {}", imageFile);
else
log.debug("Deleted file {}", imageFile);
}
} else
log.warn("Trying to delete non-existent resource {}", id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ protected void doInit() throws ResourceException {
.getDeleteToken()))
this.deleteAuthorized = true;
log.debug("Delete authorized: {}",
Boolean.valueOf(this.uploadAuthorized));
Boolean.valueOf(this.deleteAuthorized));

// if there is no id given, then return all! > simply return
// codebase/index.json file!
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/codebase.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
#

uploadToken=${conf.geoar.codebase.uploadToken}
deleteToken=${conf.geoar.codebase.deleteToken}

0 comments on commit 852793d

Please sign in to comment.