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