@@ -131,6 +131,7 @@ public class AccountOwnedResource<E extends HasAccount, DAO extends AccountOwned | |||||
} | } | ||||
protected E findAlternate(ContainerRequest ctx, E request) { return null; } | protected E findAlternate(ContainerRequest ctx, E request) { return null; } | ||||
protected E findAlternate(ContainerRequest ctx, String id) { return null; } | |||||
protected Object daoCreate(E toCreate) { return getDao().create(toCreate); } | protected Object daoCreate(E toCreate) { return getDao().create(toCreate); } | ||||
@@ -141,8 +142,11 @@ public class AccountOwnedResource<E extends HasAccount, DAO extends AccountOwned | |||||
@PathParam("id") String id, | @PathParam("id") String id, | ||||
E request) { | E request) { | ||||
final Account caller = checkEditable(ctx); | final Account caller = checkEditable(ctx); | ||||
final E found = find(ctx, id); | |||||
if (found == null) return notFound(id); | |||||
E found = find(ctx, id); | |||||
if (found == null) { | |||||
found = findAlternate(ctx, id); | |||||
if (found == null) return notFound(id); | |||||
} | |||||
if (!(found instanceof HasAccountNoName) && !canChangeName() && request.hasName() && !found.getName().equals(request.getName())) { | if (!(found instanceof HasAccountNoName) && !canChangeName() && request.hasName() && !found.getName().equals(request.getName())) { | ||||
return notFound(id+"/"+request.getName()); | return notFound(id+"/"+request.getName()); | ||||
} | } | ||||
@@ -158,8 +162,11 @@ public class AccountOwnedResource<E extends HasAccount, DAO extends AccountOwned | |||||
public Response delete(@Context ContainerRequest ctx, | public Response delete(@Context ContainerRequest ctx, | ||||
@PathParam("id") String id) { | @PathParam("id") String id) { | ||||
final Account caller = checkEditable(ctx); | final Account caller = checkEditable(ctx); | ||||
final E found = find(ctx, id); | |||||
if (found == null) return notFound(id); | |||||
E found = find(ctx, id); | |||||
if (found == null) { | |||||
found = findAlternate(ctx, id); | |||||
if (found == null) return notFound(id); | |||||
} | |||||
if (!canDelete(ctx, caller, found)) return forbidden(); | if (!canDelete(ctx, caller, found)) return forbidden(); | ||||
@@ -56,6 +56,13 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco | |||||
return getDao().findByAccountAndNotDeleted(account.getUuid()); | return getDao().findByAccountAndNotDeleted(account.getUuid()); | ||||
} | } | ||||
@Override protected AccountPlan findAlternate(ContainerRequest ctx, String id) { | |||||
// id might be a network uuid | |||||
final String accountUuid = getAccountUuid(ctx); | |||||
final BubbleNetwork network = networkDAO.findByAccountAndId(accountUuid, id); | |||||
return network == null ? null : getDao().findByAccountAndNetwork(accountUuid, network.getUuid()); | |||||
} | |||||
@Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) { | @Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) { | ||||
// ensure caller is not from a disallowed country | // ensure caller is not from a disallowed country | ||||
if (configuration.hasDisallowedCountries()) { | if (configuration.hasDisallowedCountries()) { | ||||
@@ -99,6 +99,11 @@ public class NetworksResource extends AccountOwnedResource<BubbleNetwork, Bubble | |||||
return false; | return false; | ||||
} | } | ||||
@Override protected boolean canDelete(ContainerRequest ctx, Account caller, BubbleNetwork found) { | |||||
// delete networks through plans | |||||
return false; | |||||
} | |||||
@GET @Path("/{id}"+EP_CLOSEST) | @GET @Path("/{id}"+EP_CLOSEST) | ||||
public Response findClosest(@Context Request req, | public Response findClosest(@Context Request req, | ||||
@Context ContainerRequest ctx, | @Context ContainerRequest ctx, | ||||
@@ -167,10 +167,9 @@ label_field_networks_locale=Locale | |||||
label_field_networks_timezone=Time Zone | label_field_networks_timezone=Time Zone | ||||
label_field_networks_object_state=State | label_field_networks_object_state=State | ||||
label_field_networks_action_view=View | label_field_networks_action_view=View | ||||
label_field_networks_action_start_stop=Start/Stop | |||||
label_field_networks_action_stop=Stop | |||||
label_field_networks_action_delete=Delete | label_field_networks_action_delete=Delete | ||||
table_row_networks_action_view=View | table_row_networks_action_view=View | ||||
table_row_networks_action_start=Start | |||||
table_row_networks_action_stop=Stop | table_row_networks_action_stop=Stop | ||||
table_row_networks_action_delete=Delete | table_row_networks_action_delete=Delete | ||||
button_label_new_network=Create Bubble | button_label_new_network=Create Bubble | ||||
@@ -1 +1 @@ | |||||
Subproject commit 0f3b38169089cad36ce86a0b468293d1ca6c2169 | |||||
Subproject commit e8c5f6c80992169184d4a17c1c65bfc5424a0686 |