1 package org.apache.maven.scm.provider.synergy.consumer;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.scm.log.ScmLogger;
23 import org.codehaus.plexus.util.cli.StreamConsumer;
24
25 import java.io.File;
26
27 /**
28 * Parse output of
29 * <p/>
30 * <pre>
31 * ccm wa -show -p <project_spec>
32 * </pre>
33 *
34 * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
35 *
36 */
37 public class SynergyWorkareaConsumer
38 implements StreamConsumer
39 {
40 private ScmLogger logger;
41
42 private File workarea;
43
44 public SynergyWorkareaConsumer( ScmLogger logger )
45 {
46 this.logger = logger;
47 }
48
49 /**
50 * We are expecting the following output:
51 * <p/>
52 * <pre>
53 * Project Maintain Copies Relative Time Translate Modify Path
54 * -------------------------------------------------------------------
55 * BGZBFZH˜1 TRUE TRUE FALSE FALSE TRUE FALSE 'D:\cmsynergy\ccm_wa\LAPOSTE\BGZBFZH˜1'
56 * </pre>
57 * <p/>
58 * And we want to extract:
59 * <p/>
60 * <pre>
61 * D:\cmsynergy\ccm_wa\LAPOSTE\BGZBFZH˜1
62 * <pre>
63 *
64 * {@inheritDoc}
65 */
66 public void consumeLine( String line )
67 {
68 if ( logger.isDebugEnabled() )
69 {
70 logger.debug( line );
71 }
72 if ( line.indexOf( " '" ) > -1 )
73 {
74 int beginIndex = line.indexOf( " '" );
75 String fileName = line.substring( beginIndex + 2, line.indexOf( "'", beginIndex + 2 ) );
76 workarea = new File( fileName );
77 }
78 }
79
80 public File getWorkAreaPath()
81 {
82 return workarea;
83 }
84 }