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