fixing some permission-related TODOs

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-03-25 08:47:53 +01:00
parent 229a6f8e5a
commit f9bb8def03
3 changed files with 16 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ public class CompanyModule extends BaseHandler implements CompanyService {
var company = get(companyId);
if (!membership(companyId,user.id())) throw forbidden("You are mot a member of company {company}", COMPANY,company.name());
if (!documentService().list(companyId).isEmpty()) throw forbidden("There are documents owned by {company}", COMPANY,company.name());
if (!itemService().redefineMe(companyId).isEmpty()) throw forbidden("There are items owned by {company}", COMPANY,company.name());
if (!itemService().getCompanyItems(companyId).isEmpty()) throw forbidden("There are items owned by {company}", COMPANY,company.name());
if (!projectService().listCompanyProjects(companyId,true).isEmpty()) throw forbidden("There are projects owned by {company}", COMPANY,company.name());
return sendContent(ex, companyDb.drop(companyId));
}

View File

@@ -3,16 +3,12 @@ package de.srsoftware.umbrella.core.api;
import de.srsoftware.umbrella.core.model.DbLocation;
import de.srsoftware.umbrella.core.model.Item;
import java.util.Collection;
public interface StockService {
/**
* Das war mal die methode um zu checken, ob einer Firma noch Items zugewiesen sind.
* TODO: Diese Methode muss neu definiert werden, sobald der Stock-Service neu implementiert ist.
* @param company_id
* @return
*/
Collection<Object> redefineMe(long company_id);
Collection<Item> getCompanyItems(long companyID);
DbLocation loadLocation(long locationId);
}

View File

@@ -289,17 +289,19 @@ public class StockModule extends BaseHandler implements StockService {
Field.LOCATIONS,userLocations.stream().map(DbLocation::toMap).toList()));
var companies = companyService().listCompaniesOf(user);
companies.values().stream().sorted(comparing(a -> a.name().toLowerCase())).forEach(company -> {
var locations = stockDb.listCompanyLocations(company);
result.add(Map.of(
PARENT, Map.of(Field.COMPANY, company.id()),
NAME,company.name(),
Field.LOCATIONS,locations.stream().sorted(comparing(a -> a.name().toLowerCase())).map(DbLocation::toMap).toList()));
});
companies.values().stream().sorted(comparing(a -> a.name().toLowerCase()))
.map(company -> Map.of(
PARENT, Map.of(Field.COMPANY, company.id()),
NAME,company.name(),
Field.LOCATIONS,getCompanyLocations(company).stream().sorted(comparing(a -> a.name().toLowerCase())).map(DbLocation::toMap).toList()))
.forEach(result::add);
return sendContent(ex, result);
}
public Collection<DbLocation> getCompanyLocations(Company company){
return stockDb.listCompanyLocations(company);
}
@Override
public DbLocation loadLocation(long locationId) {
return stockDb.loadLocation(locationId);
@@ -466,8 +468,7 @@ public class StockModule extends BaseHandler implements StockService {
}
@Override
public Collection<Object> redefineMe(long company_id) {
// TODO
return List.of();
public Collection<Item> getCompanyItems(long companyID) {
return stockDb.listItemsOf(companyService().get(companyID));
}
}