use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project OpenOLAT by OpenOLAT.
the class DocumentPoolWebDAVMergeSource method loadMergedContainers.
@Override
protected List<VFSContainer> loadMergedContainers() {
List<VFSContainer> containers = new ArrayList<>();
String taxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
if (StringHelper.isLong(taxonomyTreeKey)) {
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyTreeKey)));
if (taxonomy != null) {
String templatesDir = Util.createPackageTranslator(DocumentPoolMainController.class, identityEnv.getLocale()).translate("document.pool.templates");
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identityEnv.getIdentity(), null, identityEnv.getRoles().isOLATAdmin(), docPoolModule.isTemplatesDirectoryEnabled(), templatesDir, null);
TreeModel model = builder.buildTreeModel();
TreeNode rootNode = model.getRootNode();
for (int i = 0; i < rootNode.getChildCount(); i++) {
VFSContainer container = loadRecursiveMergedContainers(taxonomy, rootNode.getChildAt(i));
if (container != null) {
containers.add(container);
}
}
}
}
return containers;
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project OpenOLAT by OpenOLAT.
the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
return false;
}
UserSession usess = ureq.getUserSession();
if (usess == null) {
return false;
}
Roles roles = usess.getRoles();
if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
return false;
}
if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
return true;
}
TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project openolat by klemens.
the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
return false;
}
UserSession usess = ureq.getUserSession();
if (usess == null) {
return false;
}
Roles roles = usess.getRoles();
if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
return false;
}
if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
return true;
}
TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project openolat by klemens.
the class TaxonomyModuleWebService method getTaxonomyWebService.
@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
}
if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
}
TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
if (taxonomy == null) {
throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
}
return new TaxonomyWebService(taxonomy);
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project openolat by klemens.
the class DocumentPoolModuleWebService method getTaxonomyWebService.
@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
}
if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
}
TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
if (taxonomy == null) {
throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
}
return new TaxonomyWebService(taxonomy);
}
Aggregations