Search in sources :

Example 1 with DimensionsConnection

use of com.serena.dmclient.api.DimensionsConnection in project Gargoyle by callakrsos.

the class DimCat method copy.

/**
	 * 
	 * 파일을 복사후 로컬에 붙어넣기.
	 * 파일명에 리비전 번호를 붙여 읽는도중 다른 리비전 읽기 요청이 온 경우 대비할 수 있게한다.
	 * 
	 * 
	 * 2017.4.27
	 * 파일명에 리비전 번호를 붙임.
	 * 파일명에 리비전 번호를 붙여 읽는도중 다른 리비전 읽기 요청이 온 경우 대비할 수 있게한다.
	 * 
	 * 2017.4.13 kyj.
	 * 한가지 우려되는 부분은 
	 * 읽고 있는도중에 쓰거나 
	 * 쓰는도중에 읽는경우 어떻게 반응할것인가 하는문제.
	 * 
	 * 
	 * ps 디멘전 코드는 까볼수없으니 참..
	 * 
	 * 
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 14.
	 * @param prjSpec
	 * @param fullPathName
	 * @param revision
	 * @param encoding
	 * @param exceptionHandler
	 * @return
	 * @throws Exception 
	 */
public File copy(String prjSpec, String fullPathName, String revision, String encoding) {
    List<String> linkedList = new LinkedList<String>();
    for (String pathItem : fullPathName.split("/")) {
        if (pathItem != null && !pathItem.isEmpty()) {
            linkedList.add(pathItem);
        }
    }
    //저장 디렉토리 위치
    File root = tmpDir();
    DimensionsConnection conn = null;
    try {
        conn = getConnection();
        Project project = getProject(conn, prjSpec);
        RepositoryFolder rootFolder = project.getRootFolder();
        //searchFindOne(rootFolder, linkedList, revision);
        ItemRevision ir = manager.searchFindOne(rootFolder, linkedList, revision);
        if (ir == null)
            return null;
        //반드시 호출.
        ir.queryAttribute(new int[] { SystemAttributes.ITEMFILE_FILENAME, SystemAttributes.ITEMFILE_DIR, SystemAttributes.LAST_UPDATED_DATE, SystemAttributes.UTC_MODIFIED_DATE, SystemAttributes.REVISION });
        String pathName = ir.getAttribute(SystemAttributes.ITEMFILE_DIR).toString();
        String name = ir.getAttribute(SystemAttributes.ITEMFILE_FILENAME).toString();
        String itemRevision = ir.getAttribute(SystemAttributes.REVISION).toString();
        if (!root.exists()) {
            try {
                FileUtil.mkDirs(root);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        Path path = Paths.get(root.getAbsolutePath(), pathName, name.concat("_").concat(itemRevision));
        //			File tmp = new File(root.getAbsolutePath(), name.concat("_").concat(newRevision));
        //new File(tmp, pathName)  //root.getAbsolutePath() + "/";
        String saveFilePathName = path.toString();
        /* 
			 * java.lang.String destinationFileName, 
			 * boolean expandSubstitutionVariables, 
			 * boolean overwriteWritableFiles, 
			 * boolean applySystemTime
			 * 
			 * 첫번째 String : 저장할 파일명  
			 * 두번째 boolean : ? 치환변수?           ->
			 * 세번째 boolean : 덮어씌울지 여부        -> false - 이미존재하면 덮어쓰지않음
			 * 네번째 boolean : 시스템 타임 적용여부 -> false - 원본파일의 날짜 유지 
			 * */
        DimensionsResult copy = ir.getCopy(saveFilePathName, true, false, false);
        //			DimensionsResult copy = ir.getCopyToFolder(saveFilePathName, true, true, false);
        LOGGER.debug("Dimension DOWLNLOAD  START ############################");
        LOGGER.debug("Dimension DOWLNLOAD  File Name :  " + name);
        LOGGER.debug("Dimension DOWLNLOAD  MESSAGE    :  " + copy.getMessage());
        LOGGER.debug("Dimension DOWLNLOAD  ItemRevisionInfo :  " + ir);
        LOGGER.debug("Dimension DOWLNLOAD  END ############################");
    } finally {
        if (conn != null)
            conn.close();
    }
    return new File(root, fullPathName);
}
Also used : Path(java.nio.file.Path) Project(com.serena.dmclient.api.Project) DimensionsResult(com.serena.dmclient.api.DimensionsResult) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) ItemRevision(com.serena.dmclient.api.ItemRevision) IOException(java.io.IOException) File(java.io.File) LinkedList(java.util.LinkedList)

Example 2 with DimensionsConnection

use of com.serena.dmclient.api.DimensionsConnection in project Gargoyle by callakrsos.

the class DimList method list.

/* 
	 * @inheritDoc
	 * 디렉토리를 제외한 모든 파일 정보를 리턴.
	 */
public List<String> list(String projSpec, String path) {
    List<String> collections = Collections.emptyList();
    try {
        DimensionsConnection conn = getConnection();
        Project projObj = getProject(conn, projSpec);
        RepositoryFolder folder = projObj.findRepositoryFolderByPath(path);
        collections = toString(Arrays.asList(folder), DEFAULT_ITEMREVISION_TOSTRING);
    } catch (Exception e) {
        DEFAULT_LOGGER.accept(e);
    }
    return collections;
}
Also used : Project(com.serena.dmclient.api.Project) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection)

Example 3 with DimensionsConnection

use of com.serena.dmclient.api.DimensionsConnection in project Gargoyle by callakrsos.

the class DimResource method getLatestRevision.

/**
	 * 저장소에 저장된 최신 리비젼 리턴.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 14.
	 * @return
	 * @throws SVNException
	 */
public long getLatestRevision(String projSpec) {
    DimensionsConnection connection = null;
    long latestRevision = -1;
    try {
        connection = getConnection();
        latestRevision = getLatestRevision(connection, projSpec);
    } finally {
        close(connection);
    }
    return latestRevision;
}
Also used : DimensionsConnection(com.serena.dmclient.api.DimensionsConnection)

Example 4 with DimensionsConnection

use of com.serena.dmclient.api.DimensionsConnection in project Gargoyle by callakrsos.

the class DimResource method isExists.

/**
	 * 리소스 존재여부 체크
	 * @작성자 : KYJ
	 * @작성일 : 2017. 4. 14. 
	 * @param relativePath
	 * @return
	 */
public boolean isExists(String relativePath) {
    List<String> linkedList = new LinkedList<String>();
    for (String pathItem : relativePath.split("/")) {
        if (pathItem != null && !pathItem.isEmpty()) {
            linkedList.add(pathItem);
        }
    }
    DimensionsConnection connection = null;
    boolean search = false;
    try {
        connection = getConnection();
        Project project = connection.getObjectFactory().getProject(getProjSpec());
        RepositoryFolder rootFolder = project.getRootFolder();
        search = search(rootFolder, linkedList, "-1", items -> {
            return items.isEmpty();
        });
    } finally {
        close(connection);
    }
    return search;
}
Also used : Properties(java.util.Properties) SVNException(org.tmatesoft.svn.core.SVNException) Date(java.util.Date) SystemUtils(org.apache.commons.lang3.SystemUtils) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) File(java.io.File) Project(com.serena.dmclient.api.Project) List(java.util.List) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) ItemRevision(com.serena.dmclient.api.ItemRevision) Optional(java.util.Optional) LinkedList(java.util.LinkedList) SystemAttributes(com.serena.dmclient.api.SystemAttributes) Filter(com.serena.dmclient.api.Filter) Project(com.serena.dmclient.api.Project) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) LinkedList(java.util.LinkedList)

Example 5 with DimensionsConnection

use of com.serena.dmclient.api.DimensionsConnection in project Gargoyle by callakrsos.

the class DimList method listEntry.

/********************************
	 * 작성일 : 2016. 5. 9. 작성자 : KYJ
	 *
	 * 디멘전 트리 순회
	 *
	 * 2016-11-03 버그 수정
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public void listEntry(String projSpec, String path, DimDirHandler handler) throws Exception {
    DimensionsConnection conn = null;
    try {
        conn = getConnection();
        DimensionsObjectFactory objectFactory = conn.getObjectFactory();
        Project project = objectFactory.getProject(projSpec);
        RepositoryFolder rootFoler = project.findRepositoryFolderByPath(path);
        listEntry(rootFoler, handler);
    } finally {
        manager.close(conn);
    }
}
Also used : Project(com.serena.dmclient.api.Project) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) DimensionsObjectFactory(com.serena.dmclient.api.DimensionsObjectFactory)

Aggregations

DimensionsConnection (com.serena.dmclient.api.DimensionsConnection)6 Project (com.serena.dmclient.api.Project)5 RepositoryFolder (com.serena.dmclient.api.RepositoryFolder)5 ItemRevision (com.serena.dmclient.api.ItemRevision)3 DimensionsObjectFactory (com.serena.dmclient.api.DimensionsObjectFactory)2 DimensionsRelatedObject (com.serena.dmclient.api.DimensionsRelatedObject)2 Filter (com.serena.dmclient.api.Filter)2 SystemAttributes (com.serena.dmclient.api.SystemAttributes)2 File (java.io.File)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Properties (java.util.Properties)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 IListCommand (com.kyj.scm.manager.core.commons.IListCommand)1 ScmDirHandler (com.kyj.scm.manager.core.commons.ScmDirHandler)1 DimensionsResult (com.serena.dmclient.api.DimensionsResult)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1