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); var company = get(companyId);
if (!membership(companyId,user.id())) throw forbidden("You are mot a member of company {company}", COMPANY,company.name()); 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 (!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()); if (!projectService().listCompanyProjects(companyId,true).isEmpty()) throw forbidden("There are projects owned by {company}", COMPANY,company.name());
return sendContent(ex, companyDb.drop(companyId)); 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.DbLocation;
import de.srsoftware.umbrella.core.model.Item;
import java.util.Collection; import java.util.Collection;
public interface StockService { public interface StockService {
/** Collection<Item> getCompanyItems(long companyID);
* 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);
DbLocation loadLocation(long locationId); 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())); Field.LOCATIONS,userLocations.stream().map(DbLocation::toMap).toList()));
var companies = companyService().listCompaniesOf(user); var companies = companyService().listCompaniesOf(user);
companies.values().stream().sorted(comparing(a -> a.name().toLowerCase())).forEach(company -> { companies.values().stream().sorted(comparing(a -> a.name().toLowerCase()))
var locations = stockDb.listCompanyLocations(company); .map(company -> Map.of(
result.add(Map.of( PARENT, Map.of(Field.COMPANY, company.id()),
PARENT, Map.of(Field.COMPANY, company.id()), NAME,company.name(),
NAME,company.name(), Field.LOCATIONS,getCompanyLocations(company).stream().sorted(comparing(a -> a.name().toLowerCase())).map(DbLocation::toMap).toList()))
Field.LOCATIONS,locations.stream().sorted(comparing(a -> a.name().toLowerCase())).map(DbLocation::toMap).toList())); .forEach(result::add);
});
return sendContent(ex, result); return sendContent(ex, result);
} }
public Collection<DbLocation> getCompanyLocations(Company company){
return stockDb.listCompanyLocations(company);
}
@Override @Override
public DbLocation loadLocation(long locationId) { public DbLocation loadLocation(long locationId) {
return stockDb.loadLocation(locationId); return stockDb.loadLocation(locationId);
@@ -466,8 +468,7 @@ public class StockModule extends BaseHandler implements StockService {
} }
@Override @Override
public Collection<Object> redefineMe(long company_id) { public Collection<Item> getCompanyItems(long companyID) {
// TODO return stockDb.listItemsOf(companyService().get(companyID));
return List.of();
} }
} }