Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8051


Ignore:
Timestamp:
06/19/12 12:06:18 (12 years ago)
Author:
jkarder
Message:

#1859: manually merged branch "HiveResourcePermissionManagement (trunk integration)" into trunk

Location:
trunk/sources
Files:
2 added
17 edited

Legend:

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

    r7257 r8051  
    9797  </ItemGroup>
    9898  <ItemGroup>
     99    <Compile Include="HiveRoles.cs" />
    99100    <Compile Include="Views\HiveAdministratorView.cs">
    100101      <SubType>UserControl</SubType>
     
    141142  </ItemGroup>
    142143  <ItemGroup>
     144    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Administration\3.3\HeuristicLab.Clients.Access.Administration-3.3.csproj">
     145      <Project>{C9CF6AE8-4637-4A75-9141-042F479B5D50}</Project>
     146      <Name>HeuristicLab.Clients.Access.Administration-3.3</Name>
     147    </ProjectReference>
     148    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Views\3.3\HeuristicLab.Clients.Access.Views-3.3.csproj">
     149      <Project>{FE856595-64CD-46DA-9CD2-FFF3E6B0D4F2}</Project>
     150      <Name>HeuristicLab.Clients.Access.Views-3.3</Name>
     151    </ProjectReference>
     152    <ProjectReference Include="..\..\HeuristicLab.Clients.Access\3.3\HeuristicLab.Clients.Access-3.3.csproj">
     153      <Project>{494F87F4-0F25-4D33-A382-10CDB2174D48}</Project>
     154      <Name>HeuristicLab.Clients.Access-3.3</Name>
     155    </ProjectReference>
    143156    <ProjectReference Include="..\..\HeuristicLab.Clients.Common\3.3\HeuristicLab.Clients.Common-3.3.csproj">
    144157      <Project>{730A9104-D4D1-4360-966B-E49B7571DDA3}</Project>
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Plugin.cs.frame

    r7949 r8051  
    2525  [Plugin("HeuristicLab.Clients.Hive.Administrator", "3.3.6.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Clients.Hive.Administrator-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Clients.Access", "3.3")]
     28  [PluginDependency("HeuristicLab.Clients.Access.Administration", "3.3")]
     29  [PluginDependency("HeuristicLab.Clients.Access.Views", "3.3")]
    2730  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2831  [PluginDependency("HeuristicLab.Common", "3.3")]
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r7967 r8051  
    5454      this.btnRemoveGroup = new System.Windows.Forms.Button();
    5555      this.btnAddGroup = new System.Windows.Forms.Button();
     56      this.btnPermissionsSave = new System.Windows.Forms.Button();
    5657      this.treeSlaveGroup = new System.Windows.Forms.TreeView();
    5758      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
     
    6162      this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();
    6263      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     64      this.tabPermissions = new System.Windows.Forms.TabPage();
     65      this.permissionView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView();
    6366      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit();
    6467      this.splitSlaves.Panel1.SuspendLayout();
     
    6871      this.tabDetails.SuspendLayout();
    6972      this.tabSchedule.SuspendLayout();
     73      this.tabPermissions.SuspendLayout();
    7074      this.SuspendLayout();
    7175      //
     
    7579      this.imageListSlaveGroups.ImageSize = new System.Drawing.Size(16, 16);
    7680      this.imageListSlaveGroups.TransparentColor = System.Drawing.Color.Transparent;
    77       //
    78       // splitSlaves
    79       //
    80       this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    81                   | System.Windows.Forms.AnchorStyles.Left)
    82                   | System.Windows.Forms.AnchorStyles.Right)));
    83       this.splitSlaves.Location = new System.Drawing.Point(3, 3);
    84       this.splitSlaves.Name = "splitSlaves";
    85       //
    86       // splitSlaves.Panel1
    87       //
    88       this.splitSlaves.Panel1.Controls.Add(this.btnRefresh);
    89       this.splitSlaves.Panel1.Controls.Add(this.progressBar);
    90       this.splitSlaves.Panel1.Controls.Add(this.btnSave);
    91       this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup);
    92       this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup);
    93       this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
    94       //
    95       // splitSlaves.Panel2
    96       //
    97       this.splitSlaves.Panel2.Controls.Add(this.tabSlaveGroup);
    98       this.splitSlaves.Size = new System.Drawing.Size(847, 547);
    99       this.splitSlaves.SplitterDistance = 249;
    100       this.splitSlaves.TabIndex = 3;
    10181      //
    10282      // btnRefresh
     
    11191      this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
    11292      //
    113       // progressBar
    114       //
    115       this.progressBar.Location = new System.Drawing.Point(123, 4);
    116       this.progressBar.Name = "progressBar";
    117       this.progressBar.Size = new System.Drawing.Size(123, 23);
    118       this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
    119       this.progressBar.TabIndex = 7;
    120       //
    12193      // btnSave
    12294      //
     
    152124      this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click);
    153125      //
     126      // btnPermissionsSave
     127      //
     128      this.btnPermissionsSave.Enabled = false;
     129      this.btnPermissionsSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     130      this.btnPermissionsSave.Location = new System.Drawing.Point(36, 6);
     131      this.btnPermissionsSave.Name = "btnPermissionsSave";
     132      this.btnPermissionsSave.Size = new System.Drawing.Size(24, 24);
     133      this.btnPermissionsSave.TabIndex = 1;
     134      this.toolTip.SetToolTip(this.btnPermissionsSave, "Store slave and group sharing permissions on the server");
     135      this.btnPermissionsSave.UseVisualStyleBackColor = true;
     136      this.btnPermissionsSave.Click += new System.EventHandler(this.btnPermissionsSave_Click);
     137      //
     138      // splitSlaves
     139      //
     140      this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     141            | System.Windows.Forms.AnchorStyles.Left)
     142            | System.Windows.Forms.AnchorStyles.Right)));
     143      this.splitSlaves.Location = new System.Drawing.Point(3, 3);
     144      this.splitSlaves.Name = "splitSlaves";
     145      //
     146      // splitSlaves.Panel1
     147      //
     148      this.splitSlaves.Panel1.Controls.Add(this.btnRefresh);
     149      this.splitSlaves.Panel1.Controls.Add(this.progressBar);
     150      this.splitSlaves.Panel1.Controls.Add(this.btnSave);
     151      this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup);
     152      this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup);
     153      this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
     154      //
     155      // splitSlaves.Panel2
     156      //
     157      this.splitSlaves.Panel2.Controls.Add(this.tabSlaveGroup);
     158      this.splitSlaves.Size = new System.Drawing.Size(847, 547);
     159      this.splitSlaves.SplitterDistance = 249;
     160      this.splitSlaves.TabIndex = 3;
     161      //
     162      // progressBar
     163      //
     164      this.progressBar.Location = new System.Drawing.Point(123, 4);
     165      this.progressBar.Name = "progressBar";
     166      this.progressBar.Size = new System.Drawing.Size(123, 23);
     167      this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
     168      this.progressBar.TabIndex = 7;
     169      //
    154170      // treeSlaveGroup
    155171      //
    156172      this.treeSlaveGroup.AllowDrop = true;
    157173      this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    158                   | System.Windows.Forms.AnchorStyles.Left)
    159                   | System.Windows.Forms.AnchorStyles.Right)));
     174            | System.Windows.Forms.AnchorStyles.Left)
     175            | System.Windows.Forms.AnchorStyles.Right)));
    160176      this.treeSlaveGroup.ImageIndex = 0;
    161177      this.treeSlaveGroup.ImageList = this.imageListSlaveGroups;
     
    166182      this.treeSlaveGroup.TabIndex = 0;
    167183      this.treeSlaveGroup.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);
    168       this.treeSlaveGroup.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeSlaveGroup_NodeMouseClick);
     184      this.treeSlaveGroup.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);
    169185      this.treeSlaveGroup.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
    170186      this.treeSlaveGroup.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);
     
    175191      //
    176192      this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    177                   | System.Windows.Forms.AnchorStyles.Left)
    178                   | System.Windows.Forms.AnchorStyles.Right)));
     193            | System.Windows.Forms.AnchorStyles.Left)
     194            | System.Windows.Forms.AnchorStyles.Right)));
    179195      this.tabSlaveGroup.Controls.Add(this.tabDetails);
    180196      this.tabSlaveGroup.Controls.Add(this.tabSchedule);
     197      this.tabSlaveGroup.Controls.Add(this.tabPermissions);
    181198      this.tabSlaveGroup.Location = new System.Drawing.Point(3, 3);
    182199      this.tabSlaveGroup.Name = "tabSlaveGroup";
     
    200217      //
    201218      this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    202                   | System.Windows.Forms.AnchorStyles.Left)
    203                   | System.Windows.Forms.AnchorStyles.Right)));
     219            | System.Windows.Forms.AnchorStyles.Left)
     220            | System.Windows.Forms.AnchorStyles.Right)));
    204221      this.slaveView.Caption = "SlaveView";
    205222      this.slaveView.Content = null;
    206       this.slaveView.Location = new System.Drawing.Point(7, 7);
     223      this.slaveView.Location = new System.Drawing.Point(6, 6);
    207224      this.slaveView.Name = "slaveView";
    208225      this.slaveView.ReadOnly = false;
    209       this.slaveView.Size = new System.Drawing.Size(564, 502);
     226      this.slaveView.Size = new System.Drawing.Size(565, 503);
    210227      this.slaveView.TabIndex = 0;
    211228      //
     
    224241      //
    225242      this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    226                   | System.Windows.Forms.AnchorStyles.Left)
    227                   | System.Windows.Forms.AnchorStyles.Right)));
     243            | System.Windows.Forms.AnchorStyles.Left)
     244            | System.Windows.Forms.AnchorStyles.Right)));
    228245      this.scheduleView.Caption = "ScheduleView";
    229246      this.scheduleView.Content = null;
    230       this.scheduleView.Location = new System.Drawing.Point(3, 8);
     247      this.scheduleView.Location = new System.Drawing.Point(6, 6);
    231248      this.scheduleView.Name = "scheduleView";
    232249      this.scheduleView.ReadOnly = false;
    233       this.scheduleView.Size = new System.Drawing.Size(568, 501);
     250      this.scheduleView.Size = new System.Drawing.Size(565, 503);
    234251      this.scheduleView.TabIndex = 0;
     252      //
     253      // tabPermissions
     254      //
     255      this.tabPermissions.Controls.Add(this.btnPermissionsSave);
     256      this.tabPermissions.Controls.Add(this.permissionView);
     257      this.tabPermissions.Location = new System.Drawing.Point(4, 22);
     258      this.tabPermissions.Name = "tabPermissions";
     259      this.tabPermissions.Padding = new System.Windows.Forms.Padding(3);
     260      this.tabPermissions.Size = new System.Drawing.Size(577, 515);
     261      this.tabPermissions.TabIndex = 2;
     262      this.tabPermissions.Text = "Permissions";
     263      this.tabPermissions.UseVisualStyleBackColor = true;
     264      //
     265      // permissionView
     266      //
     267      this.permissionView.Caption = "RefreshableLightweightUser View";
     268      this.permissionView.Content = null;
     269      this.permissionView.FetchSelectedUsers = null;
     270      this.permissionView.Location = new System.Drawing.Point(6, 6);
     271      this.permissionView.Name = "permissionView";
     272      this.permissionView.ReadOnly = false;
     273      this.permissionView.Size = new System.Drawing.Size(565, 503);
     274      this.permissionView.TabIndex = 0;
    235275      //
    236276      // ResourcesView
     
    249289      this.tabDetails.ResumeLayout(false);
    250290      this.tabSchedule.ResumeLayout(false);
     291      this.tabPermissions.ResumeLayout(false);
    251292      this.ResumeLayout(false);
    252293
     
    269310    private System.Windows.Forms.Button btnRefresh;
    270311    private System.Windows.Forms.ToolTip toolTip;
     312    private System.Windows.Forms.TabPage tabPermissions;
     313    private Access.Views.RefreshableLightweightUserView permissionView;
     314    private System.Windows.Forms.Button btnPermissionsSave;
    271315  }
    272316}
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r7928 r8051  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    2728using System.Threading.Tasks;
    2829using System.Windows.Forms;
     30using HeuristicLab.Clients.Access;
    2931using HeuristicLab.Clients.Hive.Views;
    3032using HeuristicLab.Core;
     
    4547    private const int slaveImageIndex = 0;
    4648    private const int slaveGroupImageIndex = 1;
     49    private readonly Color ownedResourceColor = Color.LightGreen;
    4750    private TS.Task progressTask;
    4851    private bool stopProgressTask;
     52    private bool currentlyAuthorized;
    4953
    5054
     
    5660      HiveAdminClient.Instance.Refreshing += new EventHandler(Instance_Refreshing);
    5761      HiveAdminClient.Instance.Refreshed += new EventHandler(Instance_Refreshed);
     62
     63      Access.AccessClient.Instance.Refreshing += new EventHandler(Content_Refreshing);
     64      Access.AccessClient.Instance.Refreshed += new EventHandler(Content_Refreshed);
    5865    }
    5966
     
    6168      HiveAdminClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing);
    6269      HiveAdminClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed);
     70
     71      Access.AccessClient.Instance.Refreshing -= new EventHandler(Content_Refreshing);
     72      Access.AccessClient.Instance.Refreshed -= new EventHandler(Content_Refreshed);
    6373    }
    6474
     
    8797      progressTask = new TS.Task(UpdateProgress);
    8898      progressTask.Start();
     99      SetEnabledStateOfControls(false);
    89100    }
    90101
    91102    void Instance_Refreshed(object sender, EventArgs e) {
    92103      stopProgressTask = true;
     104      SetEnabledStateOfControls(true);
     105    }
     106
     107    void Content_Refreshing(object sender, EventArgs e) {
     108      stopProgressTask = false;
     109      progressTask = new TS.Task(UpdateProgress);
     110      progressTask.Start();
     111      SetEnabledStateOfControls(false);
     112    }
     113
     114    void Content_Refreshed(object sender, EventArgs e) {
     115      stopProgressTask = true;
     116      SetEnabledStateOfControls(true);
    93117    }
    94118
     
    110134      if (Content == null) {
    111135        slaveView.Content = null;
     136        scheduleView.Content = null;
     137        permissionView.Content = null;
     138        permissionView.FetchSelectedUsers = null;
    112139        treeSlaveGroup.Nodes.Clear();
    113140      } else {
     141        permissionView.Content = Access.AccessClient.Instance;
    114142        treeSlaveGroup.Nodes.Clear();
    115143
     
    134162              tn.Tag = g;
    135163              tn.Text = g.Name;
     164              if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) tn.BackColor = ownedResourceColor;
    136165
    137166              BuildSlaveGroupTree(g, tn);
     
    144173              stn.SelectedImageIndex = stn.ImageIndex;
    145174              stn.Tag = g;
     175              if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    146176              ungrp.Nodes.Add(stn);
    147177            }
     
    162192        stn.SelectedImageIndex = stn.ImageIndex;
    163193        stn.Tag = r;
     194        if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    164195        tn.Nodes.Add(stn);
    165196
     
    174205        btnRemoveGroup.Enabled = false;
    175206        btnSave.Enabled = false;
     207        btnPermissionsSave.Enabled = false;
     208        permissionView.Enabled = false;
    176209      } else {
    177210        btnAddGroup.Enabled = true;
     
    181214    }
    182215
    183     private void treeSlaveGroup_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) {
    184       if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    185         slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    186       }
    187 
    188       slaveView.Content = (Resource)e.Node.Tag;
    189       HiveAdminClient.Instance.DowntimeForResourceId = ((Resource)e.Node.Tag).Id;
    190 
    191       if (e.Node.Tag is SlaveGroup) {
    192         slaveView.Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    193       }
    194 
    195       if (tabSlaveGroup.SelectedIndex == 1) {
    196         UpdateScheduleAsync();
     216    public virtual void SetEnabledStateOfControls(bool state) {
     217      if (InvokeRequired) {
     218        Invoke(new Action(() => SetEnabledStateOfControls(state)));
     219      } else {
     220        if (Content == null) state = false;
     221        btnAddGroup.Enabled = state;
     222        btnRemoveGroup.Enabled = state;
     223        btnSave.Enabled = state;
     224        scheduleView.SetEnabledStateOfControls(state && IsAuthorized(slaveView.Content));
     225        btnPermissionsSave.Enabled = state && permissionView.FetchSelectedUsers != null && Content != null;
     226        permissionView.Enabled = state && permissionView.FetchSelectedUsers != null && Content != null;
     227      }
     228    }
     229
     230    private bool IsAuthorized(Resource resource) {
     231      return resource != null
     232          && resource.Name != UngroupedGroupName
     233          && resource.Id != Guid.Empty
     234          && HiveServiceLocator.Instance.CallHiveService<bool>(service => { return service.AuthorizesForResourceAdministration(resource.Id); });
     235    }
     236
     237    private void treeSlaveGroup_AfterSelect(object sender, TreeViewEventArgs e) {
     238      if (e.Action != TreeViewAction.Unknown) {
     239        Resource selectedResource = ((Resource)e.Node.Tag);
     240        currentlyAuthorized = IsAuthorized(selectedResource);
     241        if (currentlyAuthorized) {
     242          permissionView.FetchSelectedUsers = new Func<List<Guid>>(() => {
     243            return HiveServiceLocator.Instance.CallHiveService<List<ResourcePermission>>(service => {
     244              return service.GetResourcePermissions(selectedResource.Id);
     245            }).Select(x => x.GrantedUserId).ToList();
     246          });
     247          if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
     248        } else {
     249          permissionView.FetchSelectedUsers = null;
     250          btnPermissionsSave.Enabled = false;
     251          if (selectedResource.Id == Guid.Empty) {
     252            if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
     253          } else tabSlaveGroup.TabPages.Remove(tabPermissions);
     254        }
     255
     256        if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
     257          slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
     258        }
     259
     260        slaveView.Content = selectedResource;
     261        HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id;
     262
     263        if (selectedResource is SlaveGroup) {
     264          slaveView.Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
     265        }
     266
     267        if (tabSlaveGroup.SelectedIndex == 1) {
     268          UpdateScheduleAsync();
     269        } else if (tabSlaveGroup.SelectedIndex == 2) {
     270          UpdatePermissionsAsync();
     271        }
    197272      }
    198273    }
     
    217292      SlaveGroup newGroup = new SlaveGroup();
    218293      newGroup.Name = "New Group";
     294      newGroup.OwnerUserId = UserInformation.Instance.User.Id;
    219295      Content.Add(newGroup);
    220296    }
     
    269345        if (destNode.TreeView == newNode.TreeView) {
    270346          if (destNode.Text == UngroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == UngroupedGroupName)) {
    271             MessageBox.Show(String.Format("You can't drag items to the {0} group.{1}This group only contains slaves which haven't yet been assigned to a real group.",
     347            MessageBox.Show(string.Format("You can't drag items to the group \"{0}\".{1}This group only contains slaves which haven't yet been assigned to a real group.",
    272348              UngroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information);
    273349            return;
     
    285361
    286362          if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) {
     363            return;
     364          }
     365
     366          SlaveGroup parent = (SlaveGroup)parentNode.Tag;
     367
     368          if (parent.OwnerUserId != null && !IsAuthorized(parent)) {
     369            MessageBox.Show(string.Format("You don't have the permissions to drag items to the group \"{0}\".", ((Resource)parentNode.Tag).Name),
     370              "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    287371            return;
    288372          }
     
    330414    private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) {
    331415      TreeNode sourceNode = (TreeNode)e.Item;
    332       DoDragDrop(sourceNode, DragDropEffects.All);
     416      if (IsAuthorized((Resource)sourceNode.Tag))
     417        DoDragDrop(sourceNode, DragDropEffects.All);
    333418    }
    334419
     
    403488    private void UpdateSchedule() {
    404489      HiveAdminClient.Instance.RefreshCalendar();
    405       scheduleView.Invoke(new Action(() => scheduleView.Content = HiveAdminClient.Instance.Downtimes));
     490      scheduleView.Invoke(new Action(() => {
     491        scheduleView.Content = HiveAdminClient.Instance.Downtimes;
     492        SetEnabledStateOfControls(currentlyAuthorized);
     493      }));
    406494    }
    407495
     
    412500    }
    413501
     502    private void UpdatePermissions() {
     503      if (permissionView.Content != null && permissionView.FetchSelectedUsers != null)
     504        permissionView.Invoke(new Action(() => permissionView.ManualRefresh()));
     505    }
     506
     507    private void UpdatePermissionsAsync() {
     508      TS.Task.Factory.StartNew(UpdatePermissions).ContinueWith((t) => {
     509        DisplayError(t.Exception);
     510      }, TaskContinuationOptions.OnlyOnFaulted);
     511    }
     512
     513
    414514    private void DisplayError(Exception ex) {
    415515      MessageBox.Show(string.Format("An error occured while updating: {0} {1}", Environment.NewLine, ex.Message), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     
    419519      if (tabSlaveGroup.SelectedIndex == 1) {
    420520        UpdateScheduleAsync();
     521      } else if (tabSlaveGroup.SelectedIndex == 2) {
     522        UpdatePermissionsAsync();
    421523      }
    422524    }
     
    429531      UpdateResourcesAsync();
    430532    }
     533
     534    private void btnPermissionsSave_Click(object sender, EventArgs e) {
     535      SetEnabledStateOfControls(false);
     536      HiveServiceLocator.Instance.CallHiveService(service => {
     537        service.GrantResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetAddedUsers().Select(x => x.Id).ToList());
     538        service.RevokeResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetDeletedUsers().Select(x => x.Id).ToList());
     539      });
     540      SetEnabledStateOfControls(true);
     541    }
    431542  }
    432543}
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs

    r7967 r8051  
    7171      this.dvOnline.ActiveTool = drawTool1;
    7272      this.dvOnline.AmPmDisplay = false;
    73       this.dvOnline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    74                   | System.Windows.Forms.AnchorStyles.Left)));
     73      this.dvOnline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     74            | System.Windows.Forms.AnchorStyles.Right)));
    7575      this.dvOnline.AppointmentDuration = Calendar.AppointmentSlotDuration.SixtyMinutes;
    7676      this.dvOnline.AppointmentHeightMode = Calendar.AppHeightDrawMode.TrueHeightAll;
     
    8383      this.dvOnline.EnableTimeIndicator = false;
    8484      this.dvOnline.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
    85       this.dvOnline.Location = new System.Drawing.Point(9, 176);
     85      this.dvOnline.Location = new System.Drawing.Point(3, 183);
    8686      this.dvOnline.MinHalfHourApp = false;
    8787      this.dvOnline.Name = "dvOnline";
    8888      this.dvOnline.SelectionEnd = new System.DateTime(((long)(0)));
    8989      this.dvOnline.SelectionStart = new System.DateTime(((long)(0)));
    90       this.dvOnline.Size = new System.Drawing.Size(823, 354);
     90      this.dvOnline.Size = new System.Drawing.Size(836, 354);
    9191      this.dvOnline.StartDate = new System.DateTime(((long)(0)));
    9292      this.dvOnline.TabIndex = 54;
     
    123123      // groupBox1
    124124      //
     125      this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    125126      this.groupBox1.Controls.Add(this.txttimeTo);
    126127      this.groupBox1.Controls.Add(this.txttimeFrom);
     
    133134      this.groupBox1.Controls.Add(this.label1);
    134135      this.groupBox1.Controls.Add(this.btCreate);
    135       this.groupBox1.Location = new System.Drawing.Point(373, 4);
     136      this.groupBox1.Location = new System.Drawing.Point(375, 3);
    136137      this.groupBox1.Name = "groupBox1";
    137       this.groupBox1.Size = new System.Drawing.Size(254, 161);
     138      this.groupBox1.Size = new System.Drawing.Size(259, 168);
    138139      this.groupBox1.TabIndex = 56;
    139140      this.groupBox1.TabStop = false;
     
    217218      // btnSaveCal
    218219      //
     220      this.btnSaveCal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    219221      this.btnSaveCal.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
    220222      this.btnSaveCal.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    221       this.btnSaveCal.Location = new System.Drawing.Point(633, 41);
     223      this.btnSaveCal.Location = new System.Drawing.Point(640, 41);
    222224      this.btnSaveCal.Name = "btnSaveCal";
    223225      this.btnSaveCal.Size = new System.Drawing.Size(199, 26);
     
    230232      // btnClearCal
    231233      //
     234      this.btnClearCal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    232235      this.btnClearCal.Image = HeuristicLab.Common.Resources.VSImageLibrary.Document;
    233236      this.btnClearCal.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    234       this.btnClearCal.Location = new System.Drawing.Point(633, 9);
     237      this.btnClearCal.Location = new System.Drawing.Point(640, 9);
    235238      this.btnClearCal.Name = "btnClearCal";
    236239      this.btnClearCal.Size = new System.Drawing.Size(199, 26);
     
    243246      // mcOnline
    244247      //
     248      this.mcOnline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     249            | System.Windows.Forms.AnchorStyles.Right)));
    245250      this.mcOnline.CalendarDimensions = new System.Drawing.Size(2, 1);
    246       this.mcOnline.Location = new System.Drawing.Point(4, 9);
     251      this.mcOnline.Location = new System.Drawing.Point(3, 9);
    247252      this.mcOnline.Name = "mcOnline";
    248253      this.mcOnline.TabIndex = 55;
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r7259 r8051  
    228228    protected override void SetEnabledStateOfControls() {
    229229      base.SetEnabledStateOfControls();
    230       if (Content == null) {
    231         btnSaveCal.Enabled = false;
     230    }
     231
     232    public virtual void SetEnabledStateOfControls(bool state) {
     233      if (InvokeRequired) {
     234        Invoke(new Action(() => SetEnabledStateOfControls(state)));
    232235      } else {
    233         btnSaveCal.Enabled = true;
     236        if (Content == null) state = false;
     237        groupBox1.Enabled = state;
     238        btnClearCal.Enabled = state;
     239        btnSaveCal.Enabled = state;
    234240      }
    235241    }
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.Designer.cs

    r7967 r8051  
    6767      this.cbxDisposable = new System.Windows.Forms.CheckBox();
    6868      this.label4 = new System.Windows.Forms.Label();
     69      this.cbxPublic = new System.Windows.Forms.CheckBox();
     70      this.label5 = new System.Windows.Forms.Label();
    6971      this.SuspendLayout();
    7072      //
    7173      // txtSlaveState
    7274      //
    73       this.txtSlaveState.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     75      this.txtSlaveState.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    7476            | System.Windows.Forms.AnchorStyles.Right)));
    7577      this.txtSlaveState.Enabled = false;
    76       this.txtSlaveState.Location = new System.Drawing.Point(146, 216);
     78      this.txtSlaveState.Location = new System.Drawing.Point(146, 242);
    7779      this.txtSlaveState.Name = "txtSlaveState";
    7880      this.txtSlaveState.Size = new System.Drawing.Size(390, 20);
     
    8183      // txtOS
    8284      //
    83       this.txtOS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     85      this.txtOS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    8486            | System.Windows.Forms.AnchorStyles.Right)));
    8587      this.txtOS.Enabled = false;
    86       this.txtOS.Location = new System.Drawing.Point(146, 190);
     88      this.txtOS.Location = new System.Drawing.Point(146, 216);
    8789      this.txtOS.Name = "txtOS";
    8890      this.txtOS.Size = new System.Drawing.Size(390, 20);
     
    9294      //
    9395      this.label15.AutoSize = true;
    94       this.label15.Location = new System.Drawing.Point(3, 219);
     96      this.label15.Location = new System.Drawing.Point(3, 245);
    9597      this.label15.Name = "label15";
    9698      this.label15.Size = new System.Drawing.Size(35, 13);
     
    101103      //
    102104      this.label14.AutoSize = true;
    103       this.label14.Location = new System.Drawing.Point(3, 193);
     105      this.label14.Location = new System.Drawing.Point(3, 219);
    104106      this.label14.Name = "label14";
    105107      this.label14.Size = new System.Drawing.Size(93, 13);
     
    109111      // txtDetailsDescription
    110112      //
    111       this.txtDetailsDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     113      this.txtDetailsDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    112114            | System.Windows.Forms.AnchorStyles.Right)));
    113115      this.txtDetailsDescription.Enabled = false;
    114       this.txtDetailsDescription.Location = new System.Drawing.Point(146, 86);
     116      this.txtDetailsDescription.Location = new System.Drawing.Point(146, 112);
    115117      this.txtDetailsDescription.Name = "txtDetailsDescription";
    116118      this.txtDetailsDescription.Size = new System.Drawing.Size(390, 20);
     
    120122      //
    121123      this.label13.AutoSize = true;
    122       this.label13.Location = new System.Drawing.Point(3, 89);
     124      this.label13.Location = new System.Drawing.Point(3, 115);
    123125      this.label13.Name = "label13";
    124126      this.label13.Size = new System.Drawing.Size(63, 13);
     
    128130      // txtName
    129131      //
    130       this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     132      this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    131133            | System.Windows.Forms.AnchorStyles.Right)));
    132134      this.txtName.Location = new System.Drawing.Point(146, 8);
     
    138140      // txtCPU
    139141      //
    140       this.txtCPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     142      this.txtCPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    141143            | System.Windows.Forms.AnchorStyles.Right)));
    142144      this.txtCPU.Enabled = false;
    143       this.txtCPU.Location = new System.Drawing.Point(146, 112);
     145      this.txtCPU.Location = new System.Drawing.Point(146, 138);
    144146      this.txtCPU.Name = "txtCPU";
    145147      this.txtCPU.Size = new System.Drawing.Size(390, 20);
     
    148150      // txtMemory
    149151      //
    150       this.txtMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     152      this.txtMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    151153            | System.Windows.Forms.AnchorStyles.Right)));
    152154      this.txtMemory.Enabled = false;
    153       this.txtMemory.Location = new System.Drawing.Point(146, 138);
     155      this.txtMemory.Location = new System.Drawing.Point(146, 164);
    154156      this.txtMemory.Name = "txtMemory";
    155157      this.txtMemory.Size = new System.Drawing.Size(390, 20);
     
    158160      // txtLastHeartbeat
    159161      //
    160       this.txtLastHeartbeat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     162      this.txtLastHeartbeat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    161163            | System.Windows.Forms.AnchorStyles.Right)));
    162164      this.txtLastHeartbeat.Enabled = false;
    163       this.txtLastHeartbeat.Location = new System.Drawing.Point(146, 242);
     165      this.txtLastHeartbeat.Location = new System.Drawing.Point(146, 268);
    164166      this.txtLastHeartbeat.Name = "txtLastHeartbeat";
    165167      this.txtLastHeartbeat.Size = new System.Drawing.Size(390, 20);
     
    169171      //
    170172      this.label12.AutoSize = true;
    171       this.label12.Location = new System.Drawing.Point(3, 245);
     173      this.label12.Location = new System.Drawing.Point(3, 271);
    172174      this.label12.Name = "label12";
    173175      this.label12.Size = new System.Drawing.Size(80, 13);
     
    178180      //
    179181      this.label11.AutoSize = true;
    180       this.label11.Location = new System.Drawing.Point(3, 141);
     182      this.label11.Location = new System.Drawing.Point(3, 167);
    181183      this.label11.Name = "label11";
    182184      this.label11.Size = new System.Drawing.Size(47, 13);
     
    187189      //
    188190      this.label10.AutoSize = true;
    189       this.label10.Location = new System.Drawing.Point(3, 115);
     191      this.label10.Location = new System.Drawing.Point(3, 141);
    190192      this.label10.Name = "label10";
    191193      this.label10.Size = new System.Drawing.Size(32, 13);
     
    205207      //
    206208      this.label1.AutoSize = true;
    207       this.label1.Location = new System.Drawing.Point(3, 167);
     209      this.label1.Location = new System.Drawing.Point(3, 193);
    208210      this.label1.Name = "label1";
    209211      this.label1.Size = new System.Drawing.Size(70, 13);
     
    213215      // txtFreeMemory
    214216      //
    215       this.txtFreeMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     217      this.txtFreeMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    216218            | System.Windows.Forms.AnchorStyles.Right)));
    217219      this.txtFreeMemory.Enabled = false;
    218       this.txtFreeMemory.Location = new System.Drawing.Point(146, 164);
     220      this.txtFreeMemory.Location = new System.Drawing.Point(146, 190);
    219221      this.txtFreeMemory.Name = "txtFreeMemory";
    220222      this.txtFreeMemory.Size = new System.Drawing.Size(390, 20);
     
    223225      // txtId
    224226      //
    225       this.txtId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     227      this.txtId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    226228            | System.Windows.Forms.AnchorStyles.Right)));
    227229      this.txtId.Enabled = false;
    228       this.txtId.Location = new System.Drawing.Point(146, 60);
     230      this.txtId.Location = new System.Drawing.Point(146, 86);
    229231      this.txtId.Name = "txtId";
    230232      this.txtId.Size = new System.Drawing.Size(390, 20);
     
    234236      //
    235237      this.label2.AutoSize = true;
    236       this.label2.Location = new System.Drawing.Point(3, 63);
     238      this.label2.Location = new System.Drawing.Point(3, 89);
    237239      this.label2.Name = "label2";
    238240      this.label2.Size = new System.Drawing.Size(19, 13);
     
    251253      // txtHbIntervall
    252254      //
    253       this.txtHbIntervall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     255      this.txtHbIntervall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    254256            | System.Windows.Forms.AnchorStyles.Right)));
    255257      this.txtHbIntervall.Location = new System.Drawing.Point(146, 34);
     
    262264      //
    263265      this.cbxDisposable.AutoSize = true;
    264       this.cbxDisposable.Location = new System.Drawing.Point(146, 268);
     266      this.cbxDisposable.Enabled = false;
     267      this.cbxDisposable.Location = new System.Drawing.Point(146, 297);
    265268      this.cbxDisposable.Name = "cbxDisposable";
    266269      this.cbxDisposable.Size = new System.Drawing.Size(15, 14);
    267270      this.cbxDisposable.TabIndex = 34;
    268271      this.cbxDisposable.UseVisualStyleBackColor = true;
    269       this.cbxDisposable.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
     272      this.cbxDisposable.CheckedChanged += new System.EventHandler(this.cbxDisposable_CheckedChanged);
    270273      //
    271274      // label4
    272275      //
    273276      this.label4.AutoSize = true;
    274       this.label4.Location = new System.Drawing.Point(3, 269);
     277      this.label4.Location = new System.Drawing.Point(3, 297);
    275278      this.label4.Name = "label4";
    276279      this.label4.Size = new System.Drawing.Size(62, 13);
     
    278281      this.label4.Text = "Disposable:";
    279282      //
     283      // cbxPublic
     284      //
     285      this.cbxPublic.AutoSize = true;
     286      this.cbxPublic.Enabled = false;
     287      this.cbxPublic.Location = new System.Drawing.Point(146, 63);
     288      this.cbxPublic.Name = "cbxPublic";
     289      this.cbxPublic.Size = new System.Drawing.Size(15, 14);
     290      this.cbxPublic.TabIndex = 36;
     291      this.cbxPublic.UseVisualStyleBackColor = true;
     292      this.cbxPublic.CheckedChanged += new System.EventHandler(this.cbxPublic_CheckedChanged);
     293      //
     294      // label5
     295      //
     296      this.label5.AutoSize = true;
     297      this.label5.Location = new System.Drawing.Point(3, 63);
     298      this.label5.Name = "label5";
     299      this.label5.Size = new System.Drawing.Size(39, 13);
     300      this.label5.TabIndex = 37;
     301      this.label5.Text = "Public:";
     302      //
    280303      // SlaveView
    281304      //
    282305      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    283306      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     307      this.Controls.Add(this.label5);
     308      this.Controls.Add(this.cbxPublic);
    284309      this.Controls.Add(this.label4);
    285310      this.Controls.Add(this.cbxDisposable);
     
    305330      this.Controls.Add(this.label9);
    306331      this.Name = "SlaveView";
    307       this.Size = new System.Drawing.Size(539, 285);
     332      this.Size = new System.Drawing.Size(539, 407);
    308333      this.ResumeLayout(false);
    309334      this.PerformLayout();
     
    335360    private System.Windows.Forms.CheckBox cbxDisposable;
    336361    private System.Windows.Forms.Label label4;
     362    private System.Windows.Forms.CheckBox cbxPublic;
     363    private System.Windows.Forms.Label label5;
    337364  }
    338365}
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs

    r7862 r8051  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Clients.Access;
    2425using HeuristicLab.Core.Views;
    2526using HeuristicLab.MainForm;
     
    6364        txtHbIntervall.Clear();
    6465        cbxDisposable.Checked = false;
     66        cbxPublic.Checked = false;
    6567      } else {
    6668        if (Content.GetType() == typeof(Slave)) {
    6769          ShowSlaveUI(true);
    6870          Slave ct = (Slave)Content;
     71          bool authorized = HiveServiceLocator.Instance.CallHiveService<bool>(service => service.AuthorizesForResourceAdministration(ct.Id));
    6972          txtName.Text = ct.Name;
    7073          txtHbIntervall.Text = ct.HbInterval.ToString();
    71           cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault();
     74          cbxPublic.Enabled = authorized;
     75          cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
     76          cbxPublic.Checked = ct.OwnerUserId == null;
     77          cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    7278          txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString());
    7379          txtDetailsDescription.Text = ct.Description;
     
    7884          txtFreeMemory.Text = ct.FreeMemory.ToString();
    7985          txtId.Text = ct.Id.ToString();
     86          cbxDisposable.Enabled = authorized;
     87          cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault();
    8088        } else if (Content.GetType() == typeof(SlaveGroup)) {
    8189          SlaveGroup ct = (SlaveGroup)Content;
    8290          txtName.Text = ct.Name;
    8391          txtHbIntervall.Text = ct.HbInterval.ToString();
     92          cbxPublic.Enabled = ct.Name != "UNGROUPED" && HiveRoles.CheckAdminUserPermissions();
     93          cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
     94          cbxPublic.Checked = ct.OwnerUserId == null;
     95          cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    8496          ShowSlaveUI(false);
    8597        } else {
     
    136148    }
    137149
    138     private void checkBox1_CheckedChanged(object sender, EventArgs e) {
     150    private void cbxDisposable_CheckedChanged(object sender, EventArgs e) {
    139151      if (Content != null) {
    140152        ((Slave)Content).IsDisposable = cbxDisposable.Checked;
    141153      }
    142154    }
     155
     156    private void cbxPublic_CheckedChanged(object sender, EventArgs e) {
     157      if (Content != null) {
     158        Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id);
     159      }
     160    }
    143161  }
    144162}
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r7916 r8051  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.269
     4//     Runtime Version:4.0.30319.17379
    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))]
    2221  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))]
    2322  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.JobPermission))]
    2423  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))]
     24  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.ResourcePermission))]
    2525  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.NamedHiveItem))]
    2626  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Job))]
     
    422422  [System.Diagnostics.DebuggerStepThroughAttribute()]
    423423  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     424  [System.Runtime.Serialization.DataContractAttribute(Name = "Downtime", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     425  [System.SerializableAttribute()]
     426  public partial class Downtime : HeuristicLab.Clients.Hive.HiveItem {
     427
     428    [System.Runtime.Serialization.OptionalFieldAttribute()]
     429    private bool AllDayEventField;
     430
     431    [System.Runtime.Serialization.OptionalFieldAttribute()]
     432    private System.DateTime EndDateField;
     433
     434    [System.Runtime.Serialization.OptionalFieldAttribute()]
     435    private bool RecurringField;
     436
     437    [System.Runtime.Serialization.OptionalFieldAttribute()]
     438    private System.Guid RecurringIdField;
     439
     440    [System.Runtime.Serialization.OptionalFieldAttribute()]
     441    private System.Guid ResourceIdField;
     442
     443    [System.Runtime.Serialization.OptionalFieldAttribute()]
     444    private System.DateTime StartDateField;
     445
     446    [System.Runtime.Serialization.DataMemberAttribute()]
     447    public bool AllDayEvent {
     448      get {
     449        return this.AllDayEventField;
     450      }
     451      set {
     452        if ((this.AllDayEventField.Equals(value) != true)) {
     453          this.AllDayEventField = value;
     454          this.RaisePropertyChanged("AllDayEvent");
     455        }
     456      }
     457    }
     458
     459    [System.Runtime.Serialization.DataMemberAttribute()]
     460    public System.DateTime EndDate {
     461      get {
     462        return this.EndDateField;
     463      }
     464      set {
     465        if ((this.EndDateField.Equals(value) != true)) {
     466          this.EndDateField = value;
     467          this.RaisePropertyChanged("EndDate");
     468        }
     469      }
     470    }
     471
     472    [System.Runtime.Serialization.DataMemberAttribute()]
     473    public bool Recurring {
     474      get {
     475        return this.RecurringField;
     476      }
     477      set {
     478        if ((this.RecurringField.Equals(value) != true)) {
     479          this.RecurringField = value;
     480          this.RaisePropertyChanged("Recurring");
     481        }
     482      }
     483    }
     484
     485    [System.Runtime.Serialization.DataMemberAttribute()]
     486    public System.Guid RecurringId {
     487      get {
     488        return this.RecurringIdField;
     489      }
     490      set {
     491        if ((this.RecurringIdField.Equals(value) != true)) {
     492          this.RecurringIdField = value;
     493          this.RaisePropertyChanged("RecurringId");
     494        }
     495      }
     496    }
     497
     498    [System.Runtime.Serialization.DataMemberAttribute()]
     499    public System.Guid ResourceId {
     500      get {
     501        return this.ResourceIdField;
     502      }
     503      set {
     504        if ((this.ResourceIdField.Equals(value) != true)) {
     505          this.ResourceIdField = value;
     506          this.RaisePropertyChanged("ResourceId");
     507        }
     508      }
     509    }
     510
     511    [System.Runtime.Serialization.DataMemberAttribute()]
     512    public System.DateTime StartDate {
     513      get {
     514        return this.StartDateField;
     515      }
     516      set {
     517        if ((this.StartDateField.Equals(value) != true)) {
     518          this.StartDateField = value;
     519          this.RaisePropertyChanged("StartDate");
     520        }
     521      }
     522    }
     523  }
     524
     525  [System.Diagnostics.DebuggerStepThroughAttribute()]
     526  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     527  [System.Runtime.Serialization.DataContractAttribute(Name = "JobPermission", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     528  [System.SerializableAttribute()]
     529  public partial class JobPermission : HeuristicLab.Clients.Hive.HiveItem {
     530
     531    [System.Runtime.Serialization.OptionalFieldAttribute()]
     532    private System.Guid GrantedByUserIdField;
     533
     534    [System.Runtime.Serialization.OptionalFieldAttribute()]
     535    private System.Guid GrantedUserIdField;
     536
     537    [System.Runtime.Serialization.OptionalFieldAttribute()]
     538    private System.Guid JobIdField;
     539
     540    [System.Runtime.Serialization.OptionalFieldAttribute()]
     541    private HeuristicLab.Clients.Hive.Permission PermissionField;
     542
     543    [System.Runtime.Serialization.DataMemberAttribute()]
     544    public System.Guid GrantedByUserId {
     545      get {
     546        return this.GrantedByUserIdField;
     547      }
     548      set {
     549        if ((this.GrantedByUserIdField.Equals(value) != true)) {
     550          this.GrantedByUserIdField = value;
     551          this.RaisePropertyChanged("GrantedByUserId");
     552        }
     553      }
     554    }
     555
     556    [System.Runtime.Serialization.DataMemberAttribute()]
     557    public System.Guid GrantedUserId {
     558      get {
     559        return this.GrantedUserIdField;
     560      }
     561      set {
     562        if ((this.GrantedUserIdField.Equals(value) != true)) {
     563          this.GrantedUserIdField = value;
     564          this.RaisePropertyChanged("GrantedUserId");
     565        }
     566      }
     567    }
     568
     569    [System.Runtime.Serialization.DataMemberAttribute()]
     570    public System.Guid JobId {
     571      get {
     572        return this.JobIdField;
     573      }
     574      set {
     575        if ((this.JobIdField.Equals(value) != true)) {
     576          this.JobIdField = value;
     577          this.RaisePropertyChanged("JobId");
     578        }
     579      }
     580    }
     581
     582    [System.Runtime.Serialization.DataMemberAttribute()]
     583    public HeuristicLab.Clients.Hive.Permission Permission {
     584      get {
     585        return this.PermissionField;
     586      }
     587      set {
     588        if ((this.PermissionField.Equals(value) != true)) {
     589          this.PermissionField = value;
     590          this.RaisePropertyChanged("Permission");
     591        }
     592      }
     593    }
     594  }
     595
     596  [System.Diagnostics.DebuggerStepThroughAttribute()]
     597  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     598  [System.Runtime.Serialization.DataContractAttribute(Name = "PluginData", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     599  [System.SerializableAttribute()]
     600  public partial class PluginData : HeuristicLab.Clients.Hive.HiveItem {
     601
     602    [System.Runtime.Serialization.OptionalFieldAttribute()]
     603    private byte[] DataField;
     604
     605    [System.Runtime.Serialization.OptionalFieldAttribute()]
     606    private string FileNameField;
     607
     608    [System.Runtime.Serialization.OptionalFieldAttribute()]
     609    private System.Guid PluginIdField;
     610
     611    [System.Runtime.Serialization.DataMemberAttribute()]
     612    public byte[] Data {
     613      get {
     614        return this.DataField;
     615      }
     616      set {
     617        if ((object.ReferenceEquals(this.DataField, value) != true)) {
     618          this.DataField = value;
     619          this.RaisePropertyChanged("Data");
     620        }
     621      }
     622    }
     623
     624    [System.Runtime.Serialization.DataMemberAttribute()]
     625    public string FileName {
     626      get {
     627        return this.FileNameField;
     628      }
     629      set {
     630        if ((object.ReferenceEquals(this.FileNameField, value) != true)) {
     631          this.FileNameField = value;
     632          this.RaisePropertyChanged("FileName");
     633        }
     634      }
     635    }
     636
     637    [System.Runtime.Serialization.DataMemberAttribute()]
     638    public System.Guid PluginId {
     639      get {
     640        return this.PluginIdField;
     641      }
     642      set {
     643        if ((this.PluginIdField.Equals(value) != true)) {
     644          this.PluginIdField = value;
     645          this.RaisePropertyChanged("PluginId");
     646        }
     647      }
     648    }
     649  }
     650
     651  [System.Diagnostics.DebuggerStepThroughAttribute()]
     652  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    424653  [System.Runtime.Serialization.DataContractAttribute(Name = "ResourcePermission", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    425654  [System.SerializableAttribute()]
     
    470699          this.ResourceIdField = value;
    471700          this.RaisePropertyChanged("ResourceId");
    472         }
    473       }
    474     }
    475   }
    476 
    477   [System.Diagnostics.DebuggerStepThroughAttribute()]
    478   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    479   [System.Runtime.Serialization.DataContractAttribute(Name = "Downtime", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    480   [System.SerializableAttribute()]
    481   public partial class Downtime : HeuristicLab.Clients.Hive.HiveItem {
    482 
    483     [System.Runtime.Serialization.OptionalFieldAttribute()]
    484     private bool AllDayEventField;
    485 
    486     [System.Runtime.Serialization.OptionalFieldAttribute()]
    487     private System.DateTime EndDateField;
    488 
    489     [System.Runtime.Serialization.OptionalFieldAttribute()]
    490     private bool RecurringField;
    491 
    492     [System.Runtime.Serialization.OptionalFieldAttribute()]
    493     private System.Guid RecurringIdField;
    494 
    495     [System.Runtime.Serialization.OptionalFieldAttribute()]
    496     private System.Guid ResourceIdField;
    497 
    498     [System.Runtime.Serialization.OptionalFieldAttribute()]
    499     private System.DateTime StartDateField;
    500 
    501     [System.Runtime.Serialization.DataMemberAttribute()]
    502     public bool AllDayEvent {
    503       get {
    504         return this.AllDayEventField;
    505       }
    506       set {
    507         if ((this.AllDayEventField.Equals(value) != true)) {
    508           this.AllDayEventField = value;
    509           this.RaisePropertyChanged("AllDayEvent");
    510         }
    511       }
    512     }
    513 
    514     [System.Runtime.Serialization.DataMemberAttribute()]
    515     public System.DateTime EndDate {
    516       get {
    517         return this.EndDateField;
    518       }
    519       set {
    520         if ((this.EndDateField.Equals(value) != true)) {
    521           this.EndDateField = value;
    522           this.RaisePropertyChanged("EndDate");
    523         }
    524       }
    525     }
    526 
    527     [System.Runtime.Serialization.DataMemberAttribute()]
    528     public bool Recurring {
    529       get {
    530         return this.RecurringField;
    531       }
    532       set {
    533         if ((this.RecurringField.Equals(value) != true)) {
    534           this.RecurringField = value;
    535           this.RaisePropertyChanged("Recurring");
    536         }
    537       }
    538     }
    539 
    540     [System.Runtime.Serialization.DataMemberAttribute()]
    541     public System.Guid RecurringId {
    542       get {
    543         return this.RecurringIdField;
    544       }
    545       set {
    546         if ((this.RecurringIdField.Equals(value) != true)) {
    547           this.RecurringIdField = value;
    548           this.RaisePropertyChanged("RecurringId");
    549         }
    550       }
    551     }
    552 
    553     [System.Runtime.Serialization.DataMemberAttribute()]
    554     public System.Guid ResourceId {
    555       get {
    556         return this.ResourceIdField;
    557       }
    558       set {
    559         if ((this.ResourceIdField.Equals(value) != true)) {
    560           this.ResourceIdField = value;
    561           this.RaisePropertyChanged("ResourceId");
    562         }
    563       }
    564     }
    565 
    566     [System.Runtime.Serialization.DataMemberAttribute()]
    567     public System.DateTime StartDate {
    568       get {
    569         return this.StartDateField;
    570       }
    571       set {
    572         if ((this.StartDateField.Equals(value) != true)) {
    573           this.StartDateField = value;
    574           this.RaisePropertyChanged("StartDate");
    575         }
    576       }
    577     }
    578   }
    579 
    580   [System.Diagnostics.DebuggerStepThroughAttribute()]
    581   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    582   [System.Runtime.Serialization.DataContractAttribute(Name = "JobPermission", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    583   [System.SerializableAttribute()]
    584   public partial class JobPermission : HeuristicLab.Clients.Hive.HiveItem {
    585 
    586     [System.Runtime.Serialization.OptionalFieldAttribute()]
    587     private System.Guid GrantedByUserIdField;
    588 
    589     [System.Runtime.Serialization.OptionalFieldAttribute()]
    590     private System.Guid GrantedUserIdField;
    591 
    592     [System.Runtime.Serialization.OptionalFieldAttribute()]
    593     private System.Guid JobIdField;
    594 
    595     [System.Runtime.Serialization.OptionalFieldAttribute()]
    596     private HeuristicLab.Clients.Hive.Permission PermissionField;
    597 
    598     [System.Runtime.Serialization.DataMemberAttribute()]
    599     public System.Guid GrantedByUserId {
    600       get {
    601         return this.GrantedByUserIdField;
    602       }
    603       set {
    604         if ((this.GrantedByUserIdField.Equals(value) != true)) {
    605           this.GrantedByUserIdField = value;
    606           this.RaisePropertyChanged("GrantedByUserId");
    607         }
    608       }
    609     }
    610 
    611     [System.Runtime.Serialization.DataMemberAttribute()]
    612     public System.Guid GrantedUserId {
    613       get {
    614         return this.GrantedUserIdField;
    615       }
    616       set {
    617         if ((this.GrantedUserIdField.Equals(value) != true)) {
    618           this.GrantedUserIdField = value;
    619           this.RaisePropertyChanged("GrantedUserId");
    620         }
    621       }
    622     }
    623 
    624     [System.Runtime.Serialization.DataMemberAttribute()]
    625     public System.Guid JobId {
    626       get {
    627         return this.JobIdField;
    628       }
    629       set {
    630         if ((this.JobIdField.Equals(value) != true)) {
    631           this.JobIdField = value;
    632           this.RaisePropertyChanged("JobId");
    633         }
    634       }
    635     }
    636 
    637     [System.Runtime.Serialization.DataMemberAttribute()]
    638     public HeuristicLab.Clients.Hive.Permission Permission {
    639       get {
    640         return this.PermissionField;
    641       }
    642       set {
    643         if ((this.PermissionField.Equals(value) != true)) {
    644           this.PermissionField = value;
    645           this.RaisePropertyChanged("Permission");
    646         }
    647       }
    648     }
    649   }
    650 
    651   [System.Diagnostics.DebuggerStepThroughAttribute()]
    652   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    653   [System.Runtime.Serialization.DataContractAttribute(Name = "PluginData", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    654   [System.SerializableAttribute()]
    655   public partial class PluginData : HeuristicLab.Clients.Hive.HiveItem {
    656 
    657     [System.Runtime.Serialization.OptionalFieldAttribute()]
    658     private byte[] DataField;
    659 
    660     [System.Runtime.Serialization.OptionalFieldAttribute()]
    661     private string FileNameField;
    662 
    663     [System.Runtime.Serialization.OptionalFieldAttribute()]
    664     private System.Guid PluginIdField;
    665 
    666     [System.Runtime.Serialization.DataMemberAttribute()]
    667     public byte[] Data {
    668       get {
    669         return this.DataField;
    670       }
    671       set {
    672         if ((object.ReferenceEquals(this.DataField, value) != true)) {
    673           this.DataField = value;
    674           this.RaisePropertyChanged("Data");
    675         }
    676       }
    677     }
    678 
    679     [System.Runtime.Serialization.DataMemberAttribute()]
    680     public string FileName {
    681       get {
    682         return this.FileNameField;
    683       }
    684       set {
    685         if ((object.ReferenceEquals(this.FileNameField, value) != true)) {
    686           this.FileNameField = value;
    687           this.RaisePropertyChanged("FileName");
    688         }
    689       }
    690     }
    691 
    692     [System.Runtime.Serialization.DataMemberAttribute()]
    693     public System.Guid PluginId {
    694       get {
    695         return this.PluginIdField;
    696       }
    697       set {
    698         if ((this.PluginIdField.Equals(value) != true)) {
    699           this.PluginIdField = value;
    700           this.RaisePropertyChanged("PluginId");
    701701        }
    702702      }
     
    16641664  public interface IHiveService {
    16651665
     1666    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaveGroup", ReplyAction = "http://tempuri.org/IHiveService/GetSlaveGroupResponse")]
     1667    HeuristicLab.Clients.Hive.SlaveGroup GetSlaveGroup(System.Guid slaveGroupId);
     1668
     1669    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaves", ReplyAction = "http://tempuri.org/IHiveService/GetSlavesResponse")]
     1670    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Slave> GetSlaves();
     1671
     1672    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaveGroups", ReplyAction = "http://tempuri.org/IHiveService/GetSlaveGroupsResponse")]
     1673    System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroups();
     1674
     1675    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateSlave", ReplyAction = "http://tempuri.org/IHiveService/UpdateSlaveResponse")]
     1676    void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave);
     1677
    16661678    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateSlaveGroup", ReplyAction = "http://tempuri.org/IHiveService/UpdateSlaveGroupResponse")]
    16671679    void UpdateSlaveGroup(HeuristicLab.Clients.Hive.SlaveGroup slaveGroup);
     
    16911703    int GetNewHeartbeatInterval(System.Guid slaveId);
    16921704
    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 
    17021705    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddDowntime", ReplyAction = "http://tempuri.org/IHiveService/AddDowntimeResponse")]
    17031706    System.Guid AddDowntime(HeuristicLab.Clients.Hive.Downtime downtime);
     
    17171720    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetUserIdByUsername", ReplyAction = "http://tempuri.org/IHiveService/GetUserIdByUsernameResponse")]
    17181721    System.Guid GetUserIdByUsername(string username);
     1722
     1723    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AuthorizesForResourceAdministration", ReplyAction = "http://tempuri.org/IHiveService/AuthorizesForResourceAdministrationResponse")]
     1724    bool AuthorizesForResourceAdministration(System.Guid resourceId);
    17191725
    17201726    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddTask", ReplyAction = "http://tempuri.org/IHiveService/AddTaskResponse")]
     
    18241830    void DeletePlugin(System.Guid pluginId);
    18251831
     1832    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GrantResourcePermissions", ReplyAction = "http://tempuri.org/IHiveService/GrantResourcePermissionsResponse")]
     1833    void GrantResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds);
     1834
     1835    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/RevokeResourcePermissions", ReplyAction = "http://tempuri.org/IHiveService/RevokeResourcePermissionsResponse")]
     1836    void RevokeResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds);
     1837
     1838    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetResourcePermissions", ReplyAction = "http://tempuri.org/IHiveService/GetResourcePermissionsResponse")]
     1839    System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetResourcePermissions(System.Guid resourceId);
     1840
    18261841    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddSlave", ReplyAction = "http://tempuri.org/IHiveService/AddSlaveResponse")]
    18271842    System.Guid AddSlave(HeuristicLab.Clients.Hive.Slave slave);
     
    18321847    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlave", ReplyAction = "http://tempuri.org/IHiveService/GetSlaveResponse")]
    18331848    HeuristicLab.Clients.Hive.Slave GetSlave(System.Guid slaveId);
    1834 
    1835     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaveGroup", ReplyAction = "http://tempuri.org/IHiveService/GetSlaveGroupResponse")]
    1836     HeuristicLab.Clients.Hive.SlaveGroup GetSlaveGroup(System.Guid slaveGroupId);
    1837 
    1838     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaves", ReplyAction = "http://tempuri.org/IHiveService/GetSlavesResponse")]
    1839     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Slave> GetSlaves();
    1840 
    1841     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetSlaveGroups", ReplyAction = "http://tempuri.org/IHiveService/GetSlaveGroupsResponse")]
    1842     System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroups();
    1843 
    1844     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateSlave", ReplyAction = "http://tempuri.org/IHiveService/UpdateSlaveResponse")]
    1845     void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave);
    18461849  }
    18471850
     
    18731876    }
    18741877
     1878    public HeuristicLab.Clients.Hive.SlaveGroup GetSlaveGroup(System.Guid slaveGroupId) {
     1879      return base.Channel.GetSlaveGroup(slaveGroupId);
     1880    }
     1881
     1882    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Slave> GetSlaves() {
     1883      return base.Channel.GetSlaves();
     1884    }
     1885
     1886    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroups() {
     1887      return base.Channel.GetSlaveGroups();
     1888    }
     1889
     1890    public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave) {
     1891      base.Channel.UpdateSlave(slave);
     1892    }
     1893
    18751894    public void UpdateSlaveGroup(HeuristicLab.Clients.Hive.SlaveGroup slaveGroup) {
    18761895      base.Channel.UpdateSlaveGroup(slaveGroup);
     
    19091928    }
    19101929
    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 
    19231930    public System.Guid AddDowntime(HeuristicLab.Clients.Hive.Downtime downtime) {
    19241931      return base.Channel.AddDowntime(downtime);
     
    19451952    }
    19461953
     1954    public bool AuthorizesForResourceAdministration(System.Guid resourceId) {
     1955      return base.Channel.AuthorizesForResourceAdministration(resourceId);
     1956    }
     1957
    19471958    public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds) {
    19481959      return base.Channel.AddTask(task, taskData, resourceIds);
     
    20852096    }
    20862097
     2098    public void GrantResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds) {
     2099      base.Channel.GrantResourcePermissions(resourceId, grantedUserIds);
     2100    }
     2101
     2102    public void RevokeResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds) {
     2103      base.Channel.RevokeResourcePermissions(resourceId, grantedUserIds);
     2104    }
     2105
     2106    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetResourcePermissions(System.Guid resourceId) {
     2107      return base.Channel.GetResourcePermissions(resourceId);
     2108    }
     2109
    20872110    public System.Guid AddSlave(HeuristicLab.Clients.Hive.Slave slave) {
    20882111      return base.Channel.AddSlave(slave);
     
    20962119      return base.Channel.GetSlave(slaveId);
    20972120    }
    2098 
    2099     public HeuristicLab.Clients.Hive.SlaveGroup GetSlaveGroup(System.Guid slaveGroupId) {
    2100       return base.Channel.GetSlaveGroup(slaveGroupId);
    2101     }
    2102 
    2103     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Slave> GetSlaves() {
    2104       return base.Channel.GetSlaves();
    2105     }
    2106 
    2107     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroups() {
    2108       return base.Channel.GetSlaveGroups();
    2109     }
    2110 
    2111     public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave) {
    2112       base.Channel.UpdateSlave(slave);
    2113     }
    21142121  }
    21152122}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r7916 r8051  
    172172  </ItemGroup>
    173173  <ItemGroup>
     174    <ProjectReference Include="..\..\HeuristicLab.Services.Access\3.3\HeuristicLab.Services.Access-3.3.csproj">
     175      <Project>{9FAC0B23-2730-452A-9BA0-D7CA1746C541}</Project>
     176      <Name>HeuristicLab.Services.Access-3.3</Name>
     177    </ProjectReference>
    174178    <ProjectReference Include="..\..\HeuristicLab.Services.Hive.DataAccess\3.3\HeuristicLab.Services.Hive.DataAccess-3.3.csproj">
    175179      <Project>{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}</Project>
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r7916 r8051  
    4141      get { return ServiceLocator.Instance.HiveDao; }
    4242    }
    43     private IAuthenticationManager authen {
    44       get { return ServiceLocator.Instance.AuthenticationManager; }
     43    private Access.IRoleVerifier authen {
     44      get { return ServiceLocator.Instance.RoleVerifier; }
    4545    }
    4646    private IAuthorizationManager author {
     
    5353      get { return ServiceLocator.Instance.EventManager; }
    5454    }
    55     private IUserManager userManager {
     55    private Access.IUserManager userManager {
    5656      get { return ServiceLocator.Instance.UserManager; }
    5757    }
     
    5959      get { return ServiceLocator.Instance.HeartbeatManager; }
    6060    }
     61
     62    #region Authorization Methods
     63    public bool AuthorizesForResourceAdministration(Guid resourceId) {
     64      try {
     65        author.AuthorizeForResourceAdministration(resourceId);
     66        return true;
     67      }
     68      catch (System.Security.SecurityException) { return false; }
     69    }
     70    #endregion
    6171
    6272    #region Task Methods
     
    467477
    468478    #region ResourcePermission Methods
    469     public void GrantResourcePermission(Guid resourceId, Guid grantedUserId) {
     479    public void GrantResourcePermissions(Guid resourceId, params Guid[] grantedUserIds) {
    470480      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    471481      trans.UseTransaction(() => {
    472482        Resource resource = dao.GetResource(resourceId);
    473483        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) {
     484        if (resource.OwnerUserId != userManager.CurrentUserId && !authen.IsInRole(HiveRoles.Administrator)) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permission for this resource"));
     485        foreach (Guid id in grantedUserIds)
     486          dao.AddResourcePermission(new ResourcePermission { ResourceId = resourceId, GrantedByUserId = userManager.CurrentUserId, GrantedUserId = id });
     487      });
     488    }
     489
     490    public void RevokeResourcePermissions(Guid resourceId, params Guid[] grantedUserIds) {
    480491      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    481492      trans.UseTransaction(() => {
    482493        Resource resource = dao.GetResource(resourceId);
    483494        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);
     495        if (resource.OwnerUserId != userManager.CurrentUserId && !authen.IsInRole(HiveRoles.Administrator)) throw new FaultException<FaultReason>(new FaultReason("Not allowed to revoke permission for this resource"));
     496        foreach (Guid id in grantedUserIds)
     497          dao.DeleteResourcePermission(resourceId, id);
    486498      });
    487499    }
     
    492504        Resource resource = dao.GetResource(resourceId);
    493505        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"));
    495506        return dao.GetResourcePermissions(x => x.ResourceId == resourceId);
    496507      });
     
    515526
    516527    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
    517       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     528      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    518529      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    519530    }
     
    531542    public IEnumerable<Slave> GetSlaves() {
    532543      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    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));
     544      return dao.GetSlaves(x => true).Where(x => x.OwnerUserId == null
     545                                         || x.OwnerUserId == userManager.CurrentUserId
     546                                         || userManager.VerifyUser(userManager.CurrentUserId, GetResourcePermissions(x.Id).Select(y => y.GrantedUserId).ToList())
     547                                         || authen.IsInRole(HiveRoles.Administrator)).ToArray();
    537548    }
    538549
    539550    public IEnumerable<SlaveGroup> GetSlaveGroups() {
    540551      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    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));
     552      return dao.GetSlaveGroups(x => true).Where(x => x.OwnerUserId == null
     553                                              || x.OwnerUserId == userManager.CurrentUserId
     554                                              || userManager.VerifyUser(userManager.CurrentUserId, GetResourcePermissions(x.Id).Select(y => y.GrantedUserId).ToList())
     555                                              || authen.IsInRole(HiveRoles.Administrator)).ToArray();
    545556    }
    546557
    547558    public void UpdateSlave(Slave slave) {
    548       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     559      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    549560      trans.UseTransaction(() => {
    550561        dao.UpdateSlave(slave);
     
    553564
    554565    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
    555       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     566      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    556567      trans.UseTransaction(() => {
    557568        dao.UpdateSlaveGroup(slaveGroup);
     
    560571
    561572    public void DeleteSlave(Guid slaveId) {
    562       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     573      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     574      author.AuthorizeForResourceAdministration(slaveId);
    563575      trans.UseTransaction(() => {
    564576        dao.DeleteSlave(slaveId);
     
    567579
    568580    public void DeleteSlaveGroup(Guid slaveGroupId) {
    569       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     581      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     582      author.AuthorizeForResourceAdministration(slaveGroupId);
    570583      trans.UseTransaction(() => {
    571584        dao.DeleteSlaveGroup(slaveGroupId);
     
    623636    #region Downtime Methods
    624637    public Guid AddDowntime(Downtime downtime) {
    625       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     638      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     639      author.AuthorizeForResourceAdministration(downtime.ResourceId);
    626640      return trans.UseTransaction(() => dao.AddDowntime(downtime));
    627641    }
    628642
    629643    public void DeleteDowntime(Guid downtimeId) {
    630       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     644      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     645      // TODO: pass resource id
     646      // author.AuthorizeForResource(resourceId);
    631647      trans.UseTransaction(() => {
    632648        dao.DeleteDowntime(downtimeId);
     
    635651
    636652    public void UpdateDowntime(Downtime downtime) {
    637       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     653      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     654      author.AuthorizeForResourceAdministration(downtime.ResourceId);
    638655      trans.UseTransaction(() => {
    639656        dao.UpdateDowntime(downtime);
     
    642659
    643660    public IEnumerable<Downtime> GetDowntimesForResource(Guid resourceId) {
    644       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     661      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    645662      return trans.UseTransaction(() => dao.GetDowntimes(x => x.ResourceId == resourceId));
    646663    }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs

    r7259 r8051  
    3333
    3434    void AuthorizeForJob(Guid jobId, Permission requiredPermission);
     35
     36    void AuthorizeForResourceAdministration(Guid resourceId);
    3537  }
    3638}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IServiceLocator.cs

    r7259 r8051  
    2424namespace HeuristicLab.Services.Hive {
    2525  public interface IServiceLocator {
    26     IAuthenticationManager AuthenticationManager { get; }
     26    Access.IRoleVerifier RoleVerifier { get; }
    2727    IAuthorizationManager AuthorizationManager { get; }
    2828    IHiveDao HiveDao { get; }
    2929    IEventManager EventManager { get; }
    3030    ITransactionManager TransactionManager { get; }
    31     IUserManager UserManager { get; }
     31    Access.IUserManager UserManager { get; }
    3232    HeartbeatManager HeartbeatManager { get; }
    3333  }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r7259 r8051  
    3434
    3535    public void AuthorizeForTask(Guid taskId, DT.Permission requiredPermission) {
    36       if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
     36      if (ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
    3737
    3838      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId);
     
    4646        throw new SecurityException("Current user is not authorized to access task");
    4747    }
     48
     49    public void AuthorizeForResourceAdministration(Guid resourceId) {
     50      Resource resource = DT.Convert.ToEntity(ServiceLocator.Instance.HiveDao.GetResource(resourceId));
     51      if (resource.OwnerUserId != ServiceLocator.Instance.UserManager.CurrentUserId && !ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Administrator))
     52        throw new SecurityException("Current user is not authorized to access resource");
     53    }
    4854  }
    4955}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Plugin.cs.frame

    r7259 r8051  
    2929  [Plugin("HeuristicLab.Services.Hive", "3.3.6.$WCREV$")]
    3030  [PluginFile("HeuristicLab.Services.Hive-3.3.dll", PluginFileType.Assembly)]
    31   [PluginDependency("HeuristicLab.Common", "3.3")] 
     31  [PluginDependency("HeuristicLab.Common", "3.3")]
    3232  [PluginDependency("HeuristicLab.Core", "3.3")]
    33   [PluginDependency("HeuristicLab.Persistence", "3.3")] 
     33  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     34  [PluginDependency("HeuristicLab.Services.Access-3.3", "3.3")]
    3435  [PluginDependency("HeuristicLab.Services.Hive.DataAccess", "3.3")]
    3536  public class HeuristicLabServicesHivePlugin : PluginBase {
  • trunk/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r7916 r8051  
    3030  [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    3131  public interface IHiveService {
     32    #region Authorization Methods
     33    [OperationContract]
     34    bool AuthorizesForResourceAdministration(Guid resourceId);
     35    #endregion
    3236
    3337    #region Task Methods
     
    160164    #region ResourcePermission Methods
    161165    [OperationContract]
    162     void GrantResourcePermission(Guid resourceId, Guid grantedUserId);
    163 
    164     [OperationContract]
    165     void RevokeResourcePermission(Guid resourceId, Guid grantedUserId);
     166    void GrantResourcePermissions(Guid resourceId, params Guid[] grantedUserIds);
     167
     168    [OperationContract]
     169    void RevokeResourcePermissions(Guid resourceId, params Guid[] grantedUserIds);
    166170
    167171    [OperationContract]
  • trunk/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r7259 r8051  
    4242    }
    4343
    44     private IAuthenticationManager authenticationManager;
    45     public IAuthenticationManager AuthenticationManager {
     44    private Access.IRoleVerifier roleVerifier;
     45    public Access.IRoleVerifier RoleVerifier {
    4646      get {
    47         if (authenticationManager == null) authenticationManager = new AuthenticationManager();
    48         return authenticationManager;
     47        if (roleVerifier == null) roleVerifier = new Access.RoleVerifier();
     48        return roleVerifier;
    4949      }
    5050    }
     
    7474    }
    7575
    76     private IUserManager userManager;
    77     public IUserManager UserManager {
     76    private Access.IUserManager userManager;
     77    public Access.IUserManager UserManager {
    7878      get {
    79         if (userManager == null) userManager = new UserManager();
     79        if (userManager == null) userManager = new Access.UserManager();
    8080        return userManager;
    8181      }
     
    8585    public HeartbeatManager HeartbeatManager {
    8686      get {
    87         if(heartbeatManager == null) heartbeatManager = new HeartbeatManager();
     87        if (heartbeatManager == null) heartbeatManager = new HeartbeatManager();
    8888        return heartbeatManager;
    8989      }
Note: See TracChangeset for help on using the changeset viewer.