Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3296 was 3220, checked in by kgrading, 14 years ago

improved the DAL further, changed minor details for the presentation (#830)

File size: 6.8 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
[2904]46    public ServerConsoleFacade() {     
47    }
48
[1086]49    public Response Login(string username, string password) {
50      Response resp = new Response();
[1801]51     
[1769]52      sessionID = secMan.Login(username, password);
[1800]53      if (sessionID == Guid.Empty) {
[1648]54        resp.Success = false;
[1800]55        resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED;
56      } else {
[1648]57        resp.Success = true;
58        resp.StatusMessage =
59          ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
60      }
[1086]61      return resp;
[1084]62    }
63
64
[3011]65    public ResponseList<ClientDto> GetAllClients() {
[2065]66      secMan.Authorize("AccessClients", sessionID, Guid.Empty);
67      return clientManager.GetAllClients();
[800]68    }
69
[3011]70    public ResponseList<ClientGroupDto> GetAllClientGroups() {
[2067]71      //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty);
[2065]72      return clientManager.GetAllClientGroups();
[800]73    }
74
[3011]75    public ResponseList<UpTimeStatisticsDto> GetAllUpTimeStatistics() {
[2065]76      secMan.Authorize("AccessStatistics", sessionID, Guid.Empty);
77      return clientManager.GetAllUpTimeStatistics();
[800]78    }
79
[3011]80    public ResponseObject<ClientGroupDto> AddClientGroup(ClientGroupDto clientGroup) {
[2065]81      secMan.Authorize("AddClientGroup", sessionID, Guid.Empty);
82      return clientManager.AddClientGroup(clientGroup);
[934]83    }
84
[3011]85    public Response AddResourceToGroup(Guid clientGroupId, ResourceDto resource) {
[2065]86      secMan.Authorize("AddResource", sessionID, Guid.Empty);               
87      return clientManager.AddResourceToGroup(clientGroupId, resource);
[934]88    }
89
[1449]90    public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
[1648]91        return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
[934]92    }
93
[3011]94    public ResponseList<JobDto> GetAllJobs() {
[2065]95      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
96      return jobManager.GetAllJobs();
[800]97    }
[1648]98
[3011]99    public ResponseObject<JobDto> GetJobById(Guid jobId) {
[2065]100      secMan.Authorize("AccessJobs", sessionID, jobId);
[2005]101      return jobManager.GetJobById(jobId);
102    }
103
[3011]104    public ResponseObject<JobDto> AddNewJob(SerializedJob job) {
[2082]105      secMan.Authorize("AddJob", sessionID, job.JobInfo.Id);
[2065]106      return jobManager.AddNewJob(job);
[967]107    }
[800]108
[3011]109    public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
[2065]110      secMan.Authorize("AccessJobResults", sessionID, jobId);
[2099]111      return jobManager.GetLastJobResultOf(jobId);
[1171]112    }
113
[3011]114    public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested) {
[2099]115      secMan.Authorize("AccessJobResults", sessionID, jobId);
116      return jobManager.GetLastSerializedJobResultOf(jobId, requested);
117    }
118
[1799]119    public ResponseList<JobResult> GetAllJobResults(Guid jobId) {
[2065]120      secMan.Authorize("AccessJobResults", sessionID, jobId); 
121      return jobManager.GetAllJobResults(jobId);
[1648]122    }
123
[1449]124    public Response RemoveJob(Guid jobId) {
[2065]125      secMan.Authorize("RemoveJob", sessionID, jobId);
126      return jobManager.RemoveJob(jobId);
[967]127    }
128
[1509]129    public Response RequestSnapshot(Guid jobId) {
[2065]130      secMan.Authorize("AccessJobResults", sessionID, jobId); 
131      return jobManager.RequestSnapshot(jobId);
[1509]132    }
133
134    public Response AbortJob(Guid jobId) {
[2065]135      secMan.Authorize("AbortJob", sessionID, Guid.Empty);
136      return jobManager.AbortJob(jobId);
[1509]137    }
138
[3011]139    public ResponseObject<List<ClientGroupDto>> GetAllGroupsOfResource(Guid resourceId) {
[2065]140      secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty);
141      return clientManager.GetAllGroupsOfResource(resourceId);
[1627]142    }
143
[1824]144    public Response DeleteClientGroup(Guid clientGroupId) {
[2065]145      secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty);
[1824]146      return clientManager.DeleteClientGroup(clientGroupId);
147    }
148
[3011]149    public ResponseList<ProjectDto> GetAllProjects() {
[2065]150      secMan.Authorize("AccessProjects", sessionID, Guid.Empty);
[1932]151      return jobManager.GetAllProjects();
152    }
153
[3011]154    public Response CreateProject(ProjectDto project) {
[2065]155      secMan.Authorize("CreateProjects", sessionID, Guid.Empty);
[1932]156      return jobManager.CreateProject(project);
157    }
158
[3011]159    public Response ChangeProject(ProjectDto project) {
[2065]160      secMan.Authorize("ChangeProjects", sessionID, Guid.Empty);
[1932]161      return jobManager.ChangeProject(project);
162    }
163
164    public Response DeleteProject(Guid projectId) {
[2065]165      secMan.Authorize("DeleteProjects", sessionID, projectId);
[1932]166      return jobManager.DeleteProject(projectId);
167    }
168
[3011]169    public ResponseList<JobDto> GetJobsByProject(Guid projectId) {
[2065]170      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
[1932]171      return jobManager.GetJobsByProject(projectId);
172    }
173
[3022]174    public ResponseList<AppointmentDto> GetUptimeCalendarForResource(Guid guid) {
175      return clientManager.GetUptimeCalendarForResource(guid);
176    }
177
[3203]178    public Response SetUptimeCalendarForResource(Guid guid, IEnumerable<AppointmentDto> appointments, bool isForced) {
179      return clientManager.SetUptimeCalendarForResource(guid, appointments, isForced);
[3022]180    }
[3203]181
[3220]182    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
183      return jobManager.AddJobWithGroupStrings(job, resources);
184    }
[800]185  }
186}
Note: See TracBrowser for help on using the repository browser.