587
|
1 |
/*
|
628
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
587
|
17 |
|
|
18 |
package com.nokia.maven.scm.manager;
|
|
19 |
|
|
20 |
import java.io.File;
|
|
21 |
|
|
22 |
import org.apache.maven.scm.CommandParameters;
|
|
23 |
import org.apache.maven.scm.ScmException;
|
|
24 |
import org.apache.maven.scm.ScmFileSet;
|
628
|
25 |
import org.apache.maven.scm.log.ScmLogDispatcher;
|
|
26 |
import org.apache.maven.scm.log.ScmLogger;
|
587
|
27 |
import org.apache.maven.scm.manager.BasicScmManager;
|
|
28 |
import org.apache.maven.scm.repository.ScmRepository;
|
|
29 |
|
628
|
30 |
import com.nokia.maven.scm.command.info.InfoScmResult;
|
587
|
31 |
import com.nokia.maven.scm.command.pull.PullScmResult;
|
|
32 |
import com.nokia.maven.scm.command.tags.TagsScmResult;
|
|
33 |
import com.nokia.maven.scm.provider.ScmProviderExt;
|
|
34 |
|
|
35 |
/**
|
628
|
36 |
* Extended SCM manager which implements the additional functionalities defined by the
|
|
37 |
* ExtendedScmManager.
|
|
38 |
*
|
587
|
39 |
*/
|
628
|
40 |
public class BasicExtendedScmManager extends BasicScmManager implements ExtendedScmManager {
|
587
|
41 |
|
628
|
42 |
// Use dispatcher rather than DefaultLog.
|
|
43 |
private ScmLogDispatcher logDispatcher = new ScmLogDispatcher();
|
|
44 |
|
587
|
45 |
/**
|
|
46 |
* {@inheritDoc}
|
|
47 |
*/
|
|
48 |
@Override
|
628
|
49 |
public PullScmResult pull(ScmRepository repository, File path) throws ScmException {
|
587
|
50 |
try {
|
628
|
51 |
ScmProviderExt provider = (ScmProviderExt) this.getProviderByRepository(repository);
|
587
|
52 |
return provider.pull(repository, path);
|
628
|
53 |
}
|
|
54 |
catch (ClassCastException exc) {
|
587
|
55 |
throw new ScmException("The " + repository.getProvider().toString()
|
628
|
56 |
+ " does not support extended functionalities.");
|
587
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* {@inheritDoc}
|
|
62 |
*/
|
|
63 |
@Override
|
|
64 |
public TagsScmResult tags(ScmRepository repository, File path) throws ScmException {
|
|
65 |
try {
|
628
|
66 |
ScmProviderExt provider = (ScmProviderExt) this.getProviderByRepository(repository);
|
587
|
67 |
return provider.tags(repository, new ScmFileSet(path), new CommandParameters());
|
628
|
68 |
}
|
|
69 |
catch (ClassCastException exc) {
|
587
|
70 |
throw new ScmException("The " + repository.getProvider().toString()
|
628
|
71 |
+ " does not support extended functionalities.");
|
|
72 |
}
|
|
73 |
}
|
|
74 |
|
|
75 |
/**
|
|
76 |
* {@inheritDoc}
|
|
77 |
*/
|
|
78 |
@Override
|
|
79 |
public InfoScmResult info(ScmRepository repository, File path) throws ScmException {
|
|
80 |
try {
|
|
81 |
ScmProviderExt provider = (ScmProviderExt) this.getProviderByRepository(repository);
|
|
82 |
return provider.info(repository, new ScmFileSet(path), new CommandParameters());
|
|
83 |
}
|
|
84 |
catch (ClassCastException exc) {
|
|
85 |
throw new ScmException("The " + repository.getProvider().toString()
|
|
86 |
+ " does not support extended functionalities.");
|
587
|
87 |
}
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* {@inheritDoc}
|
|
92 |
*/
|
|
93 |
@Override
|
628
|
94 |
protected ScmLogger getScmLogger() {
|
|
95 |
return logDispatcher;
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Add a custom ScmLogger for message reporting.
|
|
100 |
* @param logger
|
|
101 |
*/
|
|
102 |
public void addListener(ScmLogger logger) {
|
|
103 |
logDispatcher.addListener(logger);
|
587
|
104 |
}
|
|
105 |
}
|