use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class StatusWebservice method getSystemSummaryVO.
/**
* Return the statistics about runtime: uptime, classes loaded, memory
* summary, threads count...
*
* @response.representation.200.qname {http://www.example.com}runtimeVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The version of the instance
* @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_RUNTIMEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param request The HTTP request
* @return The informations about runtime, uptime, classes loaded, memory summary...
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSystemSummaryVO() {
StatusVO stats = new StatusVO();
// File
try {
long startFile = System.nanoTime();
File infoFile = setInfoFiles("ping");
WorkThreadInformations.unset();
stats.setWriteFileInMilliseconds(CodeHelper.nanoToMilliTime(startFile));
stats.setWriteFile(infoFile.exists());
infoFile.delete();
} catch (Exception e) {
stats.setWriteFile(false);
stats.setWriteFileInMilliseconds(-1l);
log.error("", e);
}
// Datebase
try {
stats.setWriteDb(true);
PropertyManager propertyManager = CoreSpringFactory.getImpl(PropertyManager.class);
List<Property> props = propertyManager.findProperties((Identity) null, (BusinessGroup) null, PING_RESOURCE, PING_REF, PING_REF);
if (props != null && props.size() > 0) {
for (Property prop : props) {
propertyManager.deleteProperty(prop);
}
DBFactory.getInstance().commit();
}
long startDB = System.nanoTime();
Property prop = propertyManager.createPropertyInstance(null, null, PING_RESOURCE, PING_REF, PING_REF, 0f, 0l, "-", "-");
DBFactory.getInstance().commit();
stats.setWriteDbInMilliseconds(CodeHelper.nanoToMilliTime(startDB));
propertyManager.deleteProperty(prop);
DBFactory.getInstance().commit();
} catch (Exception e) {
stats.setWriteDb(false);
stats.setWriteDbInMilliseconds(-1l);
log.error("", e);
}
// Secure authenticated user
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions();
int secureAuthenticatedCount = 0;
for (UserSession usess : userSessions) {
SessionInfo sessInfo = usess.getSessionInfo();
if (sessInfo.isWebDAV() || sessInfo.isREST()) {
//
} else if (sessInfo.isSecure()) {
secureAuthenticatedCount++;
}
}
stats.setSecureAuthenticatedCount(secureAuthenticatedCount);
// Concurrent dispatch threads
SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
stats.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter());
return Response.ok(stats).build();
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class TACourseNode method informOnDelete.
/**
* @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
* org.olat.course.ICourse)
*/
@Override
public String informOnDelete(Locale locale, ICourse course) {
Translator trans = new PackageTranslator(PACKAGE_TA, locale);
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
List<Property> list = cpm.listCourseNodeProperties(this, null, null, null);
// properties exist
if (list.size() != 0)
return trans.translate("warn.nodedelete");
File fTaskFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course, this));
// task folder contains files
if (fTaskFolder.exists() && fTaskFolder.list().length > 0)
return trans.translate(NLS_WARN_NODEDELETE);
// no data yet.
return null;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class TACourseNode method getDetailsListView.
/**
* @see org.olat.course.nodes.AssessableCourseNode#getDetailsListView(org.olat.course.run.userview.UserCourseEnvironment)
*/
@Override
public String getDetailsListView(UserCourseEnvironment userCourseEnvironment) {
Identity identity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
CoursePropertyManager propMgr = userCourseEnvironment.getCourseEnvironment().getCoursePropertyManager();
List<Property> samples = propMgr.findCourseNodeProperties(this, identity, null, TaskController.PROP_ASSIGNED);
// no sample assigned yet
if (samples.size() == 0)
return null;
return samples.get(0).getStringValue();
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class LTIRunController method checkHasDataExchangeAccepted.
/**
* Helper method to check if user has already accepted. this info is stored
* in a user property, the accepted values are stored as an MD5 hash (save
* space, privacy)
*
* @param hash
* MD5 hash with all user data
* @return true: user has already accepted for this hash; false: user has
* not yet accepted or for other values
*/
private boolean checkHasDataExchangeAccepted(String hash) {
boolean dataAccepted = false;
CoursePropertyManager propMgr = this.userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
Property prop = propMgr.findCourseNodeProperty(this.courseNode, getIdentity(), null, PROP_NAME_DATA_EXCHANGE_ACCEPTED);
if (prop != null) {
// compare if value in property is the same as calculated today. If not, user as to accept again
String storedHash = prop.getStringValue();
if (storedHash != null && hash != null && storedHash.equals(hash)) {
dataAccepted = true;
} else {
// remove property, not valid anymore
propMgr.deleteProperty(prop);
}
}
return dataAccepted;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class ProjectGroupManagerImpl method deleteAccountManagerGroup.
public void deleteAccountManagerGroup(CoursePropertyManager cpm, CourseNode courseNode) {
log.debug("deleteAccountManagerGroup start...");
Property accountManagerGroupProperty = cpm.findCourseNodeProperty(courseNode, null, null, ProjectBrokerCourseNode.CONF_ACCOUNTMANAGER_GROUP_KEY);
if (accountManagerGroupProperty != null) {
Long groupKey = accountManagerGroupProperty.getLongValue();
if (groupKey != null) {
BusinessGroup accountManagerGroup = businessGroupService.loadBusinessGroup(groupKey);
if (accountManagerGroup != null) {
BusinessGroupService bgs = businessGroupService;
bgs.deleteBusinessGroup(accountManagerGroup);
log.audit("ProjectBroker: Deleted accountManagerGroup=" + accountManagerGroup);
} else {
log.debug("deleteAccountManagerGroup: accountManagerGroup=" + accountManagerGroup + " has already been deleted");
}
}
cpm.deleteProperty(accountManagerGroupProperty);
log.debug("deleteAccountManagerGroup: deleted accountManagerGroupProperty=" + accountManagerGroupProperty);
} else {
log.debug("deleteAccountManagerGroup: found no accountManagerGroup-key");
}
}
Aggregations