1   /*
2    * Copyright 2017 LINE Corporation
3    *
4    * LINE Corporation licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package com.linecorp.centraldogma.server.internal.mirror;
18  
19  import static java.util.Objects.requireNonNull;
20  
21  import java.io.File;
22  import java.net.URI;
23  
24  import javax.annotation.Nullable;
25  
26  import com.cronutils.model.Cron;
27  
28  import com.linecorp.centraldogma.server.command.CommandExecutor;
29  import com.linecorp.centraldogma.server.mirror.MirrorCredential;
30  import com.linecorp.centraldogma.server.mirror.MirrorDirection;
31  import com.linecorp.centraldogma.server.storage.repository.Repository;
32  
33  public final class CentralDogmaMirror extends AbstractMirror {
34  
35      private final String remoteProject;
36      private final String remoteRepo;
37  
38      public CentralDogmaMirror(Cron schedule, MirrorDirection direction, MirrorCredential credential,
39                                Repository localRepo, String localPath,
40                                URI remoteRepoUri, String remoteProject, String remoteRepo, String remotePath,
41                                @Nullable String gitignore) {
42          // Central Dogma has no notion of 'branch', so we just pass null as a placeholder.
43          super(schedule, direction, credential, localRepo, localPath, remoteRepoUri, remotePath, null,
44                gitignore);
45  
46          this.remoteProject = requireNonNull(remoteProject, "remoteProject");
47          this.remoteRepo = requireNonNull(remoteRepo, "remoteRepo");
48      }
49  
50      String remoteProject() {
51          return remoteProject;
52      }
53  
54      String remoteRepo() {
55          return remoteRepo;
56      }
57  
58      @Override
59      protected void mirrorLocalToRemote(File workDir, int maxNumFiles, long maxNumBytes) throws Exception {
60          throw new UnsupportedOperationException();
61      }
62  
63      @Override
64      protected void mirrorRemoteToLocal(File workDir, CommandExecutor executor,
65                                         int maxNumFiles, long maxNumBytes) throws Exception {
66          throw new UnsupportedOperationException();
67      }
68  }