|
|
|
|
@ -6,8 +6,7 @@ import static de.srsoftware.umbrella.core.Constants.*;
@@ -6,8 +6,7 @@ import static de.srsoftware.umbrella.core.Constants.*;
|
|
|
|
|
import static de.srsoftware.umbrella.core.Paths.LIST; |
|
|
|
|
import static de.srsoftware.umbrella.core.Util.mapValues; |
|
|
|
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*; |
|
|
|
|
import static de.srsoftware.umbrella.core.model.Permission.EDIT; |
|
|
|
|
import static de.srsoftware.umbrella.core.model.Permission.OWNER; |
|
|
|
|
import static de.srsoftware.umbrella.core.model.Permission.*; |
|
|
|
|
import static de.srsoftware.umbrella.core.model.Status.OPEN; |
|
|
|
|
import static de.srsoftware.umbrella.project.Constants.CONFIG_DATABASE; |
|
|
|
|
import static java.lang.Boolean.TRUE; |
|
|
|
|
@ -41,6 +40,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
@@ -41,6 +40,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
|
|
|
|
users = companies.userService(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void addMember(Project project, long userId) { |
|
|
|
|
var user = users.loadUser(userId); |
|
|
|
|
var member = new Member(user,READ_ONLY); |
|
|
|
|
project.members().put(userId,member); |
|
|
|
|
project.dirtyFields().add(MEMBERS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public CompanyService companyService() { |
|
|
|
|
return companies; |
|
|
|
|
@ -188,12 +195,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
@@ -188,12 +195,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
|
|
|
|
if (!project.hasMember(user)) throw forbidden("You are not a member of {0}",project.name()); |
|
|
|
|
var json = json(ex); |
|
|
|
|
if (json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject memberJson) patchMembers(project,memberJson); |
|
|
|
|
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) addMember(project,num.longValue()); |
|
|
|
|
|
|
|
|
|
projects.save(project.patch(json)); |
|
|
|
|
return sendContent(ex,project.toMap()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean postProject(HttpExchange ex, UmbrellaUser user) throws IOException, UmbrellaException { |
|
|
|
|
var json = json(ex); |
|
|
|
|
if (!(json.has(NAME) && json.get(NAME) instanceof String name)) throw missingFieldException(NAME); |
|
|
|
|
|