Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7916


Ignore:
Timestamp:
05/29/12 14:04:59 (12 years ago)
Author:
jkarder
Message:

#1860:

  • integrated owner attribute (OwnerUserId) into the Hive components
  • adjusted database scheme
  • adjusted service methods
Location:
trunk/sources
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj

    r7582 r7916  
    119119    <Compile Include="HiveAdminClient.cs" />
    120120    <Compile Include="HiveClient.cs" />
     121    <Compile Include="ServiceClients\ResourcePermission.cs" />
    121122    <Compile Include="Settings.Designer.cs">
    122123      <AutoGen>True</AutoGen>
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r7862 r7916  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.544
     4//     Runtime Version:4.0.30319.269
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    1919  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.StateLog))]
    2020  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Task))]
     21  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.ResourcePermission))]
    2122  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))]
    2223  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.JobPermission))]
     
    5960
    6061    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    61 
    62 
    6362  }
    6463
     
    416415          this.PriorityField = value;
    417416          this.RaisePropertyChanged("Priority");
     417        }
     418      }
     419    }
     420  }
     421
     422  [System.Diagnostics.DebuggerStepThroughAttribute()]
     423  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     424  [System.Runtime.Serialization.DataContractAttribute(Name = "ResourcePermission", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     425  [System.SerializableAttribute()]
     426  public partial class ResourcePermission : HeuristicLab.Clients.Hive.HiveItem {
     427
     428    [System.Runtime.Serialization.OptionalFieldAttribute()]
     429    private System.Guid GrantedByUserIdField;
     430
     431    [System.Runtime.Serialization.OptionalFieldAttribute()]
     432    private System.Guid GrantedUserIdField;
     433
     434    [System.Runtime.Serialization.OptionalFieldAttribute()]
     435    private System.Guid ResourceIdField;
     436
     437    [System.Runtime.Serialization.DataMemberAttribute()]
     438    public System.Guid GrantedByUserId {
     439      get {
     440        return this.GrantedByUserIdField;
     441      }
     442      set {
     443        if ((this.GrantedByUserIdField.Equals(value) != true)) {
     444          this.GrantedByUserIdField = value;
     445          this.RaisePropertyChanged("GrantedByUserId");
     446        }
     447      }
     448    }
     449
     450    [System.Runtime.Serialization.DataMemberAttribute()]
     451    public System.Guid GrantedUserId {
     452      get {
     453        return this.GrantedUserIdField;
     454      }
     455      set {
     456        if ((this.GrantedUserIdField.Equals(value) != true)) {
     457          this.GrantedUserIdField = value;
     458          this.RaisePropertyChanged("GrantedUserId");
     459        }
     460      }
     461    }
     462
     463    [System.Runtime.Serialization.DataMemberAttribute()]
     464    public System.Guid ResourceId {
     465      get {
     466        return this.ResourceIdField;
     467      }
     468      set {
     469        if ((this.ResourceIdField.Equals(value) != true)) {
     470          this.ResourceIdField = value;
     471          this.RaisePropertyChanged("ResourceId");
    418472        }
    419473      }
     
    912966
    913967    [System.Runtime.Serialization.OptionalFieldAttribute()]
     968    private System.Nullable<System.Guid> OwnerUserIdField;
     969
     970    [System.Runtime.Serialization.OptionalFieldAttribute()]
    914971    private System.Nullable<System.Guid> ParentResourceIdField;
    915972
     
    923980          this.HbIntervalField = value;
    924981          this.RaisePropertyChanged("HbInterval");
     982        }
     983      }
     984    }
     985
     986    [System.Runtime.Serialization.DataMemberAttribute()]
     987    public System.Nullable<System.Guid> OwnerUserId {
     988      get {
     989        return this.OwnerUserIdField;
     990      }
     991      set {
     992        if ((this.OwnerUserIdField.Equals(value) != true)) {
     993          this.OwnerUserIdField = value;
     994          this.RaisePropertyChanged("OwnerUserId");
    925995        }
    926996      }
     
    16211691    int GetNewHeartbeatInterval(System.Guid slaveId);
    16221692
     1693    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GrantResourcePermission", ReplyAction = "http://tempuri.org/IHiveService/GrantResourcePermissionResponse")]
     1694    void GrantResourcePermission(System.Guid slaveId, System.Guid grantedUserId);
     1695
     1696    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/RevokeResourcePermission", ReplyAction = "http://tempuri.org/IHiveService/RevokeResourcePermissionResponse")]
     1697    void RevokeResourcePermission(System.Guid slaveId, System.Guid grantedUserId);
     1698
     1699    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlavePermissions", ReplyAction = "http://tempuri.org/IHiveService/GetSlavePermissionsResponse")]
     1700    System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetSlavePermissions(System.Guid slaveId);
     1701
    16231702    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddDowntime", ReplyAction = "http://tempuri.org/IHiveService/AddDowntimeResponse")]
    16241703    System.Guid AddDowntime(HeuristicLab.Clients.Hive.Downtime downtime);
     
    18301909    }
    18311910
     1911    public void GrantResourcePermission(System.Guid slaveId, System.Guid grantedUserId) {
     1912      base.Channel.GrantResourcePermission(slaveId, grantedUserId);
     1913    }
     1914
     1915    public void RevokeResourcePermission(System.Guid slaveId, System.Guid grantedUserId) {
     1916      base.Channel.RevokeResourcePermission(slaveId, grantedUserId);
     1917    }
     1918
     1919    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetSlavePermissions(System.Guid slaveId) {
     1920      return base.Channel.GetSlavePermissions(slaveId);
     1921    }
     1922
    18321923    public System.Guid AddDowntime(HeuristicLab.Clients.Hive.Downtime downtime) {
    18331924      return base.Channel.AddDowntime(downtime);
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml

    r7862 r7916  
    3737      <Column Name="ParentResourceId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
    3838      <Column Name="HbInterval" Type="System.Int32" DbType="Int" CanBeNull="false" />
     39      <Column Name="OwnerUserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
    3940      <Association Name="Resource_AssignedResource" Member="AssignedResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedResource" />
    4041      <Association Name="Resource_Resource" Member="ChildResources" ThisKey="ResourceId" OtherKey="ParentResourceId" Type="Resource" />
    4142      <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" />
    4243      <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" />
     44      <Association Name="Resource_SlavePermission" Member="ResourcePermissions" ThisKey="ResourceId" OtherKey="ResourceId" Type="ResourcePermission" />
    4345      <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
    4446      <Type Name="Slave" InheritanceCode="Slave" IsInheritanceDefault="true">
     
    193195    </Type>
    194196  </Table>
     197  <Table Name="dbo.ResourcePermission" Member="ResourcePermissions">
     198    <Type Name="ResourcePermission">
     199      <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     200      <Column Name="GrantedUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     201      <Column Name="GrantedByUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />
     202      <Association Name="Resource_SlavePermission" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
     203    </Type>
     204  </Table>
    195205</Database>
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout

    r7862 r7916  
    33  <DataContextMoniker Name="/HiveDataContext" />
    44  <nestedChildShapes>
    5     <classShape Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" absoluteBounds="8.875, 4.25, 2, 1.1939925130208327">
     5    <classShape Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" absoluteBounds="8.875, 4.5, 2, 1.1939925130208327">
    66      <DataClassMoniker Name="/HiveDataContext/AssignedResource" />
    77      <nestedChildShapes>
    8         <elementListCompartment Id="8b005775-f0ee-41b0-ae10-6d1151003708" absoluteBounds="8.89, 4.7100000000000009, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    9       </nestedChildShapes>
    10     </classShape>
    11     <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="8.875, 5.625, 2, 1.9631982421874996">
     8        <elementListCompartment Id="8b005775-f0ee-41b0-ae10-6d1151003708" absoluteBounds="8.89, 4.9600000000000009, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     9      </nestedChildShapes>
     10    </classShape>
     11    <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="8.875, 5.875, 2, 1.9631982421874996">
    1212      <DataClassMoniker Name="/HiveDataContext/Plugin" />
    1313      <nestedChildShapes>
    14         <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="8.89, 6.0850000000000009, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    15       </nestedChildShapes>
    16     </classShape>
    17     <classShape Id="97b00810-fa30-457e-b484-b4e80b22f91b" absoluteBounds="6.5, 5.625, 2, 1.3862939453124987">
     14        <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="8.89, 6.3350000000000009, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     15      </nestedChildShapes>
     16    </classShape>
     17    <classShape Id="97b00810-fa30-457e-b484-b4e80b22f91b" absoluteBounds="6.5, 5.875, 2, 1.3862939453124987">
    1818      <DataClassMoniker Name="/HiveDataContext/RequiredPlugin" />
    1919      <nestedChildShapes>
    20         <elementListCompartment Id="df6451e5-069e-4ca0-a909-61b8213b5047" absoluteBounds="6.5150000000000006, 6.0850000000000009, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    21       </nestedChildShapes>
    22     </classShape>
    23     <classShape Id="706a4581-6daf-4e71-ae2a-87d50b27a051" absoluteBounds="11.25, 1, 2, 1.7708968098958331">
     20        <elementListCompartment Id="df6451e5-069e-4ca0-a909-61b8213b5047" absoluteBounds="6.5150000000000006, 6.3350000000000009, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     21      </nestedChildShapes>
     22    </classShape>
     23    <classShape Id="706a4581-6daf-4e71-ae2a-87d50b27a051" absoluteBounds="11.25, 1, 2, 1.9631982421875">
    2424      <DataClassMoniker Name="/HiveDataContext/Resource" />
    2525      <nestedChildShapes>
    26         <elementListCompartment Id="8c24f5bf-2164-4d0f-832e-1730eb0066df" absoluteBounds="11.265, 1.46, 1.9700000000000002, 1.2108968098958333" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     26        <elementListCompartment Id="8c24f5bf-2164-4d0f-832e-1730eb0066df" absoluteBounds="11.265, 1.46, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    2727      </nestedChildShapes>
    2828    </classShape>
     
    5757      </nestedChildShapes>
    5858    </classShape>
    59     <inheritanceConnector edgePoints="[(11.25 : 1.88544840494792); (10.875 : 1.88544840494792)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
     59    <inheritanceConnector edgePoints="[(11.25 : 1.98159912109375); (10.875 : 1.98159912109375)]" fixedFrom="Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
    6060      <nodes>
    6161        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     
    6363      </nodes>
    6464    </inheritanceConnector>
    65     <inheritanceConnector edgePoints="[(13.25 : 1.40469482421875); (13.5 : 1.40469482421875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
     65    <inheritanceConnector edgePoints="[(13.25 : 1.40469482421875); (13.5 : 1.40469482421875)]" fixedFrom="Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
    6666      <nodes>
    6767        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     
    6969      </nodes>
    7070    </inheritanceConnector>
    71     <associationConnector edgePoints="[(11.92578 : 2.77089680989583); (11.92578 : 4.84699625651042); (10.875 : 4.84699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     71    <associationConnector edgePoints="[(11.8134963640734 : 2.9631982421875); (11.8134963640734 : 3.56770833333333); (11.1119791666667 : 3.56770833333333); (11.1119791666667 : 5.09699625651042); (10.875 : 5.09699625651042)]" manuallyRouted="true" fixedFrom="NotFixed" fixedTo="NotFixed">
    7272      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedResource" />
    7373      <nodes>
     
    8282      </nestedChildShapes>
    8383    </classShape>
    84     <classShape Id="ad25bd0f-80e8-4a06-abd8-190eb678eec7" absoluteBounds="11.25, 5.625, 2, 1.5785953776041666">
     84    <classShape Id="ad25bd0f-80e8-4a06-abd8-190eb678eec7" absoluteBounds="11.25, 5.875, 2, 1.5785953776041666">
    8585      <DataClassMoniker Name="/HiveDataContext/PluginData" />
    8686      <nestedChildShapes>
    87         <elementListCompartment Id="acddb513-7de6-4bb4-8335-d6982fb2ef35" absoluteBounds="11.265, 6.0850000000000009, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    88       </nestedChildShapes>
    89     </classShape>
    90     <associationConnector edgePoints="[(10.875 : 6.41429768880208); (11.25 : 6.41429768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     87        <elementListCompartment Id="acddb513-7de6-4bb4-8335-d6982fb2ef35" absoluteBounds="11.265, 6.3350000000000009, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     88      </nestedChildShapes>
     89    </classShape>
     90    <associationConnector edgePoints="[(10.875 : 6.66429768880208); (11.25 : 6.66429768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    9191      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_PluginData" />
    9292      <nodes>
     
    9595      </nodes>
    9696    </associationConnector>
    97     <associationConnector edgePoints="[(8.875 : 6.31814697265625); (8.5 : 6.31814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     97    <associationConnector edgePoints="[(8.875 : 6.56814697265625); (8.5 : 6.56814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    9898      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_RequiredPlugin" />
    9999      <nodes>
     
    102102      </nodes>
    103103    </associationConnector>
    104     <associationConnector edgePoints="[(13.25 : 1.62798725335537); (13.5 : 1.62798725335537); (13.5 : 2.1551696113782); (13.25 : 2.1551696113782)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     104    <associationConnector edgePoints="[(11.9586362792969 : 1); (11.9586362792969 : 0.75); (12.5552381835937 : 0.75); (12.5552381835937 : 1)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    105105      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Resource" />
    106106      <nodes>
     
    121121      </nestedChildShapes>
    122122    </classShape>
    123     <associationConnector edgePoints="[(11.25 : 1.41147220247396); (10.9375 : 1.41147220247396); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     123    <associationConnector edgePoints="[(11.25 : 1.45954756054688); (10.9375 : 1.45954756054688); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    124124      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" />
    125125      <nodes>
     
    172172      </nodes>
    173173    </associationConnector>
    174     <associationConnector edgePoints="[(12.664065 : 2.77089680989583); (12.664065 : 3.7131987421875); (13.5 : 3.7131987421875)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     174    <associationConnector edgePoints="[(13.25 : 2.73159912109375); (13.5 : 2.73159912109375)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    175175      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Downtime" />
    176176      <nodes>
     
    179179      </nodes>
    180180    </associationConnector>
    181     <associationConnector edgePoints="[(7.5 : 4.30930826822917); (7.5 : 4.876650890625); (7.97916666666667 : 4.876650890625 : JumpStart); (8.14583333333333 : 4.876650890625 : JumpEnd); (8.875 : 4.876650890625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     181    <associationConnector edgePoints="[(7.96163946463664 : 4.30930826822917); (7.96163946463664 : 5.09699625651042); (8.875 : 5.09699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    182182      <AssociationMoniker Name="/HiveDataContext/Task/Task_AssignedResource" />
    183183      <nodes>
     
    186186      </nodes>
    187187    </associationConnector>
    188     <associationConnector edgePoints="[(8.0625 : 4.30930826822917); (8.0625 : 5.625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     188    <associationConnector edgePoints="[(7.16831973231832 : 4.30930826822917); (7.16831973231832 : 5.875)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    189189      <AssociationMoniker Name="/HiveDataContext/Task/Task_RequiredPlugin" />
    190190      <nodes>
     
    228228      </nodes>
    229229    </associationConnector>
     230    <classShape Id="a3f352be-9f15-4e73-8d44-3e8ac02fb4cf" absoluteBounds="11.25, 3.875, 2, 1.3862939453124996">
     231      <DataClassMoniker Name="/HiveDataContext/ResourcePermission" />
     232      <nestedChildShapes>
     233        <elementListCompartment Id="45e2f1a8-8a1e-4647-b649-10ec55976ab4" absoluteBounds="11.265, 4.335, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     234      </nestedChildShapes>
     235    </classShape>
     236    <associationConnector edgePoints="[(12.5942481820367 : 2.9631982421875); (12.5942481820367 : 3.875)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     237      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_SlavePermission" />
     238      <nodes>
     239        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     240        <classShapeMoniker Id="a3f352be-9f15-4e73-8d44-3e8ac02fb4cf" />
     241      </nodes>
     242    </associationConnector>
    230243  </nestedChildShapes>
    231244</ordesignerObjectsDiagram>
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs

    r7862 r7916  
    33// <auto-generated>
    44//     This code was generated by a tool.
    5 //     Runtime Version:4.0.30319.544
     5//     Runtime Version:4.0.30319.269
    66//
    77//     Changes to this file may cause incorrect behavior and will be lost if
     
    7979    partial void UpdateStatistics(Statistics instance);
    8080    partial void DeleteStatistics(Statistics instance);
     81    partial void InsertResourcePermission(ResourcePermission instance);
     82    partial void UpdateResourcePermission(ResourcePermission instance);
     83    partial void DeleteResourcePermission(ResourcePermission instance);
    8184    #endregion
    8285   
     
    236239      {
    237240        return this.GetTable<Statistics>();
     241      }
     242    }
     243   
     244    public System.Data.Linq.Table<ResourcePermission> ResourcePermissions
     245    {
     246      get
     247      {
     248        return this.GetTable<ResourcePermission>();
    238249      }
    239250    }
     
    857868    private int _HbInterval;
    858869   
     870    private System.Nullable<System.Guid> _OwnerUserId;
     871   
    859872    private EntitySet<AssignedResource> _AssignedResources;
    860873   
     
    864877   
    865878    private EntitySet<StateLog> _StateLogs;
     879   
     880    private EntitySet<ResourcePermission> _ResourcePermissions;
    866881   
    867882    private EntityRef<Resource> _ParentResource;
     
    881896    partial void OnHbIntervalChanging(int value);
    882897    partial void OnHbIntervalChanged();
     898    partial void OnOwnerUserIdChanging(System.Nullable<System.Guid> value);
     899    partial void OnOwnerUserIdChanged();
    883900    #endregion
    884901   
     
    889906      this._UptimeCalendars = new EntitySet<Downtime>(new Action<Downtime>(this.attach_UptimeCalendars), new Action<Downtime>(this.detach_UptimeCalendars));
    890907      this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs));
     908      this._ResourcePermissions = new EntitySet<ResourcePermission>(new Action<ResourcePermission>(this.attach_ResourcePermissions), new Action<ResourcePermission>(this.detach_ResourcePermissions));
    891909      this._ParentResource = default(EntityRef<Resource>);
    892910      OnCreated();
     
    9971015    }
    9981016   
     1017    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OwnerUserId", DbType="UniqueIdentifier")]
     1018    public System.Nullable<System.Guid> OwnerUserId
     1019    {
     1020      get
     1021      {
     1022        return this._OwnerUserId;
     1023      }
     1024      set
     1025      {
     1026        if ((this._OwnerUserId != value))
     1027        {
     1028          this.OnOwnerUserIdChanging(value);
     1029          this.SendPropertyChanging();
     1030          this._OwnerUserId = value;
     1031          this.SendPropertyChanged("OwnerUserId");
     1032          this.OnOwnerUserIdChanged();
     1033        }
     1034      }
     1035    }
     1036   
    9991037    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedResource", Storage="_AssignedResources", ThisKey="ResourceId", OtherKey="ResourceId")]
    10001038    public EntitySet<AssignedResource> AssignedResources
     
    10461084      {
    10471085        this._StateLogs.Assign(value);
     1086      }
     1087    }
     1088   
     1089    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_SlavePermission", Storage="_ResourcePermissions", ThisKey="ResourceId", OtherKey="ResourceId")]
     1090    public EntitySet<ResourcePermission> ResourcePermissions
     1091    {
     1092      get
     1093      {
     1094        return this._ResourcePermissions;
     1095      }
     1096      set
     1097      {
     1098        this._ResourcePermissions.Assign(value);
    10481099      }
    10491100    }
     
    11461197   
    11471198    private void detach_StateLogs(StateLog entity)
     1199    {
     1200      this.SendPropertyChanging();
     1201      entity.Resource = null;
     1202    }
     1203   
     1204    private void attach_ResourcePermissions(ResourcePermission entity)
     1205    {
     1206      this.SendPropertyChanging();
     1207      entity.Resource = this;
     1208    }
     1209   
     1210    private void detach_ResourcePermissions(ResourcePermission entity)
    11481211    {
    11491212      this.SendPropertyChanging();
     
    41994262    }
    42004263  }
     4264 
     4265  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ResourcePermission")]
     4266  public partial class ResourcePermission : INotifyPropertyChanging, INotifyPropertyChanged
     4267  {
     4268   
     4269    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
     4270   
     4271    private System.Guid _ResourceId;
     4272   
     4273    private System.Guid _GrantedUserId;
     4274   
     4275    private System.Guid _GrantedByUserId;
     4276   
     4277    private EntityRef<Resource> _Resource;
     4278   
     4279    #region Extensibility Method Definitions
     4280    partial void OnLoaded();
     4281    partial void OnValidate(System.Data.Linq.ChangeAction action);
     4282    partial void OnCreated();
     4283    partial void OnResourceIdChanging(System.Guid value);
     4284    partial void OnResourceIdChanged();
     4285    partial void OnGrantedUserIdChanging(System.Guid value);
     4286    partial void OnGrantedUserIdChanged();
     4287    partial void OnGrantedByUserIdChanging(System.Guid value);
     4288    partial void OnGrantedByUserIdChanged();
     4289    #endregion
     4290   
     4291    public ResourcePermission()
     4292    {
     4293      this._Resource = default(EntityRef<Resource>);
     4294      OnCreated();
     4295    }
     4296   
     4297    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
     4298    public System.Guid ResourceId
     4299    {
     4300      get
     4301      {
     4302        return this._ResourceId;
     4303      }
     4304      set
     4305      {
     4306        if ((this._ResourceId != value))
     4307        {
     4308          if (this._Resource.HasLoadedOrAssignedValue)
     4309          {
     4310            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     4311          }
     4312          this.OnResourceIdChanging(value);
     4313          this.SendPropertyChanging();
     4314          this._ResourceId = value;
     4315          this.SendPropertyChanged("ResourceId");
     4316          this.OnResourceIdChanged();
     4317        }
     4318      }
     4319    }
     4320   
     4321    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedUserId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
     4322    public System.Guid GrantedUserId
     4323    {
     4324      get
     4325      {
     4326        return this._GrantedUserId;
     4327      }
     4328      set
     4329      {
     4330        if ((this._GrantedUserId != value))
     4331        {
     4332          this.OnGrantedUserIdChanging(value);
     4333          this.SendPropertyChanging();
     4334          this._GrantedUserId = value;
     4335          this.SendPropertyChanged("GrantedUserId");
     4336          this.OnGrantedUserIdChanged();
     4337        }
     4338      }
     4339    }
     4340   
     4341    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedByUserId", DbType="UniqueIdentifier NOT NULL")]
     4342    public System.Guid GrantedByUserId
     4343    {
     4344      get
     4345      {
     4346        return this._GrantedByUserId;
     4347      }
     4348      set
     4349      {
     4350        if ((this._GrantedByUserId != value))
     4351        {
     4352          this.OnGrantedByUserIdChanging(value);
     4353          this.SendPropertyChanging();
     4354          this._GrantedByUserId = value;
     4355          this.SendPropertyChanged("GrantedByUserId");
     4356          this.OnGrantedByUserIdChanged();
     4357        }
     4358      }
     4359    }
     4360   
     4361    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_SlavePermission", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]
     4362    public Resource Resource
     4363    {
     4364      get
     4365      {
     4366        return this._Resource.Entity;
     4367      }
     4368      set
     4369      {
     4370        Resource previousValue = this._Resource.Entity;
     4371        if (((previousValue != value)
     4372              || (this._Resource.HasLoadedOrAssignedValue == false)))
     4373        {
     4374          this.SendPropertyChanging();
     4375          if ((previousValue != null))
     4376          {
     4377            this._Resource.Entity = null;
     4378            previousValue.ResourcePermissions.Remove(this);
     4379          }
     4380          this._Resource.Entity = value;
     4381          if ((value != null))
     4382          {
     4383            value.ResourcePermissions.Add(this);
     4384            this._ResourceId = value.ResourceId;
     4385          }
     4386          else
     4387          {
     4388            this._ResourceId = default(System.Guid);
     4389          }
     4390          this.SendPropertyChanged("Resource");
     4391        }
     4392      }
     4393    }
     4394   
     4395    public event PropertyChangingEventHandler PropertyChanging;
     4396   
     4397    public event PropertyChangedEventHandler PropertyChanged;
     4398   
     4399    protected virtual void SendPropertyChanging()
     4400    {
     4401      if ((this.PropertyChanging != null))
     4402      {
     4403        this.PropertyChanging(this, emptyChangingEventArgs);
     4404      }
     4405    }
     4406   
     4407    protected virtual void SendPropertyChanged(String propertyName)
     4408    {
     4409      if ((this.PropertyChanged != null))
     4410      {
     4411        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     4412      }
     4413    }
     4414  }
    42014415}
    42024416#pragma warning restore 1591
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql

    r7857 r7916  
    4242  [HbInterval] int NOT NULL,
    4343  [IsDisposable] Bit,
     44  [OwnerUserId] UniqueIdentifier,
    4445  CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
     46  )
     47CREATE TABLE [dbo].[ResourcePermission](
     48  [ResourceId] UniqueIdentifier NOT NULL,
     49  [GrantedUserId] UniqueIdentifier NOT NULL,
     50  [GrantedByUserId] UniqueIdentifier NOT NULL,
     51  CONSTRAINT [PK_dbo.ResourcePermission] PRIMARY KEY ([ResourceId], [GrantedUserId])
    4552  )
    4653CREATE TABLE [dbo].[Task](
     
    156163ALTER TABLE [dbo].[Resource]
    157164  ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
     165ALTER TABLE [dbo].[ResourcePermission]
     166  ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
    158167ALTER TABLE [dbo].[Task]
    159168  ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql

    r7814 r7916  
    8383ALTER TABLE [dbo].[JobPermission]  WITH CHECK ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY([JobId])
    8484REFERENCES [dbo].[Job] ([JobId])
     85ON UPDATE CASCADE
     86ON DELETE CASCADE
     87GO
     88
     89ALTER TABLE [dbo].[ResourcePermission]  DROP  CONSTRAINT [Resource_ResourcePermission]
     90ALTER TABLE [dbo].[ResourcePermission]  WITH CHECK ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY([ResourceId])
     91REFERENCES [dbo].[Resource] ([ResourceId])
    8592ON UPDATE CASCADE
    8693ON DELETE CASCADE
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r7857 r7916  
    200200    #endregion
    201201
     202    #region Resource
     203    public static DT.Resource ToDto(DB.Resource source) {
     204      if (source == null) return null;
     205      return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId };
     206    }
     207    public static DB.Resource ToEntity(DT.Resource source) {
     208      if (source == null) return null;
     209      var entity = new DB.Resource(); ToEntity(source, entity);
     210      return entity;
     211    }
     212    public static void ToEntity(DT.Resource source, DB.Resource target) {
     213      if ((source != null) && (target != null)) {
     214        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId;
     215      }
     216    }
     217    #endregion
     218
     219    #region SlaveGroup
     220    public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
     221      if (source == null) return null;
     222      return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId };
     223    }
     224    public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
     225      if (source == null) return null;
     226      var entity = new DB.SlaveGroup(); ToEntity(source, entity);
     227      return entity;
     228    }
     229    public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
     230      if ((source != null) && (target != null)) {
     231        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId;
     232      }
     233    }
     234    #endregion
     235
    202236    #region Slave
    203237    public static DT.Slave ToDto(DB.Slave source) {
     
    219253        CpuUtilization = source.CpuUtilization,
    220254        HbInterval = source.HbInterval,
    221         IsDisposable = source.IsDisposable
     255        IsDisposable = source.IsDisposable,
     256        OwnerUserId = source.OwnerUserId
    222257      };
    223258    }
     
    245280        target.HbInterval = source.HbInterval;
    246281        target.IsDisposable = source.IsDisposable;
    247       }
    248     }
    249     #endregion
    250 
    251     #region SlaveGroup
    252     public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
    253       if (source == null) return null;
    254       return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval };
    255     }
    256     public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
    257       if (source == null) return null;
    258       var entity = new DB.SlaveGroup(); ToEntity(source, entity);
    259       return entity;
    260     }
    261     public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
    262       if ((source != null) && (target != null)) {
    263         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval;
    264       }
    265     }
    266     #endregion
    267 
    268     #region Resource
    269     public static DT.Resource ToDto(DB.Resource source) {
    270       if (source == null) return null;
    271       return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval };
    272     }
    273     public static DB.Resource ToEntity(DT.Resource source) {
    274       if (source == null) return null;
    275       var entity = new DB.Resource(); ToEntity(source, entity);
    276       return entity;
    277     }
    278     public static void ToEntity(DT.Resource source, DB.Resource target) {
    279       if ((source != null) && (target != null)) {
    280         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval;
    281       }
    282     }
    283     #endregion
    284 
    285     #region Statistics
    286     public static DT.Statistics ToDto(DB.Statistics source) {
    287       if (source == null) return null;
    288       return new DT.Statistics {
    289         Id = source.StatisticsId,
    290         TimeStamp = source.Timestamp,
    291         SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(),
    292         UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray()
    293       };
    294     }
    295     public static DB.Statistics ToEntity(DT.Statistics source) {
    296       if (source == null) return null;
    297       var entity = new DB.Statistics(); ToEntity(source, entity);
    298       return entity;
    299     }
    300     public static void ToEntity(DT.Statistics source, DB.Statistics target) {
    301       if ((source != null) && (target != null)) {
    302         target.StatisticsId = source.Id;
    303         target.Timestamp = source.TimeStamp;
    304 
     282        target.OwnerUserId = source.OwnerUserId;
     283      }
     284    }
     285    #endregion
     286
     287    #region ResourcePermission
     288    public static DT.ResourcePermission ToDto(DB.ResourcePermission source) {
     289      if (source == null) return null;
     290      return new DT.ResourcePermission { ResourceId = source.ResourceId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId };
     291    }
     292    public static DB.ResourcePermission ToEntity(DT.ResourcePermission source) {
     293      if (source == null) return null;
     294      var entity = new DB.ResourcePermission(); ToEntity(source, entity);
     295      return entity;
     296    }
     297    public static void ToEntity(DT.ResourcePermission source, DB.ResourcePermission target) {
     298      if ((source != null) && (target != null)) {
     299        target.ResourceId = source.ResourceId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId;
    305300      }
    306301    }
     
    334329        target.FreeMemory = source.FreeMemory;
    335330        target.Memory = source.Memory;
     331      }
     332    }
     333    #endregion
     334
     335    #region Statistics
     336    public static DT.Statistics ToDto(DB.Statistics source) {
     337      if (source == null) return null;
     338      return new DT.Statistics {
     339        Id = source.StatisticsId,
     340        TimeStamp = source.Timestamp,
     341        SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(),
     342        UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray()
     343      };
     344    }
     345    public static DB.Statistics ToEntity(DT.Statistics source) {
     346      if (source == null) return null;
     347      var entity = new DB.Statistics(); ToEntity(source, entity);
     348      return entity;
     349    }
     350    public static void ToEntity(DT.Statistics source, DB.Statistics target) {
     351      if ((source != null) && (target != null)) {
     352        target.StatisticsId = source.Id;
     353        target.Timestamp = source.TimeStamp;
     354
    336355      }
    337356    }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Resource.cs

    r7259 r7916  
    2929    [DataMember]
    3030    public Guid? ParentResourceId { get; set; }
    31 
    3231    [DataMember]
    3332    public int HbInterval { get; set; }
     33    [DataMember]
     34    public Guid? OwnerUserId { get; set; }
    3435
    3536    public Resource() { }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r7189 r7916  
    114114    <Compile Include="Convert.cs" />
    115115    <Compile Include="DataTransfer\Command.cs" />
     116    <Compile Include="DataTransfer\ResourcePermission.cs" />
    116117    <Compile Include="DataTransfer\Downtime.cs" />
    117118    <Compile Include="DataTransfer\Heartbeat.cs" />
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r7259 r7916  
    613613    #endregion
    614614
     615    #region ResourcePermission Methods
     616    public DT.ResourcePermission GetResourcePermission(Guid resourceId, Guid grantedUserId) {
     617      using (var db = CreateContext()) {
     618        return DT.Convert.ToDto(db.ResourcePermissions.SingleOrDefault(x => x.ResourceId == resourceId && x.GrantedUserId == grantedUserId));
     619      }
     620    }
     621
     622    public IEnumerable<DT.ResourcePermission> GetResourcePermissions(Expression<Func<ResourcePermission, bool>> predicate) {
     623      using (var db = CreateContext()) {
     624        return db.ResourcePermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     625      }
     626    }
     627
     628    public void AddResourcePermission(DT.ResourcePermission dto) {
     629      using (var db = CreateContext()) {
     630        var entity = db.ResourcePermissions.SingleOrDefault(x => x.ResourceId == dto.ResourceId && x.GrantedUserId == dto.GrantedUserId);
     631        if (entity == null) { db.ResourcePermissions.InsertOnSubmit(DT.Convert.ToEntity(dto)); db.SubmitChanges(); }
     632      }
     633    }
     634
     635    public void UpdateResourcePermission(DT.ResourcePermission dto) {
     636      using (var db = CreateContext()) {
     637        var entity = db.ResourcePermissions.FirstOrDefault(x => x.ResourceId == dto.ResourceId && x.GrantedUserId == dto.GrantedUserId);
     638        if (entity == null) db.ResourcePermissions.InsertOnSubmit(DT.Convert.ToEntity(dto));
     639        else DT.Convert.ToEntity(dto, entity);
     640        db.SubmitChanges();
     641      }
     642    }
     643
     644    public void DeleteResourcePermission(Guid resourceId, Guid grantedUserId) {
     645      using (var db = CreateContext()) {
     646        var entity = db.ResourcePermissions.FirstOrDefault(x => x.ResourceId == resourceId && x.GrantedUserId == grantedUserId);
     647        if (entity != null) db.ResourcePermissions.DeleteOnSubmit(entity);
     648        db.SubmitChanges();
     649      }
     650    }
     651    #endregion
     652
    615653    #region Authorization Methods
    616654    public Permission GetPermissionForTask(Guid taskId, Guid userId) {
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r7910 r7916  
    353353    public void Hello(Slave slaveInfo) {
    354354      authen.AuthenticateForAnyRole(HiveRoles.Slave);
     355      if (userManager.CurrentUser.UserName != "hiveslave")
     356        slaveInfo.OwnerUserId = userManager.CurrentUserId;
     357
    355358      trans.UseTransaction(() => {
    356359        var slave = dao.GetSlave(slaveInfo.Id);
     
    359362          dao.AddSlave(slaveInfo);
    360363        } else {
    361           var dbSlave = dao.GetSlave(slaveInfo.Id);
    362 
    363           dbSlave.Name = slaveInfo.Name;
    364           dbSlave.Description = slaveInfo.Description;
    365 
    366           dbSlave.Cores = slaveInfo.Cores;
    367           dbSlave.CpuArchitecture = slaveInfo.CpuArchitecture;
    368           dbSlave.CpuSpeed = slaveInfo.CpuSpeed;
    369           dbSlave.FreeCores = slaveInfo.FreeCores;
    370           dbSlave.FreeMemory = slaveInfo.FreeMemory;
    371           dbSlave.Memory = slaveInfo.Memory;
    372           dbSlave.OperatingSystem = slaveInfo.OperatingSystem;
    373 
    374           dbSlave.LastHeartbeat = DateTime.Now;
    375           dbSlave.SlaveState = SlaveState.Idle;
     364          slave.Name = slaveInfo.Name;
     365          slave.Description = slaveInfo.Description;
     366          slave.OwnerUserId = slaveInfo.OwnerUserId;
     367
     368          slave.Cores = slaveInfo.Cores;
     369          slave.CpuArchitecture = slaveInfo.CpuArchitecture;
     370          slave.CpuSpeed = slaveInfo.CpuSpeed;
     371          slave.FreeCores = slaveInfo.FreeCores;
     372          slave.FreeMemory = slaveInfo.FreeMemory;
     373          slave.Memory = slaveInfo.Memory;
     374          slave.OperatingSystem = slaveInfo.OperatingSystem;
     375
     376          slave.LastHeartbeat = DateTime.Now;
     377          slave.SlaveState = SlaveState.Idle;
    376378
    377379          // don't update those properties: dbSlave.IsAllowedToCalculate, dbSlave.ParentResourceId
    378380
    379           dao.UpdateSlave(dbSlave);
     381          dao.UpdateSlave(slave);
    380382        }
    381383      });
     
    461463      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    462464      dao.DeletePlugin(pluginId);
     465    }
     466    #endregion
     467
     468    #region ResourcePermission Methods
     469    public void GrantResourcePermission(Guid resourceId, Guid grantedUserId) {
     470      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     471      trans.UseTransaction(() => {
     472        Resource resource = dao.GetResource(resourceId);
     473        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
     474        if (resource.OwnerUserId != userManager.CurrentUserId) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permission for this resource"));
     475        dao.AddResourcePermission(new ResourcePermission { ResourceId = resourceId, GrantedByUserId = userManager.CurrentUserId, GrantedUserId = grantedUserId });
     476      });
     477    }
     478
     479    public void RevokeResourcePermission(Guid resourceId, Guid grantedUserId) {
     480      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     481      trans.UseTransaction(() => {
     482        Resource resource = dao.GetResource(resourceId);
     483        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
     484        if (resource.OwnerUserId != userManager.CurrentUserId) throw new FaultException<FaultReason>(new FaultReason("Not allowed to revoke permission for this resource"));
     485        dao.DeleteResourcePermission(resourceId, grantedUserId);
     486      });
     487    }
     488
     489    public IEnumerable<ResourcePermission> GetResourcePermissions(Guid resourceId) {
     490      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     491      return trans.UseTransaction(() => {
     492        Resource resource = dao.GetResource(resourceId);
     493        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
     494        if (resource.OwnerUserId != userManager.CurrentUserId) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this resource"));
     495        return dao.GetResourcePermissions(x => x.ResourceId == resourceId);
     496      });
    463497    }
    464498    #endregion
     
    497531    public IEnumerable<Slave> GetSlaves() {
    498532      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    499       return dao.GetSlaves(x => true);
     533      return dao.GetSlaves(x => x.OwnerUserId == null
     534                             || x.OwnerUserId == userManager.CurrentUserId
     535                             || x.ResourcePermissions.Count(y => y.GrantedUserId == userManager.CurrentUserId) > 0
     536                             || authen.IsInRole(HiveRoles.Administrator));
    500537    }
    501538
    502539    public IEnumerable<SlaveGroup> GetSlaveGroups() {
    503540      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    504       return dao.GetSlaveGroups(x => true);
     541      return dao.GetSlaveGroups(x => x.OwnerUserId == null
     542                                  || x.OwnerUserId == userManager.CurrentUserId
     543                                  || x.ResourcePermissions.Count(y => y.GrantedUserId == userManager.CurrentUserId) > 0
     544                                  || authen.IsInRole(HiveRoles.Administrator));
    505545    }
    506546
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r7259 r7916  
    117117    #endregion
    118118
     119    #region ResourcePermission Methods
     120    DT.ResourcePermission GetResourcePermission(Guid resourceId, Guid grantedUserId);
     121    IEnumerable<DT.ResourcePermission> GetResourcePermissions(Expression<Func<ResourcePermission, bool>> predicate);
     122    void AddResourcePermission(DT.ResourcePermission dto);
     123    void UpdateResourcePermission(DT.ResourcePermission dto);
     124    void DeleteResourcePermission(Guid resourceId, Guid grantedUserId);
     125    #endregion
     126
    119127    #region Authorization Methods
    120128    Permission GetPermissionForTask(Guid taskId, Guid userId);
  • trunk/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r7259 r7916  
    158158    #endregion
    159159
     160    #region ResourcePermission Methods
     161    [OperationContract]
     162    void GrantResourcePermission(Guid resourceId, Guid grantedUserId);
     163
     164    [OperationContract]
     165    void RevokeResourcePermission(Guid resourceId, Guid grantedUserId);
     166
     167    [OperationContract]
     168    IEnumerable<ResourcePermission> GetResourcePermissions(Guid resourceId);
     169    #endregion
     170
    160171    #region Slave Methods
    161172    [OperationContract]
Note: See TracChangeset for help on using the changeset viewer.