Skip to content

Commit 9824913

Browse files
committed
Adds support for returning the request ID when an update operation requires authorization
1 parent da738bd commit 9824913

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

src/Lithnet.ResourceManagement.Automation.Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Product Id="*"
55
Name="Lithnet FIM/MIM Service PowerShell Module"
66
Language="1033"
7-
Version="1.0.6048"
7+
Version="1.0.6088"
88
Manufacturer="Lithnet"
99
UpgradeCode="CC6C89F6-8663-46ED-A792-15B1327D8AA8">
1010
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

src/Lithnet.ResourceManagement.Automation/Lithnet.ResourceManagement.Automation.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
<Prefer32Bit>false</Prefer32Bit>
3636
</PropertyGroup>
3737
<ItemGroup>
38-
<Reference Include="Lithnet.ResourceManagement.Client, Version=1.0.6048.17046, Culture=neutral, processorArchitecture=MSIL">
39-
<HintPath>..\packages\Lithnet.ResourceManagement.Client.1.0.6048.17046\lib\net40\Lithnet.ResourceManagement.Client.dll</HintPath>
38+
<Reference Include="Lithnet.ResourceManagement.Client, Version=1.0.6088.20561, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>..\packages\Lithnet.ResourceManagement.Client.1.0.6088.20561\lib\net40\Lithnet.ResourceManagement.Client.dll</HintPath>
4040
<Private>True</Private>
4141
</Reference>
4242
<Reference Include="Microsoft.ResourceManagement, Version=4.1.3451.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

src/Lithnet.ResourceManagement.Automation/SaveResource.cs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,50 @@ public class SaveResource : Cmdlet
2525

2626
protected override void ProcessRecord()
2727
{
28-
IEnumerable<RmaObject> creatingObjects = this.Resources.Where(t => t.InternalObject.ModificationType == OperationType.Create).ToList();
29-
30-
if (this.Locale != null || this.Resources.Any(t => t.InternalObject.Locale != null))
28+
try
3129
{
32-
CultureInfo locale = null;
30+
IEnumerable<RmaObject> creatingObjects = this.Resources.Where(t => t.InternalObject.ModificationType == OperationType.Create).ToList();
3331

34-
if (this.Locale != null)
32+
if (this.Locale != null || this.Resources.Any(t => t.InternalObject.Locale != null))
3533
{
36-
locale = new CultureInfo(this.Locale);
37-
}
34+
CultureInfo locale = null;
3835

39-
if (this.Resources.Length > 1)
40-
{
41-
this.WriteWarning("Composite save disabled as locale parameter has been specified or at least one resource has been localized");
42-
}
36+
if (this.Locale != null)
37+
{
38+
locale = new CultureInfo(this.Locale);
39+
}
4340

44-
foreach (ResourceObject r in this.Resources.Select(t => t.GetResourceWithAppliedChanges()))
45-
{
46-
RmcWrapper.Client.SaveResource(r, locale);
41+
if (this.Resources.Length > 1)
42+
{
43+
this.WriteWarning("Composite save disabled as locale parameter has been specified or at least one resource has been localized");
44+
}
45+
46+
foreach (ResourceObject r in this.Resources.Select(t => t.GetResourceWithAppliedChanges()))
47+
{
48+
RmcWrapper.Client.SaveResource(r, locale);
49+
}
4750
}
48-
}
49-
else
50-
{
51-
if (this.Parallel.IsPresent)
51+
else
5252
{
53-
RmcWrapper.Client.SaveResourcesParallel(this.Resources.Select(t => t.GetResourceWithAppliedChanges()), -1);
53+
if (this.Parallel.IsPresent)
54+
{
55+
RmcWrapper.Client.SaveResourcesParallel(this.Resources.Select(t => t.GetResourceWithAppliedChanges()), -1);
56+
}
57+
else
58+
{
59+
RmcWrapper.Client.SaveResources(this.Resources.Select(t => t.GetResourceWithAppliedChanges()));
60+
}
5461
}
55-
else
62+
63+
foreach (RmaObject resource in creatingObjects)
5664
{
57-
RmcWrapper.Client.SaveResources(this.Resources.Select(t => t.GetResourceWithAppliedChanges()));
65+
resource.ReloadProperties();
5866
}
5967
}
60-
61-
foreach (RmaObject resource in creatingObjects)
68+
catch (AuthorizationRequiredException ex)
6269
{
63-
resource.ReloadProperties();
70+
this.WriteVerbose("Authorization required: " + ex.ResourceReference);
71+
this.WriteObject(ex.ResourceReference);
6472
}
6573
}
6674
}

src/Lithnet.ResourceManagement.Automation/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<packages>
33
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net45" developmentDependency="true" />
44
<package id="Fody" version="1.29.2" targetFramework="net45" developmentDependency="true" />
5-
<package id="Lithnet.ResourceManagement.Client" version="1.0.6048.17046" targetFramework="net45" />
5+
<package id="Lithnet.ResourceManagement.Client" version="1.0.6088.20561" targetFramework="net45" />
66
</packages>

0 commit comments

Comments
 (0)