use of org.bimserver.models.log.LogAction in project BIMserver by opensourceBIM.
the class AdminServiceImpl method getLogs.
@Override
public List<SLogAction> getLogs() throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<List<LogAction>> action = new GetLogsDatabaseAction(session, getInternalAccessMethod(), getAuthorization());
List<LogAction> logs = session.executeAndCommitAction(action);
List<SLogAction> convertToSListLogAction = getBimServer().getSConverter().convertToSListLogAction(logs);
Collections.sort(convertToSListLogAction, new SLogComparator(true));
return convertToSListLogAction;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.log.LogAction in project BIMserver by opensourceBIM.
the class GetLogsDatabaseAction method execute.
@Override
public List<LogAction> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(authorization.getUoid());
if (user.getUserType() != UserType.ADMIN) {
throw new UserException("Only admin users can retrieve log");
}
Map<Long, LogAction> query = getDatabaseSession().query(new IsOfTypeCondition(LogPackage.eINSTANCE.getLogAction()), LogAction.class, OldQuery.getDefault());
ArrayList<LogAction> list = new ArrayList<LogAction>(query.values());
return list;
}
use of org.bimserver.models.log.LogAction in project BIMserver by opensourceBIM.
the class ServiceImpl method getUserRelatedLogs.
@Override
public List<SLogAction> getUserRelatedLogs(Long uoid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
List<LogAction> logActions = new ArrayList<LogAction>();
User user = session.get(getAuthorization().getUoid(), OldQuery.getDefault());
IfcModelInterface projectsModel = session.getAllOfType(StorePackage.eINSTANCE.getProject(), OldQuery.getDefault());
logActions.addAll(user.getLogs());
for (IdEObject idEObject : projectsModel.getValues()) {
if (idEObject instanceof Project) {
Project project = (Project) idEObject;
if ((user.getUserType() == UserType.ADMIN || (project.getState() == ObjectState.ACTIVE) && getAuthorization().hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project))) {
logActions.addAll(project.getLogs());
}
}
}
Collections.sort(logActions, new Comparator<LogAction>() {
@Override
public int compare(LogAction o1, LogAction o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
return getBimServer().getSConverter().convertToSListLogAction(logActions);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations