Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2269 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
Line 
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;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Hive.Contracts.Interfaces;
27using HeuristicLab.Hive.Contracts.BusinessObjects;
28using HeuristicLab.Hive.Contracts;
29using HeuristicLab.Security.Contracts.Interfaces;
30using HeuristicLab.Hive.Server.Core.InternalInterfaces;
31using System.ServiceModel;
32
33
34namespace HeuristicLab.Hive.Server.Core {
35  public class ServerConsoleFacade: IServerConsoleFacade {
36    private IClientManager clientManager =
37      ServiceLocator.GetClientManager();
38
39    private IJobManager jobManager =
40      ServiceLocator.GetJobManager();
41
42    private IHivePermissionManager secMan = ServiceLocator.GetHivePermissionManager();
43
44    public Guid sessionID = Guid.Empty;
45
46    public Response Login(string username, string password) {
47      Response resp = new Response();
48     
49      sessionID = secMan.Login(username, password);
50      if (sessionID == Guid.Empty) {
51        resp.Success = false;
52        resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED;
53      } else {
54        resp.Success = true;
55        resp.StatusMessage =
56          ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
57      }
58      return resp;
59    }
60
61
62    public ResponseList<ClientInfo> GetAllClients() {
63      secMan.Authorize("AccessClients", sessionID, Guid.Empty);
64      return clientManager.GetAllClients();
65    }
66
67    public ResponseList<ClientGroup> GetAllClientGroups() {
68      //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty);
69      return clientManager.GetAllClientGroups();
70    }
71
72    public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
73      secMan.Authorize("AccessStatistics", sessionID, Guid.Empty);
74      return clientManager.GetAllUpTimeStatistics();
75    }
76
77    public ResponseObject<ClientGroup> AddClientGroup(ClientGroup clientGroup) {
78      secMan.Authorize("AddClientGroup", sessionID, Guid.Empty);
79      return clientManager.AddClientGroup(clientGroup);
80    }
81
82    public Response AddResourceToGroup(Guid clientGroupId, Resource resource) {
83      secMan.Authorize("AddResource", sessionID, Guid.Empty);               
84      return clientManager.AddResourceToGroup(clientGroupId, resource);
85    }
86
87    public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
88        return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
89    }
90
91    public ResponseList<Job> GetAllJobs() {
92      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
93      return jobManager.GetAllJobs();
94    }
95
96    public ResponseObject<Job> GetJobById(Guid jobId) {
97      secMan.Authorize("AccessJobs", sessionID, jobId);
98      return jobManager.GetJobById(jobId);
99    }
100
101    public ResponseObject<Job> AddNewJob(SerializedJob job) {
102      secMan.Authorize("AddJob", sessionID, job.JobInfo.Id);
103      return jobManager.AddNewJob(job);
104    }
105
106    public ResponseObject<JobResult> GetLastJobResultOf(Guid jobId) {
107      secMan.Authorize("AccessJobResults", sessionID, jobId);
108      return jobManager.GetLastJobResultOf(jobId);
109    }
110
111    public ResponseObject<SerializedJobResult> GetLastSerializedJobResultOf(Guid jobId, bool requested) {
112      secMan.Authorize("AccessJobResults", sessionID, jobId);
113      return jobManager.GetLastSerializedJobResultOf(jobId, requested);
114    }
115
116    public ResponseList<JobResult> GetAllJobResults(Guid jobId) {
117      secMan.Authorize("AccessJobResults", sessionID, jobId); 
118      return jobManager.GetAllJobResults(jobId);
119    }
120
121    public Response RemoveJob(Guid jobId) {
122      secMan.Authorize("RemoveJob", sessionID, jobId);
123      return jobManager.RemoveJob(jobId);
124    }
125
126    public Response RequestSnapshot(Guid jobId) {
127      secMan.Authorize("AccessJobResults", sessionID, jobId); 
128      return jobManager.RequestSnapshot(jobId);
129    }
130
131    public Response AbortJob(Guid jobId) {
132      secMan.Authorize("AbortJob", sessionID, Guid.Empty);
133      return jobManager.AbortJob(jobId);
134    }
135
136    public ResponseObject<List<ClientGroup>> GetAllGroupsOfResource(Guid resourceId) {
137      secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty);
138      return clientManager.GetAllGroupsOfResource(resourceId);
139    }
140
141    public Response DeleteClientGroup(Guid clientGroupId) {
142      secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty);
143      return clientManager.DeleteClientGroup(clientGroupId);
144    }
145
146    public ResponseList<Project> GetAllProjects() {
147      secMan.Authorize("AccessProjects", sessionID, Guid.Empty);
148      return jobManager.GetAllProjects();
149    }
150
151    public Response CreateProject(Project project) {
152      secMan.Authorize("CreateProjects", sessionID, Guid.Empty);
153      return jobManager.CreateProject(project);
154    }
155
156    public Response ChangeProject(Project project) {
157      secMan.Authorize("ChangeProjects", sessionID, Guid.Empty);
158      return jobManager.ChangeProject(project);
159    }
160
161    public Response DeleteProject(Guid projectId) {
162      secMan.Authorize("DeleteProjects", sessionID, projectId);
163      return jobManager.DeleteProject(projectId);
164    }
165
166    public ResponseList<Job> GetJobsByProject(Guid projectId) {
167      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
168      return jobManager.GetJobsByProject(projectId);
169    }
170
171  }
172}
Note: See TracBrowser for help on using the repository browser.