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