10
10
using Umbraco . Extensions ;
11
11
using Umbraco . Cms . Core ;
12
12
using System . Linq ;
13
- using Umbraco . Deploy . Core ;
14
13
15
14
namespace Umbraco . Commerce . Deploy . Composing
16
15
{
@@ -20,7 +19,8 @@ public partial class UmbracoCommerceDeployComponent : IComponent
20
19
private readonly IServiceConnectorFactory _serviceConnectorFactory ;
21
20
private readonly ITransferEntityService _transferEntityService ;
22
21
23
- public UmbracoCommerceDeployComponent ( IDiskEntityService diskEntityService ,
22
+ public UmbracoCommerceDeployComponent (
23
+ IDiskEntityService diskEntityService ,
24
24
IServiceConnectorFactory serviceConnectorFactory ,
25
25
ITransferEntityService transferEntityService )
26
26
{
@@ -70,20 +70,36 @@ private void InitializeIntegratedEntities()
70
70
SupportsRestore = true ,
71
71
PermittedToRestore = true ,
72
72
SupportsPartialRestore = true ,
73
- SupportsImportExport = true
73
+ //SupportsImportExport = true,
74
+ //SupportsExportOfDescendants = true
74
75
} ,
75
76
false ,
76
77
Cms . Constants . Trees . Stores . Alias ,
77
78
( string routePath , HttpContext httpContext ) => MatchesRoutePath ( routePath , "productattribute" ) ,
78
79
( string nodeId , HttpContext httpContext ) => MatchesNodeId (
79
80
nodeId ,
80
81
httpContext ,
81
- new Cms . Constants . Trees . Stores . NodeType [ ]
82
- {
82
+ [
83
83
Cms . Constants . Trees . Stores . NodeType . ProductAttributes ,
84
84
Cms . Constants . Trees . Stores . NodeType . ProductAttribute
85
- } ) ,
86
- ( string nodeId , HttpContext httpContext , out Guid entityId ) => Guid . TryParse ( nodeId , out entityId ) ) ;
85
+ ] ) ,
86
+ ( string nodeId , HttpContext httpContext , out Guid entityId ) =>
87
+ {
88
+ if ( Guid . TryParse ( nodeId , out entityId ) )
89
+ {
90
+ return true ;
91
+ }
92
+ else if ( int . TryParse ( nodeId , out int id ) && id == Cms . Constants . Trees . Stores . Ids [ Cms . Constants . Trees . Stores . NodeType . ProductAttributes ] )
93
+ {
94
+ entityId = Guid . Empty ;
95
+ return true ;
96
+ }
97
+ else
98
+ {
99
+ entityId = Guid . Empty ;
100
+ return false ;
101
+ }
102
+ } ) ;
87
103
// TODO: , new DeployTransferRegisteredEntityTypeDetail.RemoteTreeDetail(FormsTreeHelper.GetExampleTree, "example", "externalExampleTree"));
88
104
89
105
_transferEntityService . RegisterTransferEntityType < ProductAttributePresetReadOnly > (
@@ -96,20 +112,36 @@ private void InitializeIntegratedEntities()
96
112
SupportsRestore = true ,
97
113
PermittedToRestore = true ,
98
114
SupportsPartialRestore = true ,
99
- SupportsImportExport = true
115
+ //SupportsImportExport = true,
116
+ //SupportsExportOfDescendants = true
100
117
} ,
101
118
false ,
102
119
Cms . Constants . Trees . Stores . Alias ,
103
120
( string routePath , HttpContext httpContext ) => MatchesRoutePath ( routePath , "productattributepreset" ) ,
104
121
( string nodeId , HttpContext httpContext ) => MatchesNodeId (
105
122
nodeId ,
106
123
httpContext ,
107
- new Cms . Constants . Trees . Stores . NodeType [ ]
108
- {
124
+ [
109
125
Cms . Constants . Trees . Stores . NodeType . ProductAttributePresets ,
110
126
Cms . Constants . Trees . Stores . NodeType . ProductAttributePreset
111
- } ) ,
112
- ( string nodeId , HttpContext httpContext , out Guid entityId ) => Guid . TryParse ( nodeId , out entityId ) ) ;
127
+ ] ) ,
128
+ ( string nodeId , HttpContext httpContext , out Guid entityId ) =>
129
+ {
130
+ if ( Guid . TryParse ( nodeId , out entityId ) )
131
+ {
132
+ return true ;
133
+ }
134
+ else if ( int . TryParse ( nodeId , out int id ) && id == Cms . Constants . Trees . Stores . Ids [ Cms . Constants . Trees . Stores . NodeType . ProductAttributePresets ] )
135
+ {
136
+ entityId = Guid . Empty ;
137
+ return true ;
138
+ }
139
+ else
140
+ {
141
+ entityId = Guid . Empty ;
142
+ return false ;
143
+ }
144
+ } ) ;
113
145
// TODO: , new DeployTransferRegisteredEntityTypeDetail.RemoteTreeDetail(FormsTreeHelper.GetExampleTree, "example", "externalExampleTree"));
114
146
}
115
147
@@ -118,6 +150,17 @@ private static bool MatchesRoutePath(string routePath, string routePartPrefix)
118
150
119
151
private static bool MatchesNodeId ( string nodeId , HttpContext httpContext , Cms . Constants . Trees . Stores . NodeType [ ] nodeTypes )
120
152
{
153
+ if ( int . TryParse ( nodeId , out int id ) )
154
+ {
155
+ foreach ( var nt in nodeTypes )
156
+ {
157
+ if ( Cms . Constants . Trees . Stores . Ids . ContainsKey ( nt ) && Cms . Constants . Trees . Stores . Ids [ nt ] == id )
158
+ {
159
+ return true ;
160
+ }
161
+ }
162
+ }
163
+
121
164
var nodeType = httpContext . Request . Query [ "nodeType" ] . ToString ( ) ;
122
165
return nodeTypes . Select ( x => x . ToString ( ) ) . InvariantContains ( nodeType ) ;
123
166
}
0 commit comments