10000 Manage the new ORecordDuplicatedException exception · githubcs/baasbox@2ecbf3d · GitHub
[go: up one dir, main page]

Skip to content
forked from baasbox/baasbox

Commit 2ecbf3d

Browse files
committed
Manage the new ORecordDuplicatedException exception
1 parent 0cc00d9 commit 2ecbf3d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

app/com/baasbox/controllers/Admin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
import com.orientechnologies.orient.core.index.OIndexException;
9898
import com.orientechnologies.orient.core.record.impl.ODocument;
9999
import com.orientechnologies.orient.core.serialization.serializer.OJSONWriter;
100+
import com.orientechnologies.orient.core.storage.ORecordDuplicatedException;
100101

101102
@With ({UserCredentialWrapFilter.class,ConnectToDBFilter.class, CheckAdminRoleFilter.class,ExtractQueryParameters.class})
102103
public class Admin extends Controller {
@@ -261,6 +262,8 @@ public static Result editRole(String name){
261262
return badRequest("Role " + name + " is not modifiable");
262263
} catch (RoleNotFoundException e) {
263264
return notFound("Role " + name + " does not exists");
265+
}catch (ORecordDuplicatedException e){
266+
return badRequest("Role " + name + " already exists");
264267
} catch (OIndexException e){
265268
return badRequest("Role " + name + " already exists");
266269
}

app/com/baasbox/controllers/Asset.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ private static Result postFile() throws Throwable{
281281
try{
282282
ODocument doc=AssetService.createFile(name[0],fileName,metaJson,contentType, fileContentAsByteArray);
283283
ret=prepareResponseToJson(doc);
284+
}catch (ORecordDuplicatedException e){
285+
return badRequest("An asset with the same name already exists");
284286
}catch (OIndexException e){
285287
return badRequest("An asset with the same name already exists");
286288
}

0 commit comments

Comments
 (0)
0