|
|
|
@ -15,9 +15,11 @@ import de.srsoftware.configuration.Configuration; |
|
|
|
import de.srsoftware.tools.Path; |
|
|
|
import de.srsoftware.tools.Path; |
|
|
|
import de.srsoftware.tools.SessionToken; |
|
|
|
import de.srsoftware.tools.SessionToken; |
|
|
|
import de.srsoftware.umbrella.core.BaseHandler; |
|
|
|
import de.srsoftware.umbrella.core.BaseHandler; |
|
|
|
|
|
|
|
import de.srsoftware.umbrella.core.api.EntityId; |
|
|
|
import de.srsoftware.umbrella.core.api.TagService; |
|
|
|
import de.srsoftware.umbrella.core.api.TagService; |
|
|
|
import de.srsoftware.umbrella.core.api.UserService; |
|
|
|
import de.srsoftware.umbrella.core.api.UserService; |
|
|
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; |
|
|
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; |
|
|
|
|
|
|
|
import de.srsoftware.umbrella.core.model.LongId; |
|
|
|
import de.srsoftware.umbrella.core.model.Token; |
|
|
|
import de.srsoftware.umbrella.core.model.Token; |
|
|
|
import de.srsoftware.umbrella.core.model.UmbrellaUser; |
|
|
|
import de.srsoftware.umbrella.core.model.UmbrellaUser; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
@ -35,7 +37,7 @@ public class TagModule extends BaseHandler implements TagService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void deleteEntity(String module, long entityId) { |
|
|
|
public void deleteEntity(String module, EntityId<?> entityId) { |
|
|
|
tagDb.deleteEntity(module,entityId); |
|
|
|
tagDb.deleteEntity(module,entityId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -49,7 +51,7 @@ public class TagModule extends BaseHandler implements TagService { |
|
|
|
var module = path.pop(); |
|
|
|
var module = path.pop(); |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
var head = path.pop(); |
|
|
|
var head = path.pop(); |
|
|
|
long entityId = Long.parseLong(head); |
|
|
|
var entityId = LongId.of(head); |
|
|
|
var tag = tagDb.delete(user.get().id(),module,entityId,body(ex)); |
|
|
|
var tag = tagDb.delete(user.get().id(),module,entityId,body(ex)); |
|
|
|
return sendContent(ex, tag); |
|
|
|
return sendContent(ex, tag); |
|
|
|
} catch (NumberFormatException e){ |
|
|
|
} catch (NumberFormatException e){ |
|
|
|
@ -69,7 +71,7 @@ public class TagModule extends BaseHandler implements TagService { |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
var head = path.pop(); |
|
|
|
var head = path.pop(); |
|
|
|
if (USES.equals(module)) return getTagUses(ex,head,user.get()); |
|
|
|
if (USES.equals(module)) return getTagUses(ex,head,user.get()); |
|
|
|
long entityId = Long.parseLong(head); |
|
|
|
var entityId = LongId.of(head); |
|
|
|
return sendContent(ex, getTags(module,entityId,user.get())); |
|
|
|
return sendContent(ex, getTags(module,entityId,user.get())); |
|
|
|
} catch (NumberFormatException e){ |
|
|
|
} catch (NumberFormatException e){ |
|
|
|
return sendContent(ex,HTTP_UNPROCESSABLE,"Entity id missing in path."); |
|
|
|
return sendContent(ex,HTTP_UNPROCESSABLE,"Entity id missing in path."); |
|
|
|
@ -98,7 +100,7 @@ public class TagModule extends BaseHandler implements TagService { |
|
|
|
var module = path.pop(); |
|
|
|
var module = path.pop(); |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
if (module == null) throw unprocessable("Module missing in path."); |
|
|
|
var head = path.pop(); |
|
|
|
var head = path.pop(); |
|
|
|
long entityId = Long.parseLong(head); |
|
|
|
var entityId = LongId.of(head); |
|
|
|
var json = json(ex); |
|
|
|
var json = json(ex); |
|
|
|
if (!(json.has(TAG) && json.get(TAG) instanceof String tag)) throw missingFieldException(TAG); |
|
|
|
if (!(json.has(TAG) && json.get(TAG) instanceof String tag)) throw missingFieldException(TAG); |
|
|
|
List<Long> userList = null; |
|
|
|
List<Long> userList = null; |
|
|
|
@ -122,17 +124,17 @@ public class TagModule extends BaseHandler implements TagService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Collection<String> getTags(String module, long entityId, UmbrellaUser user) throws UmbrellaException{ |
|
|
|
public Collection<String> getTags(String module, EntityId<?> entityId, UmbrellaUser user) throws UmbrellaException{ |
|
|
|
return tagDb.list(user.id(),module,entityId); |
|
|
|
return tagDb.list(user.id(),module,entityId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void save(String module, long entityId, Collection<Long> userIds, Collection<String> tags) { |
|
|
|
public void save(String module, EntityId<?> entityId, Collection<Long> userIds, Collection<String> tags) { |
|
|
|
tagDb.save(userIds,module,entityId,tags); |
|
|
|
tagDb.save(userIds,module,entityId,tags); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String save(String module, long entityId, Collection<Long> userIds, String tag) { |
|
|
|
public String save(String module, EntityId<?> entityId, Collection<Long> userIds, String tag) { |
|
|
|
save(module,entityId,userIds,List.of(tag)); |
|
|
|
save(module,entityId,userIds,List.of(tag)); |
|
|
|
return tag; |
|
|
|
return tag; |
|
|
|
} |
|
|
|
} |
|
|
|
|