use of com.serena.dmclient.api.Project 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);
}
use of com.serena.dmclient.api.Project 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;
}
use of com.serena.dmclient.api.Project 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;
}
use of com.serena.dmclient.api.Project 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);
}
}
use of com.serena.dmclient.api.Project in project Gargoyle by callakrsos.
the class DimList method list.
/********************************
* 작성일 : 2017. 4. 24. 작성자 : KYJ
*
* path에 속하는 하위 구성정보 조회
*
* @param path
* @param revision
* @param exceptionHandler
* @return
********************************/
public <T> List<T> list(String projSpec, String path, String fileName, String revision, Function<ItemRevision, T> convert, Consumer<Exception> exceptionHandler) {
List<T> collections = Collections.emptyList();
DimensionsConnection conn = null;
try {
conn = getConnection();
Project projObj = getProject(conn, projSpec);
RepositoryFolder findRepositoryFolderByPath = projObj.findRepositoryFolderByPath(path);
Filter filter = new Filter();
if (ValueUtil.isNotEmpty(fileName))
filter.criteria().add(new Filter.Criterion(SystemAttributes.ITEMFILE_FILENAME, fileName, Filter.Criterion.EQUALS));
if (ValueUtil.equals("-1", revision)) {
filter.criteria().add(new Filter.Criterion(SystemAttributes.IS_LATEST_REV, "Y", 0));
} else {
filter.criteria().add(new Filter.Criterion(SystemAttributes.REVISION, revision, Filter.Criterion.EQUALS));
}
List allChildFolders = findRepositoryFolderByPath.getAllChildFolders();
List<DimensionsRelatedObject> childItems = findRepositoryFolderByPath.getChildItems(filter);
// Stream.concat(allChildFolders, childItems);
List<ItemRevision> collect = childItems.stream().map(i -> (ItemRevision) i.getObject()).collect(Collectors.toList());
collections = collect.stream().map(convert).collect(Collectors.toList());
} catch (Exception e) {
exceptionHandler.accept(e);
} finally {
manager.close(conn);
}
return collections;
}
Aggregations