use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.
the class ImportServerObjectWizard method handlePictureResourceObject.
/**
* DOC hbhong Comment method "handlePictureResourceObject".
*
* @param treeObj
* @throws IOException
*/
private WSResourceE handlePictureResourceObject(TreeObject treeObj) throws IOException {
if (treeObj != null) {
if (treeObj instanceof TreeParent) {
return null;
}
String[] fileInfo = getPicResourceFileInfo(treeObj.getName());
if (fileInfo != null) {
String dirName = fileInfo[0];
String fileQName = fileInfo[1];
String fileExtension = fileInfo[2];
String fileName = fileInfo[3];
// encode the dirName and fileName
String encodedDirName = URLEncoder.encode(dirName, UTF8);
fileQName = URLEncoder.encode(fileQName, UTF8);
WSResourceE resource = MdmserverobjectFactory.eINSTANCE.createWSResourceE();
resource.setName(fileName);
resource.setFileExtension(fileExtension);
StringBuffer strBuf = new StringBuffer();
strBuf.append(serverDef.getProtocol()).append(serverDef.getHost()).append(":").append(// $NON-NLS-1$
serverDef.getPort()).append(Util.getContextPath(serverDef.getPath())).append("/services/imageserver/upload/").append(encodedDirName).append("/").append(fileQName).append(".").append(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
fileExtension);
String url = strBuf.toString();
byte[] bytes = HttpClientUtil.downloadFile(url, serverDef.getUser(), serverDef.getPasswd());
resource.setFileContent(bytes);
// add imageCatalog
resource.setImageCatalog(dirName);
treeObj.setName(fileName);
return resource;
}
}
return null;
}
use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.
the class AbstractNodeCheckTreeViewer method isExist.
private boolean isExist(TreeObject treeObj) {
if (treeObj instanceof TreeParent) {
return false;
}
int type = treeObj.getType();
ERepositoryObjectType rType = RepositoryQueryService.getRepositoryObjectType(type);
if (rType == null) {
return false;
}
List<IRepositoryViewObject> children = RepositoryResourceUtil.findAllViewObjectsWithDeleted(rType);
if (children == null) {
return false;
}
String treeObjName = treeObj.getName();
if (type == TreeObject.PICTURES_RESOURCE) {
// $NON-NLS-1$
int index = treeObjName.indexOf("-");
if (index > 0) {
treeObjName = treeObjName.substring(index + 1);
}
}
for (IRepositoryViewObject viewObject : children) {
Item item = viewObject.getProperty().getItem();
if (item instanceof MDMServerObjectItem) {
MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
String name = serverObj.getName();
if (type == TreeObject.WORKFLOW_PROCESS) {
// $NON-NLS-1$
name = name + "_" + viewObject.getVersion();
}
if (type == TreeObject.PICTURES_RESOURCE) {
// $NON-NLS-1$ //$NON-NLS-2$
name = name + "_" + viewObject.getVersion() + "." + ((WSResourceE) serverObj).getFileExtension();
}
if (serverObj != null && treeObjName.equals(name)) {
return true;
}
}
}
return false;
}
use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.
the class RepositoryWebServiceAdapter method resetXObject.
public static void resetXObject(MDMServerDef serverDef, TreeObject xobject) {
String serverName = serverDef.getHost();
String username = serverDef.getUser();
String password = serverDef.getPasswd();
String endpointaddress = // $NON-NLS-1$
serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
(password == null ? "" : password));
UserInfo user = new UserInfo();
user.setUsername(username);
user.setPassword(password);
user.setServerUrl(endpointaddress);
serverRoot.setUser(user);
xobject.setServerRoot(serverRoot);
}
Aggregations