ALERT! The community will be read-only on April 19, 8am Pacific as the migration begins. Read more for important details.
ALERT! The community will be read-only on April 19, 8am Pacific as the migration begins.Read more for important details.
Absent Member.
Absent Member.
1320 views

Disembodied File

Jump to solution

I want to fetch all related file of a ChangeRequest.

Using the bellow code:

private List<File> getRawFile(ChangeRequest cr) {
if (cr == null) return null;
Link[] links = cr.findLinks();
List<File> r = new ArrayList<File>();
int crNumber = cr.getNumber();
for (int i = 0; i < links.length; i++) {
Link l = links;
Endpoint end = l.getChildEndpoint();
ViewMember vm = l.resolveChild();
if (end.isPinned()) {
filterFile(vm, r);
} else {
filterFile(guessFile(vm, l, crNumber), r);
}
}

// TraceCollection tc = cr.getTraces(false);
// for (int i =0; i < tc.size(); i++) {
// Trace t = (Trace)tc.get(i);
// resolveURL(t.getSource(), r);
// resolveURL(t.getTarget(), r);
// }
ProcessItem pi = new ProcessItem(cr);
ViewMemberCollection vmc = pi.resolve();
vmc.getCache().populate();
for (int i = 0; i < vmc.size(); i++) {
filterFile((ViewMember)vmc.get(i), r);
}
return r;
}

But one file in List<File〉has been deleted, then restored. So  it throw a exception DisembodiedException when i use the File.getParentFolder() or File.getFullName() method. I can get history of this file through File.getHistory()  method.

I want to generate a key for this file. In past, i use getFullName which now doesn't work.

Disembodied file can also  be checked out, right?

In below code, input list may contained a brunch of  different version files of same file. The output list is new version file of each different file.

private List<File> mapNewVersion(List<File> list) {
if (list == null) return null;
List<File> r = new ArrayList<File>();
HashMap<String, Vector<File>> hash = new HashMap<String, Vector<File>>();
for (File f: list) {
System.out.println(f.getName() + " " + f.getFullName());
Vector<File> v = hash.get(f.getFullName());
if (v != null) {
v.add(f);
} else {
v = new Vector<File>();
v.add(f);
hash.put(f.getFullName(), v);
}
}
for (String filename: hash.keySet()) {
Vector<File> v = hash.get(filename);
File max = null;
for (File f: v) {
if (max != null) {
if (max.getDotNotation().compareTo(f.getDotNotation()) < 0) {
max = f;
}
} else {
max = f;
}
}
r.add(max);
}
return r;
}

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

correct, if a file is deleted, it will throw a disembodied item exception.

yes, you can get its history, but any call to getFullName() will fail, since it is disembodied, i.e. it does not know its parent folder context.

no i do not believe that you can check  out from a disembodied file. you should ignore it.

if (file.isDisembodied())

 continue;

if the file was restored subsequently, it would no longer be the same file throwing the disenbodied exception.i.e. the restored file and the original deleted file do not stem from the same root, they do not have the same share tree, and they definitely do not have the same item ID.

>>input list may contained a brunch of  different version files of same file. The output list is new version file of each different file

if the goal of this code is simply to idenitfy the highest revision of each file, then use

processItem.resolveEx() instead.

please note that you have no reason to walk the links using the first getLinks loop, then resolve the process item using processItem.resolve().

throw the top loop code away. processItem(c).resolve() is sufficient.

walking links & traces is fully subsumed into processitem.resolve() or .resolveEx()

i.e. the processitem resolution code automatically walks links &/or traces &/or changes as relevant, and returns the set of files attached.

View solution in original post

0 Likes
1 Reply
Micro Focus Expert
Micro Focus Expert

correct, if a file is deleted, it will throw a disembodied item exception.

yes, you can get its history, but any call to getFullName() will fail, since it is disembodied, i.e. it does not know its parent folder context.

no i do not believe that you can check  out from a disembodied file. you should ignore it.

if (file.isDisembodied())

 continue;

if the file was restored subsequently, it would no longer be the same file throwing the disenbodied exception.i.e. the restored file and the original deleted file do not stem from the same root, they do not have the same share tree, and they definitely do not have the same item ID.

>>input list may contained a brunch of  different version files of same file. The output list is new version file of each different file

if the goal of this code is simply to idenitfy the highest revision of each file, then use

processItem.resolveEx() instead.

please note that you have no reason to walk the links using the first getLinks loop, then resolve the process item using processItem.resolve().

throw the top loop code away. processItem(c).resolve() is sufficient.

walking links & traces is fully subsumed into processitem.resolve() or .resolveEx()

i.e. the processitem resolution code automatically walks links &/or traces &/or changes as relevant, and returns the set of files attached.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.