Free cookie consent management tool by TermsFeed Policy Generator

Changeset 942 for trunk


Ignore:
Timestamp:
12/10/08 14:27:43 (16 years ago)
Author:
msteinbi
Message:

Implementation of Client Manager (#427)

Location:
trunk/sources
Files:
4 edited

Legend:

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

    r940 r942  
    2323    public static string RESPONSE_CLIENT_GET_ALL_CLIENTS = "Client.GetAllClients";
    2424    public static string RESPONSE_CLIENT_GET_ALL_CLIENTGROUPS = "Client.GetAllClientGroups";
     25    public static string RESPONSE_CLIENT_ID_MUST_NOT_BE_SET = "Client.IdMustNotBeSet";
     26    public static string RESPONSE_CLIENT_CLIENTGROUP_ADDED = "Client.ClientGroupAdded";
     27    public static string RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST = "Client.ClientGroupDoesntExist";
     28    public static string RESPONSE_CLIENT_RESOURCE_ADDED_TO_GROUP = "Client.ResourceAddedToGroup";
     29    public static string RESPONSE_CLIENT_RESOURCE_REMOVED = "Client.ResourceRemoved";
     30    public static string RESPONSE_CLIENT_RESOURCE_NOT_FOUND = "Client.ResourceNotFound";
    2531
    2632    public static string RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED = "Communicator.HeardbeatReceived";
  • trunk/sources/HeuristicLab.Hive.Contracts/HiveServerMessages.resx

    r937 r942  
    178178    <value>User successfully added to database</value>
    179179  </data>
     180  <data name="Client.ClientGroupAdded" xml:space="preserve">
     181    <value>ClientGroup successfully added</value>
     182  </data>
     183  <data name="Client.ClientGroupDoesntExist" xml:space="preserve">
     184    <value>The specified ClientGroup doesn't exist</value>
     185  </data>
     186  <data name="Client.IdMustNotBeSet" xml:space="preserve">
     187    <value>In this context the id must not be set</value>
     188  </data>
     189  <data name="Client.ResourceAddedToGroup" xml:space="preserve">
     190    <value>Resource successfully added to ClientGroup</value>
     191  </data>
     192  <data name="Client.ResourceRemoved" xml:space="preserve">
     193    <value>Resource successfully removed from ClientGroup</value>
     194  </data>
    180195  <data name="UserRole.IdMustNotBeSet" xml:space="preserve">
    181196    <value>In this context the id must not be set</value>
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientManager.cs

    r937 r942  
    8080      Response response = new Response();
    8181
    82       ClientGroup clientGroupFromDb = clientGroupAdapter.GetClientGroupById(clientGroup.ResourceId);
    83      
     82      if (clientGroup.ResourceId != 0) {
     83        response.Success = false;
     84        response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_ID_MUST_NOT_BE_SET;
     85        return response;
     86      }
     87      clientGroupAdapter.UpdateClientGroup(clientGroup);
     88      response.Success = true;
     89      response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_ADDED;
    8490
    8591      return response;
     
    8793
    8894    public Response AddResourceToGroup(long clientGroupId, Resource resource) {
    89       throw new NotImplementedException();
     95      Response response = new Response();
     96
     97      if (resource.ResourceId != 0) {
     98        response.Success = false;
     99        response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_ID_MUST_NOT_BE_SET;
     100        return response;
     101      }
     102
     103      ClientGroup clientGroup = clientGroupAdapter.GetClientGroupById(clientGroupId);
     104      if (clientGroup == null) {
     105        response.Success = false;
     106        response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST;
     107        return response;
     108      }
     109      clientGroup.Resources.Add(resource);
     110
     111      response.Success = true;
     112      response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_ADDED_TO_GROUP;
     113
     114      return response;
    90115    }
    91116
    92117    public Response DeleteResourceFromGroup(long clientGroupId, long resourceId) {
    93       throw new NotImplementedException();
     118      Response response = new Response();
     119
     120      ClientGroup clientGroup = clientGroupAdapter.GetClientGroupById(clientGroupId);
     121      if (clientGroup == null) {
     122        response.Success = false;
     123        response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST;
     124        return response;
     125      }
     126      foreach (Resource resource in clientGroup.Resources) {
     127        if (resource.ResourceId == resourceId) {
     128          clientGroup.Resources.Remove(resource);
     129          response.Success = true;
     130          response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_REMOVED;
     131          return response;
     132        }
     133      }
     134      response.Success = false;
     135      response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
     136
     137      return response;
    94138    }
    95139    #endregion
  • trunk/sources/HeuristicLab.Hive.Server.Core/UserRoleManager.cs

    r937 r942  
    3737      Response response = new Response();
    3838
    39       if (user.PermissionOwnerId != null) {
     39      if (user.PermissionOwnerId != 0) {
    4040        response.Success = false;
    4141        response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_ID_MUST_NOT_BE_SET;
     
    7777      Response response = new Response();
    7878     
    79       if (userGroup.PermissionOwnerId != null) {
     79      if (userGroup.PermissionOwnerId != 0) {
    8080        response.Success = false;
    8181        response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_ID_MUST_NOT_BE_SET;
     
    108108      Response response = new Response();
    109109
    110       if (permissionOwner.PermissionOwnerId != null) {
     110      if (permissionOwner.PermissionOwnerId != 0) {
    111111        response.Success = false;
    112112        response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_ID_MUST_NOT_BE_SET;
Note: See TracChangeset for help on using the changeset viewer.