Search in sources :

Example 1 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder 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 RepositoryFolder

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

the class DimDirHandler method accept.

/**
	 * parent폴더 기준,
	 * filter처리된 아이템 대상으로 하위 아이템들을 순회하는 코드
	 */
@Override
public void accept(RepositoryFolder parent) {
    Filter itemFilter = itemFilter();
    List<DimensionsRelatedObject> childItems = parent.getChildItems(/*필터 적용*/
    itemFilter);
    childItems.stream().map(f -> (ItemRevision) f.getObject()).forEach(r -> handle(r));
}
Also used : List(java.util.List) ScmDirHandler(com.kyj.scm.manager.core.commons.ScmDirHandler) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) ItemRevision(com.serena.dmclient.api.ItemRevision) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) Filter(com.serena.dmclient.api.Filter) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) Filter(com.serena.dmclient.api.Filter) ItemRevision(com.serena.dmclient.api.ItemRevision)

Example 3 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder 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 4 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder 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 RepositoryFolder

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

the class DimmensionManager method getRevision.

/**
	 * 날짜에 매치되는 리비젼 번호를 구함.
	 *
	 * 값이 없거나 유효하지않는경우 -1
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 14.
	 * @param date
	 * @return
	 * @throws Exception
	 */
public float getRevision(String projSpec, String path, String fileName) throws Exception {
    DimDirHandler handler = new DimDirHandler() {

        Object findOne;

        @Override
        public boolean test(RepositoryFolder entry) {
            return entry.getName().equals(path);
        }

        @Override
        public Filter itemFilter() {
            Filter filter = new Filter();
            filter.criteria().add(new Filter.Criterion(SystemAttributes.IS_LATEST_REV, "Y", 0));
            filter.criteria().add(new Filter.Criterion(SystemAttributes.ITEMFILE_FILENAME, fileName, Filter.Criterion.EQUALS));
            return filter;
        }

        @Override
        public void handle(ItemRevision r) {
            r.queryAttribute(SystemAttributes.REVISION);
            findOne = r.getAttribute(SystemAttributes.REVISION);
        }

        @Override
        public Object get() {
            return findOne;
        }
    };
    this.listEntry(projSpec, path, handler);
    Object object = handler.get();
    if (object != null)
        return Float.parseFloat(object.toString());
    return -1;
}
Also used : RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) Filter(com.serena.dmclient.api.Filter) ItemRevision(com.serena.dmclient.api.ItemRevision)

Aggregations

RepositoryFolder (com.serena.dmclient.api.RepositoryFolder)9 DimensionsConnection (com.serena.dmclient.api.DimensionsConnection)5 DimensionsRelatedObject (com.serena.dmclient.api.DimensionsRelatedObject)5 Filter (com.serena.dmclient.api.Filter)5 ItemRevision (com.serena.dmclient.api.ItemRevision)5 Project (com.serena.dmclient.api.Project)5 List (java.util.List)3 ScmDirHandler (com.kyj.scm.manager.core.commons.ScmDirHandler)2 DimensionsObjectFactory (com.serena.dmclient.api.DimensionsObjectFactory)2 SystemAttributes (com.serena.dmclient.api.SystemAttributes)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)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 DimensionsResult (com.serena.dmclient.api.DimensionsResult)1 IOException (java.io.IOException)1