001/* 002 * ModeShape (http://www.modeshape.org) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.modeshape.connector.git; 017 018import org.eclipse.jgit.api.Git; 019import org.eclipse.jgit.lib.Repository; 020import org.modeshape.schematic.document.Document; 021import org.modeshape.jcr.spi.federation.DocumentWriter; 022 023/** 024 * 025 */ 026public class GitRoot extends GitFunction { 027 028 protected static final String ID = CallSpecification.DELIMITER_STR; 029 protected static final String NAME = ""; 030 031 private final Document root; 032 033 public GitRoot( GitConnector connector ) { 034 super(NAME, connector); 035 DocumentWriter writer = connector.newDocumentWriter(ID); 036 writer.setPrimaryType(GitLexicon.ROOT); 037 writer.addChild(GitBranches.ID, GitBranches.NAME); 038 writer.addChild(GitTags.ID, GitTags.NAME); 039 writer.addChild(GitHistory.ID, GitHistory.NAME); 040 writer.addChild(GitCommitDetails.ID, GitCommitDetails.NAME); 041 writer.addChild(GitTree.ID, GitTree.NAME); 042 root = writer.document(); 043 } 044 045 @Override 046 public Document execute( Repository repository, 047 Git git, 048 CallSpecification spec, 049 DocumentWriter writer, 050 Values values ) { 051 return root.clone(); // return a copy 052 } 053}