use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class DocumentPoolSiteSecurityCallback method isAllowedToLaunchSite.
/**
* @see com.frentix.olat.coursesite.SiteSecurityCallback#isAllowedToLaunchSite(org.olat.core.gui.UserRequest)
*/
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
UserSession usess = ureq == null ? null : ureq.getUserSession();
if (usess == null)
return false;
Roles roles = usess.getRoles();
if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
return false;
}
if (roles.isOLATAdmin()) {
return true;
}
String taxonomyKey = docPoolModule.getTaxonomyTreeKey();
if (StringHelper.isLong(taxonomyKey)) {
TaxonomyRef taxonomy = new TaxonomyRefImpl(new Long(taxonomyKey));
return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), ureq.getRequestTimestamp());
}
return false;
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project OpenOLAT by OpenOLAT.
the class DocumentPoolAdminController method doOpenPermissions.
private void doOpenPermissions(UserRequest ureq) {
removeAsListenerAndDispose(permissionsCtrl);
if (StringHelper.containsNonWhitespace(docPoolModule.getTaxonomyTreeKey())) {
WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType("Types"), null);
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(docPoolModule.getTaxonomyTreeKey())));
permissionsCtrl = new DocumentPoolAdminPermissionsController(ureq, bwControl, taxonomy);
listenTo(permissionsCtrl);
mainVC.put("segmentCmp", permissionsCtrl.getInitialComponent());
}
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project openolat by klemens.
the class SearchControllerFactory method getBusinessPathLabel.
@Override
public String getBusinessPathLabel(String token, List<String> allTokens, Locale locale) {
try {
String[] splitted = token.split("[:]");
if (splitted != null && splitted.length == 2) {
String tokenType = splitted[0];
String tokenKey = splitted[1];
if ("RepositoryEntry".equals(tokenType)) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(tokenKey));
return re.getDisplayname();
}
if ("CourseNode".equals(tokenType)) {
String repoKey = allTokens.get(0).split("[:]")[1];
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(repoKey));
if (re != null) {
ICourse course = CourseFactory.loadCourse(re);
CourseNode courseNode = course.getRunStructure().getNode(tokenKey);
return courseNode.getShortTitle();
}
}
if ("Identity".equals(tokenType)) {
IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(Long.parseLong(tokenKey));
return UserManager.getInstance().getUserDisplayName(identity);
}
if ("BusinessGroup".equals(tokenType)) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(Long.parseLong(tokenKey));
return bg == null ? "" : bg.getName();
}
if ("Taxonomy".equals(tokenType)) {
Taxonomy taxonomy = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomy(new TaxonomyRefImpl(Long.parseLong(tokenKey)));
return taxonomy == null ? "" : taxonomy.getDisplayName();
}
if ("TaxonomyLevel".equals(tokenType)) {
TaxonomyLevel level = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomyLevel(new TaxonomyLevelRefImpl(Long.parseLong(tokenKey)));
return level == null ? "" : level.getDisplayName();
}
Translator translator = Util.createPackageTranslator(this.getClass(), locale);
if ("DocumentPool".equals(tokenType)) {
return translator.translate("DocumentPool");
}
if ("Templates".equals(tokenType)) {
return translator.translate("Templates");
}
if ("userfolder".equals(tokenType)) {
return translator.translate("type.identity.publicfolder");
}
String translated = translator.translate(tokenType);
if (translated == null || translated.length() > 64) {
// no translation, translator return an error
return token;
}
return translated;
}
} catch (Exception ex) {
log.warn("Problem to decipher business path token: " + token, ex);
}
return token;
}
use of org.olat.modules.taxonomy.model.TaxonomyRefImpl in project openolat by klemens.
the class DocumentPoolSiteSecurityCallback method isAllowedToLaunchSite.
/**
* @see com.frentix.olat.coursesite.SiteSecurityCallback#isAllowedToLaunchSite(org.olat.core.gui.UserRequest)
*/
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
UserSession usess = ureq == null ? null : ureq.getUserSession();
if (usess == null)
return false;
Roles roles = usess.getRoles();
if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
return false;
}
if (roles.isOLATAdmin()) {
return true;
}
String taxonomyKey = docPoolModule.getTaxonomyTreeKey();
if (StringHelper.isLong(taxonomyKey)) {
TaxonomyRef taxonomy = new TaxonomyRefImpl(new Long(taxonomyKey));
return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), ureq.getRequestTimestamp());
}
return false;
}
Aggregations