use of com.emc.storageos.model.file.FileShareRestRep in project coprhd-controller by CoprHD.
the class FileMapper method map.
public static FileShareRestRep map(FileShare from) {
if (from == null) {
return null;
}
FileShareRestRep to = new FileShareRestRep();
mapFileObjectFields(from, to);
if (from.getProject() != null) {
to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
}
if (from.getTenant() != null) {
to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant().getURI()));
}
to.setCapacity(CapacityUtils.convertBytesToGBInStr(from.getCapacity()));
to.setUsedCapacity(CapacityUtils.convertBytesToGBInStr(from.getUsedCapacity()));
to.setSoftLimit(from.getSoftLimit());
to.setSoftGrace(from.getSoftGracePeriod());
to.setNotificationLimit(from.getNotificationLimit());
to.setSoftLimitExceeded(from.getSoftLimitExceeded());
to.setVirtualPool(toRelatedResource(ResourceTypeEnum.FILE_VPOOL, from.getVirtualPool()));
to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, from.getVirtualArray()));
to.setProtocols(from.getProtocol());
to.setNativeId(from.getNativeId());
to.setDataProtection(from.getDataProtection());
to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageDevice()));
to.setPool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getPool(), from.getStorageDevice()));
to.setStoragePort(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, from.getStoragePort(), from.getStorageDevice()));
to.setVirtualNAS(toRelatedResource(ResourceTypeEnum.VIRTUAL_NAS, from.getVirtualNAS()));
to.setThinlyProvisioned(from.getThinlyProvisioned());
// Set file replication attributes!!
FileProtectionRestRep replication = new FileProtectionRestRep();
if (from.getPersonality() != null) {
replication.setPersonality(from.getPersonality());
if (PersonalityTypes.SOURCE.name().equalsIgnoreCase(from.getPersonality())) {
if ((from.getMirrorfsTargets() != null) && (!from.getMirrorfsTargets().isEmpty())) {
List<VirtualArrayRelatedResourceRep> mirrorTargets = new ArrayList<VirtualArrayRelatedResourceRep>();
for (String target : from.getMirrorfsTargets()) {
mirrorTargets.add(toTargetFileSystemRelatedResource(ResourceTypeEnum.FILE, URI.create(target), null));
}
replication.setTargetFileSystems(mirrorTargets);
}
} else if (PersonalityTypes.TARGET.name().equalsIgnoreCase(from.getPersonality())) {
replication.setParentFileSystem(toRelatedResource(ResourceTypeEnum.FILE, from.getParentFileShare().getURI()));
}
}
if (from.getMirrorStatus() != null) {
replication.setMirrorStatus(from.getMirrorStatus());
}
if (from.getAccessState() != null) {
replication.setAccessState(from.getAccessState());
}
to.setProtection(replication);
to.setFilePolicies(from.getFilePolicies());
return to;
}
Aggregations