}
protected Identifier createNewIdentifier(Versionable versionable, Folder folder, String existingId) throws DotDataException {
User systemUser = APILocator.getUserAPI().getSystemUser();
HostAPI hostAPI = APILocator.getHostAPI();
String uuid=existingId;
Identifier identifier = new Identifier();
Identifier parentId=APILocator.getIdentifierAPI().find(folder);
if(versionable instanceof Folder) {
identifier.setAssetType("folder");
identifier.setAssetName(((Folder) versionable).getName());
}
else {
String uri = versionable.getVersionType() + "." + versionable.getInode();
identifier.setId(uuid);
if(versionable instanceof Contentlet){
Contentlet cont = (Contentlet)versionable;
if(cont.getStructure().getStructureType()==Structure.STRUCTURE_TYPE_FILEASSET){
try {
uri = cont.getBinary(FileAssetAPI.BINARY_FIELD)!=null?cont.getBinary(FileAssetAPI.BINARY_FIELD).getName():"";
if(UtilMethods.isSet(cont.getStringProperty(FileAssetAPI.FILE_NAME_FIELD)))//DOTCMS-7093
uri = cont.getStringProperty(FileAssetAPI.FILE_NAME_FIELD);
} catch (IOException e) {
Logger.debug(this, e.getMessage() + " Issue happened while assigning Binary Field");
}
}
identifier.setAssetType("contentlet");
identifier.setParentPath(parentId.getPath());
identifier.setAssetName(uri);
} else if (versionable instanceof WebAsset) {
identifier.setURI(((WebAsset) versionable).getURI(folder));
identifier.setAssetType(versionable.getVersionType());
if(versionable instanceof Link)
identifier.setAssetName(versionable.getInode());
} else{
identifier.setURI(uri);
identifier.setAssetType(versionable.getVersionType());
}
identifier.setId(null);
}
Host host;
try {
host = hostAPI.findParentHost(folder, systemUser, false);
} catch (DotSecurityException e) {
throw new DotStateException("I can't find the parent host!");
}
if("folder".equals(identifier.getAssetType()) && APILocator.getHostAPI().findSystemHost().getIdentifier().equals(host.getIdentifier())){