Skip to content

Commit 86ce05e

Browse files
authored
added check to make sure the space to be added does not already exist (duracloud#197)
1 parent ca57efd commit 86ce05e

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

duradmin/src/main/webapp/jquery/dc/api/durastore-api.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@ var dc;
115115
* @param Object callback The callback must implement success and failure methods. options begin method is supported.
116116
*/
117117
dc.store.AddSpace = function(space, publicFlag, callback){
118+
// Check if space already exists
119+
var exists = false;
120+
dc.ajax({
121+
url: "/duradmin/spaces/json",
122+
data: "storeId=" + space.storeId,
123+
cache: false,
124+
async: false,
125+
success: function (data) {
126+
$.each(data.spaces, function (index, current_space) {
127+
if (space.spaceId == current_space.spaceId) {
128+
exists = true;
129+
}
130+
});
131+
},
132+
failure: {},
133+
});
134+
if (exists) {
135+
return callback.failure('The space already exists.');
136+
}
137+
138+
// Add space
118139
dc.ajax(
119140
{
120141
url: "/duradmin/spaces/space",

duradmin/src/main/webapp/js/spaces-manager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,10 @@ $(function() {
906906
$("#spaces-list").selectablelist("setCurrentItemById", space.spaceId);
907907
that._spacesListPane.spaceslistpane("scrollToCurrentSpace");
908908
}
909-
909+
},
910+
failure : function(message) {
911+
dc.done();
912+
alert("Error: " + message);
910913
},
911914
});
912915
this._addSpaceDialog.dialog("close");

0 commit comments

Comments
 (0)