Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs @ 2211

Last change on this file since 2211 was 2099, checked in by svonolfe, 15 years ago

Further avoided out of memory exceptions by updating the JobResult DAO (#372)

File size: 6.1 KB
RevLine 
[907]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
[800]23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Hive.Contracts.Interfaces;
27using HeuristicLab.Hive.Contracts.BusinessObjects;
[902]28using HeuristicLab.Hive.Contracts;
[1648]29using HeuristicLab.Security.Contracts.Interfaces;
[1769]30using HeuristicLab.Hive.Server.Core.InternalInterfaces;
[2065]31using System.ServiceModel;
[800]32
[2065]33
[800]34namespace HeuristicLab.Hive.Server.Core {
35  public class ServerConsoleFacade: IServerConsoleFacade {
[1099]36    private IClientManager clientManager =
37      ServiceLocator.GetClientManager();
[1084]38
[1099]39    private IJobManager jobManager =
40      ServiceLocator.GetJobManager();
41
[1769]42    private IHivePermissionManager secMan = ServiceLocator.GetHivePermissionManager();
[1084]43
[1648]44    public Guid sessionID = Guid.Empty;
45
[1086]46    public Response Login(string username, string password) {
47      Response resp = new Response();
[1801]48     
[1769]49      sessionID = secMan.Login(username, password);
[1800]50      if (sessionID == Guid.Empty) {
[1648]51        resp.Success = false;
[1800]52        resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED;
53      } else {
[1648]54        resp.Success = true;
55        resp.StatusMessage =
56          ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
57      }
[1086]58      return resp;
[1084]59    }
60
61
[902]62    public ResponseList<ClientInfo> GetAllClients() {
[2065]63      secMan.Authorize("AccessClients", sessionID, Guid.Empty);
64      return clientManager.GetAllClients();
[800]65    }
66
[902]67    public ResponseList<ClientGroup> GetAllClientGroups() {
[2067]68      //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty);
[2065]69      return clientManager.GetAllClientGroups();
[800]70    }
71
[902]72    public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
[2065]73      secMan.Authorize("AccessStatistics", sessionID, Guid.Empty);
74      return clientManager.GetAllUpTimeStatistics();
[800]75    }
76
[1825]77    public ResponseObject<ClientGroup> AddClientGroup(ClientGroup clientGroup) {
[2065]78      secMan.Authorize("AddClientGroup", sessionID, Guid.Empty);
79      return clientManager.AddClientGroup(clientGroup);
[934]80    }
81
[1449]82    public Response AddResourceToGroup(Guid clientGroupId, Resource resource) {
[2065]83      secMan.Authorize("AddResource", sessionID, Guid.Empty);               
84      return clientManager.AddResourceToGroup(clientGroupId, resource);
[934]85    }
86
[1449]87    public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
[1648]88        return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
[934]89    }
90
[2065]91    public ResponseList<Job> GetAllJobs() {
92      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
93      return jobManager.GetAllJobs();
[800]94    }
[1648]95
[2065]96    public ResponseObject<Job> GetJobById(Guid jobId) {
97      secMan.Authorize("AccessJobs", sessionID, jobId);
[2005]98      return jobManager.GetJobById(jobId);
99    }
100
[2092]101    public ResponseObject<Job> AddNewJob(SerializedJob job) {
[2082]102      secMan.Authorize("AddJob", sessionID, job.JobInfo.Id);
[2065]103      return jobManager.AddNewJob(job);
[967]104    }
[800]105
[2099]106    public ResponseObject<JobResult> GetLastJobResultOf(Guid jobId) {
[2065]107      secMan.Authorize("AccessJobResults", sessionID, jobId);
[2099]108      return jobManager.GetLastJobResultOf(jobId);
[1171]109    }
110
[2099]111    public ResponseObject<SerializedJobResult> GetLastSerializedJobResultOf(Guid jobId, bool requested) {
112      secMan.Authorize("AccessJobResults", sessionID, jobId);
113      return jobManager.GetLastSerializedJobResultOf(jobId, requested);
114    }
115
[1799]116    public ResponseList<JobResult> GetAllJobResults(Guid jobId) {
[2065]117      secMan.Authorize("AccessJobResults", sessionID, jobId); 
118      return jobManager.GetAllJobResults(jobId);
[1648]119    }
120
[1449]121    public Response RemoveJob(Guid jobId) {
[2065]122      secMan.Authorize("RemoveJob", sessionID, jobId);
123      return jobManager.RemoveJob(jobId);
[967]124    }
125
[1509]126    public Response RequestSnapshot(Guid jobId) {
[2065]127      secMan.Authorize("AccessJobResults", sessionID, jobId); 
128      return jobManager.RequestSnapshot(jobId);
[1509]129    }
130
131    public Response AbortJob(Guid jobId) {
[2065]132      secMan.Authorize("AbortJob", sessionID, Guid.Empty);
133      return jobManager.AbortJob(jobId);
[1509]134    }
135
[1769]136    public ResponseObject<List<ClientGroup>> GetAllGroupsOfResource(Guid resourceId) {
[2065]137      secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty);
138      return clientManager.GetAllGroupsOfResource(resourceId);
[1627]139    }
140
[1824]141    public Response DeleteClientGroup(Guid clientGroupId) {
[2065]142      secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty);
[1824]143      return clientManager.DeleteClientGroup(clientGroupId);
144    }
145
[1932]146    public ResponseList<Project> GetAllProjects() {
[2065]147      secMan.Authorize("AccessProjects", sessionID, Guid.Empty);
[1932]148      return jobManager.GetAllProjects();
149    }
150
151    public Response CreateProject(Project project) {
[2065]152      secMan.Authorize("CreateProjects", sessionID, Guid.Empty);
[1932]153      return jobManager.CreateProject(project);
154    }
155
156    public Response ChangeProject(Project project) {
[2065]157      secMan.Authorize("ChangeProjects", sessionID, Guid.Empty);
[1932]158      return jobManager.ChangeProject(project);
159    }
160
161    public Response DeleteProject(Guid projectId) {
[2065]162      secMan.Authorize("DeleteProjects", sessionID, projectId);
[1932]163      return jobManager.DeleteProject(projectId);
164    }
165
166    public ResponseList<Job> GetJobsByProject(Guid projectId) {
[2065]167      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
[1932]168      return jobManager.GetJobsByProject(projectId);
169    }
170
[800]171  }
172}
Note: See TracBrowser for help on using the repository browser.