use of fi.otavanopisto.pyramus.dao.system.SettingDAO in project pyramus by otavanopisto.
the class Mailer method getSetting.
private static String getSetting(String settingName) {
SettingDAO settingDAO = DAOFactory.getInstance().getSettingDAO();
SettingKeyDAO settingKeyDAO = DAOFactory.getInstance().getSettingKeyDAO();
SettingKey key = settingKeyDAO.findByName(settingName);
if (key != null) {
Setting setting = settingDAO.findByKey(key);
if (setting != null) {
return setting.getValue();
}
}
return null;
}
use of fi.otavanopisto.pyramus.dao.system.SettingDAO in project pyramus by otavanopisto.
the class MuikkuPluginTools method getMuikkuHost.
public static String getMuikkuHost() {
SettingKeyDAO settingKeyDAO = DAOFactory.getInstance().getSettingKeyDAO();
SettingDAO settingDAO = DAOFactory.getInstance().getSettingDAO();
SettingKey key = settingKeyDAO.findByName("muikkuplugin.muikkuhost");
if (key != null) {
Setting setting = settingDAO.findByKey(key);
if (setting != null) {
return setting.getValue();
}
}
return null;
}
use of fi.otavanopisto.pyramus.dao.system.SettingDAO in project pyramus by otavanopisto.
the class GoogleOauthAuthorizationStrategy method getClientSecret.
private String getClientSecret() {
SettingDAO settingDAO = DAOFactory.getInstance().getSettingDAO();
SettingKeyDAO settingKeyDAO = DAOFactory.getInstance().getSettingKeyDAO();
return settingDAO.findByKey(settingKeyDAO.findByName("google.oauth.clientsecret")).getValue();
}
use of fi.otavanopisto.pyramus.dao.system.SettingDAO in project pyramus by otavanopisto.
the class SystemSettingsViewController method processForm.
@Override
public void processForm(PageRequestContext requestContext) {
SettingDAO settingDAO = DAOFactory.getInstance().getSettingDAO();
SettingKeyDAO settingKeyDAO = DAOFactory.getInstance().getSettingKeyDAO();
Map<String, String> settings = new HashMap<>();
List<SettingKey> settingKeys = settingKeyDAO.listAll();
for (SettingKey settingKey : settingKeys) {
Setting setting = settingDAO.findByKey(settingKey);
if (setting != null)
settings.put(settingKey.getName(), setting.getValue());
}
requestContext.getRequest().setAttribute("settingKeys", settingKeys);
requestContext.getRequest().setAttribute("settings", settings);
requestContext.setIncludeJSP("/templates/system/systemsettings.jsp");
}
use of fi.otavanopisto.pyramus.dao.system.SettingDAO in project pyramus by otavanopisto.
the class CreateApplicationViewController method process.
public void process(PageRequestContext pageRequestContext) {
try {
SettingKeyDAO settingKeyDAO = DAOFactory.getInstance().getSettingKeyDAO();
SettingKey settingKey = settingKeyDAO.findByName("applications.storagePath");
if (settingKey == null) {
logger.log(Level.SEVERE, "SettingKey for applications.storagePath not found");
pageRequestContext.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
SettingDAO settingDAO = DAOFactory.getInstance().getSettingDAO();
Setting setting = settingDAO.findByKey(settingKey);
if (setting == null || setting.getValue() == null) {
logger.log(Level.SEVERE, "Setting applications.storagePath not defined");
pageRequestContext.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
File attachmentsFolder = Paths.get(setting.getValue()).toFile();
if (!attachmentsFolder.exists() || !attachmentsFolder.isDirectory() || !attachmentsFolder.canWrite()) {
logger.log(Level.SEVERE, "Setting applications.storagePath refers to a non-existing or non-writable folder");
pageRequestContext.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Unable to serve 404 for applications.storagePath", e);
return;
}
String line = pageRequestContext.getString("line");
if (!StringUtils.isBlank(line) && ApplicationUtils.isValidLine(line)) {
pageRequestContext.getRequest().setAttribute("preselectLine", line);
pageRequestContext.getRequest().setAttribute("applicationId", UUID.randomUUID().toString());
pageRequestContext.getRequest().setAttribute("preload", Boolean.FALSE);
pageRequestContext.getRequest().setAttribute("donePage", Boolean.TRUE);
pageRequestContext.getRequest().setAttribute("saveUrl", "/1/applications/saveapplication");
pageRequestContext.setIncludeJSP("/templates/applications/application-edit.jsp");
} else {
pageRequestContext.setRedirectURL(pageRequestContext.getRequest().getContextPath() + "/applications/index.page");
}
}
Aggregations