Search in sources :

Example 6 with Sysprop

use of com.erudika.para.core.Sysprop in project scoold by Erudika.

the class ScooldUtils method getDefaultThemeObject.

private Sysprop getDefaultThemeObject() {
    String themeName = "default";
    Sysprop s = new Sysprop("theme" + Config.SEPARATOR + "custom");
    s.setName(themeName);
    s.addProperty("theme", "");
    FILE_CACHE.put("theme", themeName);
    FILE_CACHE.put(getThemeKey(themeName), loadResource(getThemeKey(themeName)));
    return s;
}
Also used : Sysprop(com.erudika.para.core.Sysprop)

Example 7 with Sysprop

use of com.erudika.para.core.Sysprop in project scoold by Erudika.

the class ScooldUtils method getSpaceIdFromCookie.

public String getSpaceIdFromCookie(Profile authUser, HttpServletRequest req) {
    if (isAdmin(authUser) && req.getParameter("space") != null) {
        // API override
        Sysprop s = pc.read(getSpaceId(req.getParameter("space")));
        if (s != null) {
            return s.getId() + Config.SEPARATOR + s.getName();
        }
    }
    String spaceAttr = (String) req.getAttribute(SPACE_COOKIE);
    String spaceValue = StringUtils.isBlank(spaceAttr) ? Utils.base64dec(getCookieValue(req, SPACE_COOKIE)) : spaceAttr;
    String space = getValidSpaceId(authUser, spaceValue);
    return (isAllSpaces(space) && isMod(authUser)) ? DEFAULT_SPACE : verifyExistingSpace(authUser, space);
}
Also used : Sysprop(com.erudika.para.core.Sysprop)

Example 8 with Sysprop

use of com.erudika.para.core.Sysprop in project scoold by Erudika.

the class ScooldUtils method setCustomTheme.

public void setCustomTheme(String themeName, String themeCSS) {
    String id = "theme" + Config.SEPARATOR + "custom";
    boolean isCustom = "custom".equalsIgnoreCase(themeName);
    String css = isCustom ? themeCSS : "";
    Sysprop custom = new Sysprop(id);
    custom.setName(StringUtils.isBlank(css) && isCustom ? "default" : themeName);
    custom.addProperty("theme", css);
    customTheme = pc.create(custom);
    FILE_CACHE.put("theme", themeName);
    FILE_CACHE.put(getThemeKey(themeName), isCustom ? css : loadResource(getThemeKey(themeName)));
}
Also used : Sysprop(com.erudika.para.core.Sysprop)

Example 9 with Sysprop

use of com.erudika.para.core.Sysprop in project scoold by Erudika.

the class ScooldUtils method unsubscribeFromNotifications.

@SuppressWarnings("unchecked")
public void unsubscribeFromNotifications(String email, String channelId) {
    if (!StringUtils.isBlank(email) && !StringUtils.isBlank(channelId)) {
        Sysprop s = pc.read(channelId);
        if (s == null || !s.hasProperty("emails")) {
            s = new Sysprop(channelId);
            s.addProperty("emails", new LinkedList<>());
        }
        Set<String> emails = new HashSet<>((List<String>) s.getProperty("emails"));
        if (emails.remove(email)) {
            s.addProperty("emails", emails);
            pc.create(s);
        }
    }
}
Also used : Sysprop(com.erudika.para.core.Sysprop) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 10 with Sysprop

use of com.erudika.para.core.Sysprop in project scoold by Erudika.

the class ScooldUtils method buildSpaceObject.

public Sysprop buildSpaceObject(String space) {
    space = Utils.abbreviate(space, 255);
    space = space.replaceAll(Config.SEPARATOR, "");
    String spaceId = getSpaceId(Utils.noSpaces(Utils.stripAndTrim(space, " "), "-"));
    Sysprop s = new Sysprop(spaceId);
    s.setType("scooldspace");
    s.setName(space);
    return s;
}
Also used : Sysprop(com.erudika.para.core.Sysprop)

Aggregations

Sysprop (com.erudika.para.core.Sysprop)32 HashMap (java.util.HashMap)8 PostMapping (org.springframework.web.bind.annotation.PostMapping)8 Map (java.util.Map)6 ParaObject (com.erudika.para.core.ParaObject)5 Profile (com.erudika.scoold.core.Profile)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 LinkedHashMap (java.util.LinkedHashMap)4 Pager (com.erudika.para.core.utils.Pager)3 TreeMap (java.util.TreeMap)3 User (com.erudika.para.core.User)2 ConfigValue (com.typesafe.config.ConfigValue)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 ParaClient (com.erudika.para.client.ParaClient)1 App (com.erudika.para.core.App)1 Tag (com.erudika.para.core.Tag)1 Webhook (com.erudika.para.core.Webhook)1 Config (com.erudika.para.core.utils.Config)1