Free cookie consent management tool by TermsFeed Policy Generator

Changeset 902


Ignore:
Timestamp:
12/04/08 16:35:24 (16 years ago)
Author:
msteinbi
Message:

Implementation of UserRoleManager (#417)

Location:
trunk/sources
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/UserGroup.cs

    r795 r902  
    2929
    3030  [DataContract]
    31   public class UserGroup {
     31  public class UserGroup : PermissionOwner {
    3232    [DataMember]
    3333    public long UserGroupId { get; set; }
  • trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj

    r858 r902  
    7070  </ItemGroup>
    7171  <ItemGroup>
     72    <Compile Include="ApplicationConstants.cs" />
    7273    <Compile Include="BusinessObjects\GrantedPermissions.cs" />
    7374    <Compile Include="BusinessObjects\ClientGroup.cs" />
     
    9697    <Compile Include="Response.cs" />
    9798    <Compile Include="ResponseHB.cs" />
     99    <Compile Include="ResponseList.cs" />
    98100    <Compile Include="ResponseResultReceived.cs" />
    99101    <Compile Include="TestJob.cs" />
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IClientManager.cs

    r839 r902  
    1313  public interface IClientManager {
    1414    [OperationContract]
    15     List<ClientInfo> GetAllClients();
     15    ResponseList<ClientInfo> GetAllClients();
    1616    [OperationContract]
    1717    [ServiceKnownType(typeof (Resource))]
    1818    [ServiceKnownType(typeof(ClientInfo))]
    19     List<ClientGroup> GetAllClientGroups();
     19    ResponseList<ClientGroup> GetAllClientGroups();
    2020    [OperationContract]
    21     List<UpTimeStatistics> GetAllUpTimeStatistics();
     21    ResponseList<UpTimeStatistics> GetAllUpTimeStatistics();
    2222  }
    2323}
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IJobManager.cs

    r796 r902  
    1313  public interface IJobManager {
    1414    [OperationContract]
    15     List<Job> GetAllJobs();
     15    ResponseList<Job> GetAllJobs();
    1616  }
    1717}
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IUserRoleManager.cs

    r842 r902  
    1313  public interface IUserRoleManager {
    1414    [OperationContract]
    15     List<User> GetAllUsers();
     15    ResponseList<User> GetAllUsers();
    1616    [OperationContract]
    17     void AddNewUser(User user);
     17    Response AddNewUser(User user);
    1818    [OperationContract]
    19     List<UserGroup> GetAllUserGroups();
     19    Response RemoveUser(long userId);
     20    [OperationContract]
     21    Response AddNewUserGroup(UserGroup userGroup);
     22    [OperationContract]
     23    Response RemoveUserGroup(long groupId);
     24    [OperationContract]
     25    ResponseList<UserGroup> GetAllUserGroups();
     26    [OperationContract]
     27    Response AddUserToGroup(long groupId, long userId);
     28    [OperationContract]
     29    Response RemoveUserFromGroup(long groupId, long userId);
    2030  }
    2131}
  • trunk/sources/HeuristicLab.Hive.Contracts/ResponseJob.cs

    r823 r902  
    1 using System;
     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;
    223using System.Collections.Generic;
    324using System.Linq;
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r842 r902  
    4444          if (client.State != State.offline) {
    4545            response.Success = false;
    46             response.StatusMessage = rm.GetString("UserAllreadyOnline");
     46            response.StatusMessage = rm.GetString(ApplicationConstants.RESPONSE_LOGIN_USER_ALLREADY_ONLINE);
    4747            break;
    4848          } else
     
    5454        clientAdapter.UpdateClient(clientInfo);
    5555        response.Success = true;
    56         response.StatusMessage = rm.GetString("LoginSuccess");
     56        response.StatusMessage = rm.GetString(ApplicationConstants.RESPONSE_LOGIN_SUCCESS);
    5757      }
    5858
     
    9797                           
    9898    public Response Logout(Guid clientId) {
    99       bool clientRemoved = false;
    100       foreach (ClientInfo client in clients) {
    101         if (client.ClientId.Equals(clientId)) {
    102           clients.Remove(client);
    103           clientRemoved = true;
    104         }
    105       }
    10699      Response response = new Response();
    107100     
    108       if (clientRemoved) {
    109         response.Success = true;
    110         response.StatusMessage = "Successfully logged out. Good bye";
    111       } else {
     101      ClientInfo client = clientAdapter.GetClientById(clientId);
     102      if (client == null) {
    112103        response.Success = false;
    113         response.StatusMessage = "Sorry, but you weren't logged in";
     104        response.StatusMessage = rm.GetString(ApplicationConstants.RESPONSE_LOGOUT_CLIENT_NOT_REGISTERED);
     105        return response;
    114106      }
     107      client.State = State.offline;
     108      clientAdapter.UpdateClient(client);
     109
     110      response.Success = true;
     111      response.StatusMessage = rm.GetString(ApplicationConstants.RESPONSE_LOGOUT_SUCCESS);
     112     
    115113      return response;
    116114    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientManager.cs

    r837 r902  
    55using HeuristicLab.Hive.Contracts.Interfaces;
    66using HeuristicLab.Hive.Contracts.BusinessObjects;
     7using HeuristicLab.Hive.Contracts;
    78
    89namespace HeuristicLab.Hive.Server.Core {
     
    3536    #region IClientManager Members
    3637
    37     public List<ClientInfo> GetAllClients() {
    38       return clients;
     38    public ResponseList<ClientInfo> GetAllClients() {
     39      return null;
    3940    }
    4041
    41     public List<ClientGroup> GetAllClientGroups() {
    42       return clientGroups;
     42    public ResponseList<ClientGroup> GetAllClientGroups() {
     43      return null;
    4344    }
    4445
    45     public List<UpTimeStatistics> GetAllUpTimeStatistics() {
    46       return new List<UpTimeStatistics>();
     46    public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
     47      return null;
    4748    }
    4849
  • trunk/sources/HeuristicLab.Hive.Server.Core/HiveServerMessages.resx

    r897 r902  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <data name="LoginSuccess" xml:space="preserve">
     120  <data name="Login.ClientNotRegistered" xml:space="preserve">
     121    <value>Sorry this client was not registered yet</value>
     122  </data>
     123  <data name="Login.Success" xml:space="preserve">
    121124    <value>The Login was successfull</value>
    122125  </data>
    123   <data name="UserAllreadyOnline" xml:space="preserve">
     126  <data name="Logout.Success" xml:space="preserve">
     127    <value>You where logged out successfully. Good bye</value>
     128  </data>
     129  <data name="Logout.UserAllreadyOnline" xml:space="preserve">
    124130    <value>A User with this GUID is allready logged in</value>
    125131  </data>
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r820 r902  
    55using HeuristicLab.Hive.Contracts.Interfaces;
    66using HeuristicLab.Hive.Contracts.BusinessObjects;
     7using HeuristicLab.Hive.Contracts;
    78
    89namespace HeuristicLab.Hive.Server.Core {
     
    2122    }
    2223
    23     public List<Job> GetAllJobs() {
    24       return jobs;
     24    public ResponseList<Job> GetAllJobs() {
     25      return null;
    2526    }
    2627
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs

    r842 r902  
    55using HeuristicLab.Hive.Contracts.Interfaces;
    66using HeuristicLab.Hive.Contracts.BusinessObjects;
     7using HeuristicLab.Hive.Contracts;
    78
    89namespace HeuristicLab.Hive.Server.Core {
     
    1415    #region IClientManager Members
    1516
    16     public List<ClientInfo> GetAllClients() {
     17    public ResponseList<ClientInfo> GetAllClients() {
    1718      return clientManager.GetAllClients();
    1819    }
    1920
    20     public List<ClientGroup> GetAllClientGroups() {
     21    public ResponseList<ClientGroup> GetAllClientGroups() {
    2122      return clientManager.GetAllClientGroups();
    2223    }
    2324
    24     public List<UpTimeStatistics> GetAllUpTimeStatistics() {
     25    public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
    2526      return clientManager.GetAllUpTimeStatistics();
    2627    }
     
    3031    #region IJobManager Members
    3132
    32     public List<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetAllJobs() {
     33    public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetAllJobs() {
    3334      return jobManager.GetAllJobs();
    3435    }
     
    3839    #region IUserRoleManager Members
    3940
    40     public List<HeuristicLab.Hive.Contracts.BusinessObjects.User> GetAllUsers() {
     41    public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.User> GetAllUsers() {
    4142      return userRoleManager.GetAllUsers();
    4243    }
    4344
    44     public void AddNewUser(User user) {
    45       userRoleManager.AddNewUser(user);
     45    public Response AddNewUser(User user) {
     46      return userRoleManager.AddNewUser(user);
    4647    }
    4748
    48     public List<HeuristicLab.Hive.Contracts.BusinessObjects.UserGroup> GetAllUserGroups() {
     49    public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.UserGroup> GetAllUserGroups() {
    4950      return userRoleManager.GetAllUserGroups();
    5051    }
    5152
     53    public Response RemoveUser(long userId) {
     54      throw new NotImplementedException();
     55    }
     56
     57    public Response AddNewUserGroup(UserGroup userGroup) {
     58      throw new NotImplementedException();
     59    }
     60
     61    public Response RemoveUserGroup(long groupId) {
     62      throw new NotImplementedException();
     63    }
     64
     65    public Response AddUserToGroup(long groupId, long userId) {
     66      throw new NotImplementedException();
     67    }
     68
     69    public Response RemoveUserFromGroup(long groupId, long userId) {
     70      throw new NotImplementedException();
     71    }
     72
    5273    #endregion
     74
    5375  }
    5476}
  • trunk/sources/HeuristicLab.Hive.Server.Core/UserRoleManager.cs

    r845 r902  
    55using HeuristicLab.Hive.Contracts.Interfaces;
    66using HeuristicLab.Hive.Contracts.BusinessObjects;
     7using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
     8using System.Resources;
     9using System.Reflection;
     10using HeuristicLab.Hive.Contracts;
    711
    812namespace HeuristicLab.Hive.Server.Core {
     
    1216    List<UserGroup> userGroups;
    1317
     18    IUserAdapter userAdapter;
     19    ResourceManager rm;
     20
    1421    public UserRoleManager() {
     22      userAdapter = ServiceLocator.GetUserAdapter();
     23      rm = new ResourceManager("HiveServerMessages.resx", Assembly.GetExecutingAssembly());
     24
    1525      users = new List<User>();
    1626      userGroups = new List<UserGroup>();
     
    2636    #region IUserRoleManager Members
    2737
    28     public List<User> GetAllUsers() {
    29       return users;     
     38    public ResponseList<User> GetAllUsers() {
     39      return null;     
    3040    }
    3141
    32     public void AddNewUser(User user) {
     42    public Response AddNewUser(User user) {
     43      User dbUser = userAdapter.GetUserByName(user.Name);
    3344
     45      return null;
    3446    }
    3547
    36     public List<UserGroup> GetAllUserGroups() {
    37       return userGroups;
     48    public ResponseList<UserGroup> GetAllUserGroups() {
     49      return null;
     50    }
     51
     52    public Response RemoveUser(long userId) {
     53      return null;
     54    }
     55
     56    public Response AddNewUserGroup(UserGroup userGroup) {
     57      return null;
     58    }
     59
     60    public Response RemoveUserGroup(long groupId) {
     61      return null;
     62    }
     63
     64    public Response AddUserToGroup(long groupId, long userId) {
     65      throw new NotImplementedException();
     66    }
     67
     68    public Response RemoveUserFromGroup(long groupId, long userId) {
     69      throw new NotImplementedException();
    3870    }
    3971
Note: See TracChangeset for help on using the changeset viewer.