26
26
import com .cognifide .apm .core .grammar .ScriptExecutionException ;
27
27
import com .cognifide .apm .core .grammar .datasource .DataSourceInvoker ;
28
28
import com .cognifide .apm .core .scripts .MutableScriptWrapper ;
29
- import com .cognifide .apm .core .scripts .ScriptNode ;
30
29
import com .day .cq .commons .jcr .JcrUtil ;
31
30
import com .day .crx .JcrConstants ;
32
31
import java .util .List ;
@@ -116,15 +115,14 @@ private void createVersion(ResourceResolver resolver, Script script) {
116
115
Node versionNode = createVersionNode (scriptNode , script , session );
117
116
copyScriptContent (versionNode , script , session );
118
117
session .save ();
119
- resolver .commit ();
120
118
} catch (Exception e ) {
121
119
LOGGER .error ("Issues with saving to repository while logging script execution" , e );
122
120
}
123
121
}
124
122
125
123
private Node createScriptNode (Script script , Session session ) throws RepositoryException {
126
124
String path = getScriptVersionPath (script );
127
- Node scriptHistory = JcrUtils .getOrCreateByPath (path , "sling:OrderedFolder" , JcrConstants .NT_UNSTRUCTURED , session , true );
125
+ Node scriptHistory = JcrUtils .getOrCreateByPath (path , "sling:OrderedFolder" , JcrConstants .NT_UNSTRUCTURED , session , false );
128
126
scriptHistory .setProperty ("scriptPath" , script .getPath ());
129
127
scriptHistory .setProperty ("lastChecksum" , script .getChecksum ());
130
128
return scriptHistory ;
@@ -136,14 +134,13 @@ private String getScriptVersionPath(Script script) {
136
134
137
135
private Node createVersionNode (Node parent , Script script , Session session ) throws RepositoryException {
138
136
String path = parent .getPath () + "/" + script .getChecksum ();
139
- return JcrUtils .getOrCreateByPath (path , "sling:OrderedFolder" , "sling:OrderedFolder" , session , true );
137
+ return JcrUtils .getOrCreateByPath (path , "sling:OrderedFolder" , "sling:OrderedFolder" , session , false );
140
138
}
141
139
142
140
private void copyScriptContent (Node parent , Script script , Session session ) throws RepositoryException {
143
141
if (!parent .hasNode (SCRIPT_NODE_NAME )) {
144
142
Node source = session .getNode (script .getPath ());
145
- Node file = JcrUtil .copy (source , parent , SCRIPT_NODE_NAME );
146
- file .addMixin (ScriptNode .APM_SCRIPT );
143
+ JcrUtil .copy (source , parent , SCRIPT_NODE_NAME );
147
144
}
148
145
}
149
146
0 commit comments