aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/AttributeResource.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
commita9478ded48de140d47d17def1ee5329267fe6088 (patch)
treeadc5a9177fd5adcf10a8b56ee4620780dfc13cd9 /src/org/traccar/api/resource/AttributeResource.java
parentcb0d7cccaecfe049e04defd90884976ac1e982f9 (diff)
downloadtrackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.gz
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.bz2
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.zip
Refactored four managers
Diffstat (limited to 'src/org/traccar/api/resource/AttributeResource.java')
-rw-r--r--src/org/traccar/api/resource/AttributeResource.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/org/traccar/api/resource/AttributeResource.java b/src/org/traccar/api/resource/AttributeResource.java
index 4d326779b..c67d9cafe 100644
--- a/src/org/traccar/api/resource/AttributeResource.java
+++ b/src/org/traccar/api/resource/AttributeResource.java
@@ -52,42 +52,42 @@ public class AttributeResource extends BaseResource {
AttributesManager attributesManager = Context.getAttributesManager();
if (refresh) {
- attributesManager.refreshAttributes();
+ attributesManager.refreshItems();
}
Set<Long> result = new HashSet<>();
if (all) {
if (Context.getPermissionsManager().isAdmin(getUserId())) {
- result.addAll(attributesManager.getAllAttributes());
+ result.addAll(attributesManager.getAllItems());
} else {
Context.getPermissionsManager().checkManager(getUserId());
- result.addAll(attributesManager.getManagedAttributes(getUserId()));
+ result.addAll(attributesManager.getManagedItems(getUserId()));
}
} else {
if (userId == 0) {
userId = getUserId();
}
Context.getPermissionsManager().checkUser(getUserId(), userId);
- result.addAll(attributesManager.getUserAttributes(userId));
+ result.addAll(attributesManager.getUserItems(userId));
}
if (groupId != 0) {
Context.getPermissionsManager().checkGroup(getUserId(), groupId);
- result.retainAll(attributesManager.getGroupAttributes(groupId));
+ result.retainAll(attributesManager.getGroupItems(groupId));
}
if (deviceId != 0) {
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
- result.retainAll(attributesManager.getDeviceAttributes(deviceId));
+ result.retainAll(attributesManager.getDeviceItems(deviceId));
}
- return attributesManager.getAttributes(result);
+ return attributesManager.getItems(Attribute.class, result);
}
private Response add(Attribute entity) throws SQLException {
- Context.getAttributesManager().addAttribute(entity);
+ Context.getAttributesManager().addItem(entity);
Context.getDataManager().linkAttribute(getUserId(), entity.getId());
- Context.getAttributesManager().refreshUserAttributes();
+ Context.getAttributesManager().refreshUserItems();
return Response.ok(entity).build();
}
@@ -127,8 +127,8 @@ public class AttributeResource extends BaseResource {
@PUT
public Response update(Attribute entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkAttribute(getUserId(), entity.getId());
- Context.getAttributesManager().updateAttribute(entity);
+ Context.getPermissionsManager().checkPermission("attribute", getUserId(), entity.getId());
+ Context.getAttributesManager().updateItem(entity);
return Response.ok(entity).build();
}
@@ -136,8 +136,8 @@ public class AttributeResource extends BaseResource {
@DELETE
public Response remove(@PathParam("id") long id) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkAttribute(getUserId(), id);
- Context.getAttributesManager().removeAttribute(id);
+ Context.getPermissionsManager().checkPermission("attribute", getUserId(), id);
+ Context.getAttributesManager().removeItem(id);
return Response.noContent().build();
}