]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java
9ff8f15fb9fb006a332c183382995da7af9d6d8a
[gpl/argeo-slc.git] / runtime / org.argeo.slc.repo / src / main / java / org / argeo / slc / repo / RepoUtils.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.repo;
17
18 import java.io.ByteArrayOutputStream;
19 import java.io.File;
20 import java.io.FileInputStream;
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.OutputStream;
24 import java.util.Enumeration;
25 import java.util.Iterator;
26 import java.util.Set;
27 import java.util.StringTokenizer;
28 import java.util.TreeSet;
29 import java.util.jar.Attributes;
30 import java.util.jar.JarEntry;
31 import java.util.jar.JarFile;
32 import java.util.jar.JarInputStream;
33 import java.util.jar.JarOutputStream;
34 import java.util.jar.Manifest;
35 import java.util.zip.ZipInputStream;
36
37 import javax.jcr.Credentials;
38 import javax.jcr.GuestCredentials;
39 import javax.jcr.Node;
40 import javax.jcr.NodeIterator;
41 import javax.jcr.Property;
42 import javax.jcr.PropertyIterator;
43 import javax.jcr.Repository;
44 import javax.jcr.RepositoryException;
45 import javax.jcr.RepositoryFactory;
46 import javax.jcr.Session;
47 import javax.jcr.SimpleCredentials;
48 import javax.jcr.nodetype.NodeType;
49
50 import org.apache.commons.io.FilenameUtils;
51 import org.apache.commons.io.IOUtils;
52 import org.apache.commons.logging.Log;
53 import org.apache.commons.logging.LogFactory;
54 import org.argeo.ArgeoMonitor;
55 import org.argeo.jcr.ArgeoJcrUtils;
56 import org.argeo.jcr.ArgeoNames;
57 import org.argeo.jcr.ArgeoTypes;
58 import org.argeo.jcr.JcrUtils;
59 import org.argeo.slc.DefaultNameVersion;
60 import org.argeo.slc.NameVersion;
61 import org.argeo.slc.SlcException;
62 import org.argeo.slc.aether.ArtifactIdComparator;
63 import org.argeo.slc.jcr.SlcNames;
64 import org.argeo.slc.jcr.SlcTypes;
65 import org.argeo.slc.repo.maven.MavenConventionsUtils;
66 import org.argeo.util.security.Keyring;
67 import org.osgi.framework.Constants;
68 import org.sonatype.aether.artifact.Artifact;
69 import org.sonatype.aether.util.artifact.DefaultArtifact;
70
71 /** Utilities around repo */
72 public class RepoUtils implements ArgeoNames, SlcNames {
73 private final static Log log = LogFactory.getLog(RepoUtils.class);
74
75 /** Packages a regular sources jar as PDE source. */
76 public static void packagesAsPdeSource(File sourceFile,
77 NameVersion nameVersion, OutputStream out) throws IOException {
78 if (isAlreadyPdeSource(sourceFile)) {
79 FileInputStream in = new FileInputStream(sourceFile);
80 IOUtils.copy(in, out);
81 IOUtils.closeQuietly(in);
82 } else {
83 String sourceSymbolicName = nameVersion.getName() + ".source";
84
85 Manifest sourceManifest = null;
86 sourceManifest = new Manifest();
87 sourceManifest.getMainAttributes().put(
88 Attributes.Name.MANIFEST_VERSION, "1.0");
89 sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
90 sourceSymbolicName);
91 sourceManifest.getMainAttributes().putValue("Bundle-Version",
92 nameVersion.getVersion());
93 sourceManifest.getMainAttributes().putValue(
94 "Eclipse-SourceBundle",
95 nameVersion.getName() + ";version="
96 + nameVersion.getVersion());
97 copyJar(sourceFile, out, sourceManifest);
98 }
99 }
100
101 public static byte[] packageAsPdeSource(InputStream sourceJar,
102 NameVersion nameVersion) {
103 String sourceSymbolicName = nameVersion.getName() + ".source";
104
105 Manifest sourceManifest = null;
106 sourceManifest = new Manifest();
107 sourceManifest.getMainAttributes().put(
108 Attributes.Name.MANIFEST_VERSION, "1.0");
109 sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
110 sourceSymbolicName);
111 sourceManifest.getMainAttributes().putValue("Bundle-Version",
112 nameVersion.getVersion());
113 sourceManifest.getMainAttributes().putValue("Eclipse-SourceBundle",
114 nameVersion.getName() + ";version=" + nameVersion.getVersion());
115
116 return modifyManifest(sourceJar, sourceManifest);
117 }
118
119 /**
120 * Check whether the file as already been packaged as PDE source, in order
121 * not to mess with Jar signing
122 */
123 private static boolean isAlreadyPdeSource(File sourceFile) {
124 JarInputStream jarInputStream = null;
125
126 try {
127 jarInputStream = new JarInputStream(new FileInputStream(sourceFile));
128
129 Manifest manifest = jarInputStream.getManifest();
130 Iterator<?> it = manifest.getMainAttributes().keySet().iterator();
131 boolean res = false;
132 // containsKey() does not work, iterating...
133 while (it.hasNext())
134 if (it.next().toString().equals("Eclipse-SourceBundle")) {
135 res = true;
136 break;
137 }
138 // boolean res = manifest.getMainAttributes().get(
139 // "Eclipse-SourceBundle") != null;
140 if (res)
141 log.info(sourceFile + " is already a PDE source");
142 return res;
143 } catch (Exception e) {
144 // probably not a jar, skipping
145 if (log.isDebugEnabled())
146 log.debug("Skipping " + sourceFile + " because of "
147 + e.getMessage());
148 return false;
149 } finally {
150 IOUtils.closeQuietly(jarInputStream);
151 }
152 }
153
154 /**
155 * Copy a jar, replacing its manifest with the provided one
156 *
157 * @param manifest
158 * can be null
159 */
160 private static void copyJar(File source, OutputStream out, Manifest manifest)
161 throws IOException {
162 JarFile sourceJar = null;
163 JarOutputStream output = null;
164 try {
165 output = manifest != null ? new JarOutputStream(out, manifest)
166 : new JarOutputStream(out);
167 sourceJar = new JarFile(source);
168
169 entries: for (Enumeration<?> entries = sourceJar.entries(); entries
170 .hasMoreElements();) {
171 JarEntry entry = (JarEntry) entries.nextElement();
172 if (manifest != null
173 && entry.getName().equals("META-INF/MANIFEST.MF"))
174 continue entries;
175
176 InputStream entryStream = sourceJar.getInputStream(entry);
177 JarEntry newEntry = new JarEntry(entry.getName());
178 // newEntry.setMethod(JarEntry.DEFLATED);
179 output.putNextEntry(newEntry);
180 IOUtils.copy(entryStream, output);
181 }
182 } finally {
183 IOUtils.closeQuietly(output);
184 try {
185 if (sourceJar != null)
186 sourceJar.close();
187 } catch (IOException e) {
188 // silent
189 }
190 }
191 }
192
193 /** Copy a jar changing onlythe manifest */
194 public static void copyJar(InputStream in, OutputStream out,
195 Manifest manifest) {
196 JarInputStream jarIn = null;
197 JarOutputStream jarOut = null;
198 try {
199 jarIn = new JarInputStream(in);
200 jarOut = new JarOutputStream(out, manifest);
201 JarEntry jarEntry = null;
202 while ((jarEntry = jarIn.getNextJarEntry()) != null) {
203 JarEntry newJarEntry = new JarEntry(jarEntry.getName());
204 jarOut.putNextEntry(newJarEntry);
205 IOUtils.copy(jarIn, jarOut);
206 jarIn.closeEntry();
207 jarOut.closeEntry();
208 }
209 } catch (IOException e) {
210 throw new SlcException("Could not copy jar with MANIFEST "
211 + manifest.getMainAttributes(), e);
212 } finally {
213 if (!(in instanceof ZipInputStream))
214 IOUtils.closeQuietly(jarIn);
215 IOUtils.closeQuietly(jarOut);
216 }
217 }
218
219 /** Reads a jar file, modify its manifest */
220 public static byte[] modifyManifest(InputStream in, Manifest manifest) {
221 ByteArrayOutputStream out = new ByteArrayOutputStream(200 * 1024);
222 try {
223 copyJar(in, out, manifest);
224 return out.toByteArray();
225 } finally {
226 IOUtils.closeQuietly(out);
227 }
228 }
229
230 /** Read the OSGi {@link NameVersion} */
231 public static NameVersion readNameVersion(Artifact artifact) {
232 File artifactFile = artifact.getFile();
233 if (artifact.getExtension().equals("pom")) {
234 // hack to process jars which weirdly appear as POMs
235 File jarFile = new File(artifactFile.getParentFile(),
236 FilenameUtils.getBaseName(artifactFile.getPath()) + ".jar");
237 if (jarFile.exists()) {
238 log.warn("Use " + jarFile + " instead of " + artifactFile
239 + " for " + artifact);
240 artifactFile = jarFile;
241 }
242 }
243 return readNameVersion(artifactFile);
244 }
245
246 /** Read the OSGi {@link NameVersion} */
247 public static NameVersion readNameVersion(File artifactFile) {
248 try {
249 return readNameVersion(new FileInputStream(artifactFile));
250 } catch (Exception e) {
251 // probably not a jar, skipping
252 if (log.isDebugEnabled()) {
253 log.debug("Skipping " + artifactFile + " because of " + e);
254 // e.printStackTrace();
255 }
256 }
257 return null;
258 }
259
260 /** Read the OSGi {@link NameVersion} */
261 public static NameVersion readNameVersion(InputStream in) {
262 JarInputStream jarInputStream = null;
263 try {
264 jarInputStream = new JarInputStream(in);
265 return readNameVersion(jarInputStream.getManifest());
266 } catch (Exception e) {
267 // probably not a jar, skipping
268 if (log.isDebugEnabled()) {
269 log.debug("Skipping because of " + e);
270 e.printStackTrace();
271 }
272 } finally {
273 IOUtils.closeQuietly(jarInputStream);
274 }
275 return null;
276 }
277
278 /** Read the OSGi {@link NameVersion} */
279 public static NameVersion readNameVersion(Manifest manifest) {
280 DefaultNameVersion nameVersion = new DefaultNameVersion();
281 nameVersion.setName(manifest.getMainAttributes().getValue(
282 Constants.BUNDLE_SYMBOLICNAME));
283
284 // Skip additional specs such as
285 // ; singleton:=true
286 if (nameVersion.getName().indexOf(';') > -1) {
287 nameVersion
288 .setName(new StringTokenizer(nameVersion.getName(), " ;")
289 .nextToken());
290 }
291
292 nameVersion.setVersion(manifest.getMainAttributes().getValue(
293 Constants.BUNDLE_VERSION));
294
295 return nameVersion;
296 }
297
298 /*
299 * DATA MODEL
300 */
301 /** The artifact described by this node */
302 public static Artifact asArtifact(Node node) throws RepositoryException {
303 if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
304 // FIXME update data model to store packaging at this level
305 String extension = "jar";
306 return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
307 .getString(),
308 node.getProperty(SLC_ARTIFACT_ID).getString(), extension,
309 node.getProperty(SLC_ARTIFACT_VERSION).getString());
310 } else if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
311 return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
312 .getString(),
313 node.getProperty(SLC_ARTIFACT_ID).getString(), node
314 .getProperty(SLC_ARTIFACT_CLASSIFIER).getString(),
315 node.getProperty(SLC_ARTIFACT_EXTENSION).getString(), node
316 .getProperty(SLC_ARTIFACT_VERSION).getString());
317 } else {
318 throw new SlcException("Unsupported node type for " + node);
319 }
320 }
321
322 /**
323 * The path to the PDE source related to this artifact (or artifact version
324 * base). There may or there may not be a node at this location (the
325 * returned path will typically be used to test whether PDE sources are
326 * attached to this artifact).
327 */
328 public static String relatedPdeSourcePath(String artifactBasePath,
329 Node artifactNode) throws RepositoryException {
330 Artifact artifact = asArtifact(artifactNode);
331 Artifact pdeSourceArtifact = new DefaultArtifact(artifact.getGroupId(),
332 artifact.getArtifactId() + ".source", artifact.getExtension(),
333 artifact.getVersion());
334 return MavenConventionsUtils.artifactPath(artifactBasePath,
335 pdeSourceArtifact);
336 }
337
338 /**
339 * Copy this bytes array as an artifact, relative to the root of the
340 * repository (typically the workspace root node)
341 */
342 public static Node copyBytesAsArtifact(Node artifactsBase,
343 Artifact artifact, byte[] bytes) throws RepositoryException {
344 String parentPath = MavenConventionsUtils.artifactParentPath(
345 artifactsBase.getPath(), artifact);
346 Node folderNode = JcrUtils.mkfolders(artifactsBase.getSession(),
347 parentPath);
348 return JcrUtils.copyBytesAsFile(folderNode,
349 MavenConventionsUtils.artifactFileName(artifact), bytes);
350 }
351
352 private RepoUtils() {
353 }
354
355 /** If a source return the base bundle name, does not change otherwise */
356 public static String extractBundleNameFromSourceName(String sourceBundleName) {
357 if (sourceBundleName.endsWith(".source"))
358 return sourceBundleName.substring(0, sourceBundleName.length()
359 - ".source".length());
360 else
361 return sourceBundleName;
362 }
363
364 /*
365 * SOFTWARE REPOSITORIES
366 */
367
368 /** Retrieve repository based on information in the repo node */
369 public static Repository getRepository(RepositoryFactory repositoryFactory,
370 Keyring keyring, Node repoNode) {
371 try {
372 Repository repository;
373 if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
374 String uri = repoNode.getProperty(ARGEO_URI).getString();
375 if (uri.startsWith("http")) {// http, https
376 repository = ArgeoJcrUtils.getRepositoryByUri(
377 repositoryFactory, uri);
378 } else if (uri.startsWith("vm:")) {// alias
379 repository = ArgeoJcrUtils.getRepositoryByUri(
380 repositoryFactory, uri);
381 } else {
382 throw new SlcException("Unsupported repository uri " + uri);
383 }
384 return repository;
385 } else {
386 throw new SlcException("Unsupported node type " + repoNode);
387 }
388 } catch (RepositoryException e) {
389 throw new SlcException("Cannot connect to repository " + repoNode,
390 e);
391 }
392 }
393
394 /**
395 * Reads credentials from node, using keyring if there is a password. Can
396 * return null if no credentials needed (local repo) at all, but returns
397 * {@link GuestCredentials} if user id is 'anonymous' .
398 */
399 public static Credentials getRepositoryCredentials(Keyring keyring,
400 Node repoNode) {
401 try {
402 if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
403 if (!repoNode.hasProperty(ARGEO_USER_ID))
404 return null;
405
406 String userId = repoNode.getProperty(ARGEO_USER_ID).getString();
407 if (userId.equals("anonymous"))// FIXME hardcoded userId
408 return new GuestCredentials();
409 char[] password = keyring.getAsChars(repoNode.getPath() + '/'
410 + ARGEO_PASSWORD);
411 Credentials credentials = new SimpleCredentials(userId,
412 password);
413 return credentials;
414 } else {
415 throw new SlcException("Unsupported node type " + repoNode);
416 }
417 } catch (RepositoryException e) {
418 throw new SlcException("Cannot connect to repository " + repoNode,
419 e);
420 }
421 }
422
423 /**
424 * Shortcut to retrieve a session given variable information: Handle the
425 * case where we only have an URI of the repository, that we want to connect
426 * as anonymous or the case of a identified connection to a local or remote
427 * repository.
428 *
429 * Callers must close the session once it has been used
430 */
431 public static Session getRemoteSession(RepositoryFactory repositoryFactory,
432 Keyring keyring, Node repoNode, String uri, String workspaceName) {
433 try {
434 if (repoNode == null && uri == null)
435 throw new SlcException(
436 "At least one of repoNode and uri must be defined");
437 Repository currRepo = null;
438 Credentials credentials = null;
439 // Anonymous URI only workspace
440 if (repoNode == null)
441 // Anonymous
442 currRepo = ArgeoJcrUtils.getRepositoryByUri(repositoryFactory,
443 uri);
444 else {
445 currRepo = RepoUtils.getRepository(repositoryFactory, keyring,
446 repoNode);
447 credentials = RepoUtils.getRepositoryCredentials(keyring,
448 repoNode);
449 }
450 return currRepo.login(credentials, workspaceName);
451 } catch (RepositoryException e) {
452 throw new SlcException("Cannot connect to workspace "
453 + workspaceName + " of repository " + repoNode
454 + " with URI " + uri, e);
455 }
456 }
457
458 /**
459 * Shortcut to retrieve a session on a remote Jrc Repository from
460 * information stored in a local argeo node or from an URI: Handle the case
461 * where we only have an URI of the repository, that we want to connect as
462 * anonymous or the case of a identified connection to a local or remote
463 * repository.
464 *
465 * Callers must close the session once it has been used
466 */
467 public static Session getRemoteSession(RepositoryFactory repositoryFactory,
468 Keyring keyring, Repository localRepository, String repoNodePath,
469 String uri, String workspaceName) {
470 Session localSession = null;
471 Node repoNode = null;
472 try {
473 localSession = localRepository.login();
474 if (repoNodePath != null && localSession.nodeExists(repoNodePath))
475 repoNode = localSession.getNode(repoNodePath);
476
477 return RepoUtils.getRemoteSession(repositoryFactory, keyring,
478 repoNode, uri, workspaceName);
479 } catch (RepositoryException e) {
480 throw new SlcException("Cannot log to workspace " + workspaceName
481 + " for repo defined in " + repoNodePath, e);
482 } finally {
483 JcrUtils.logoutQuietly(localSession);
484 }
485 }
486
487 /**
488 * Write group indexes: 'binaries' lists all bundles and their versions,
489 * 'sources' list their sources, and 'sdk' aggregates both.
490 */
491 public static void writeGroupIndexes(Session session,
492 String artifactBasePath, String groupId, String version,
493 Set<Artifact> binaries, Set<Artifact> sources) {
494 try {
495 Set<Artifact> indexes = new TreeSet<Artifact>(
496 new ArtifactIdComparator());
497 Artifact binariesArtifact = writeIndex(session, artifactBasePath,
498 groupId, RepoConstants.BINARIES_ARTIFACT_ID, version,
499 binaries);
500 indexes.add(binariesArtifact);
501 if (sources != null) {
502 Artifact sourcesArtifact = writeIndex(session,
503 artifactBasePath, groupId,
504 RepoConstants.SOURCES_ARTIFACT_ID, version, sources);
505 indexes.add(sourcesArtifact);
506 }
507 // sdk
508 writeIndex(session, artifactBasePath, groupId,
509 RepoConstants.SDK_ARTIFACT_ID, version, indexes);
510 session.save();
511 } catch (RepositoryException e) {
512 throw new SlcException("Cannot write indexes for group " + groupId,
513 e);
514 }
515 }
516
517 /** Write a group index. */
518 private static Artifact writeIndex(Session session,
519 String artifactBasePath, String groupId, String artifactId,
520 String version, Set<Artifact> artifacts) throws RepositoryException {
521 Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
522 version);
523 String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
524 artifacts, null);
525 Node node = RepoUtils.copyBytesAsArtifact(
526 session.getNode(artifactBasePath), artifact, pom.getBytes());
527 addMavenChecksums(node);
528 return artifact;
529 }
530
531 /** Add files containing the SHA-1 and MD5 checksums. */
532 public static void addMavenChecksums(Node node) throws RepositoryException {
533 // TODO optimize
534 String sha = JcrUtils.checksumFile(node, "SHA-1");
535 JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
536 sha.getBytes());
537 String md5 = JcrUtils.checksumFile(node, "MD5");
538 JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
539 md5.getBytes());
540 }
541
542 /**
543 * Custom copy since the one in commons does not fit the needs when copying
544 * a workspace completely.
545 */
546 public static void copy(Node fromNode, Node toNode) {
547 copy(fromNode, toNode, null);
548 }
549
550 public static void copy(Node fromNode, Node toNode, ArgeoMonitor monitor) {
551 try {
552 String fromPath = fromNode.getPath();
553 if (monitor != null)
554 monitor.subTask("copying node :" + fromPath);
555 if (log.isDebugEnabled())
556 log.debug("copy node :" + fromPath);
557
558 // FIXME : small hack to enable specific workspace copy
559 if (fromNode.isNodeType("rep:ACL")
560 || fromNode.isNodeType("rep:system")) {
561 if (log.isTraceEnabled())
562 log.trace("node " + fromNode + " skipped");
563 return;
564 }
565
566 // add mixins
567 for (NodeType mixinType : fromNode.getMixinNodeTypes()) {
568 toNode.addMixin(mixinType.getName());
569 }
570
571 // Double check
572 for (NodeType mixinType : toNode.getMixinNodeTypes()) {
573 if (log.isDebugEnabled())
574 log.debug(mixinType.getName());
575 }
576
577 // process properties
578 PropertyIterator pit = fromNode.getProperties();
579 properties: while (pit.hasNext()) {
580 Property fromProperty = pit.nextProperty();
581 String propName = fromProperty.getName();
582 try {
583 String propertyName = fromProperty.getName();
584 if (toNode.hasProperty(propertyName)
585 && toNode.getProperty(propertyName).getDefinition()
586 .isProtected())
587 continue properties;
588
589 if (fromProperty.getDefinition().isProtected())
590 continue properties;
591
592 if (propertyName.equals("jcr:created")
593 || propertyName.equals("jcr:createdBy")
594 || propertyName.equals("jcr:lastModified")
595 || propertyName.equals("jcr:lastModifiedBy"))
596 continue properties;
597
598 if (fromProperty.isMultiple()) {
599 toNode.setProperty(propertyName,
600 fromProperty.getValues());
601 } else {
602 toNode.setProperty(propertyName,
603 fromProperty.getValue());
604 }
605 } catch (RepositoryException e) {
606 throw new SlcException("Cannot property " + propName, e);
607 }
608 }
609
610 // recursively process children nodes
611 NodeIterator nit = fromNode.getNodes();
612 while (nit.hasNext()) {
613 Node fromChild = nit.nextNode();
614 Integer index = fromChild.getIndex();
615 String nodeRelPath = fromChild.getName() + "[" + index + "]";
616 Node toChild;
617 if (toNode.hasNode(nodeRelPath))
618 toChild = toNode.getNode(nodeRelPath);
619 else
620 toChild = toNode.addNode(fromChild.getName(), fromChild
621 .getPrimaryNodeType().getName());
622 copy(fromChild, toChild);
623 }
624
625 // update jcr:lastModified and jcr:lastModifiedBy in toNode in
626 // case
627 // they existed
628 if (!toNode.getDefinition().isProtected()
629 && toNode.isNodeType(NodeType.MIX_LAST_MODIFIED))
630 JcrUtils.updateLastModified(toNode);
631
632 // Workaround to reduce session size: artifact is a saveable
633 // unity
634 if (toNode.isNodeType(SlcTypes.SLC_ARTIFACT))
635 toNode.getSession().save();
636
637 if (monitor != null)
638 monitor.worked(1);
639
640 } catch (RepositoryException e) {
641 throw new SlcException("Cannot copy " + fromNode + " to " + toNode,
642 e);
643 }
644 }
645
646 }