Hi,
We have written a utility to fetch the URL Drawing of a part created in Creo.
Code Snippet :
final QueryResult qr = PersistenceHelper.manager.find((StatementSpec)qs);
while (qr.hasMoreElements()) {
EPMDocument epmm = (EPMDocument) qr.nextElement();
if ( (epmm.getNumber().endsWith(".drw")) || (epmm.getNumber().endsWith(".DRW")) && (internalUrl != null) && (internalUrl.length() > 0) )
{
Representation defaultRep = RepresentationHelper.service
.getDefaultRepresentation(epmm);
ContentHolder holder;
try {
holder = ContentHelper.service.getContents(defaultRep);
Vector contents = ContentHelper
.getContentListAll(holder);
ApplicationData data = null;
WTProperties propName = WTProperties.getLocalProperties();
String protocol= propName
.getProperty("wt.webserver.protocol");
String rmiHost = propName
.getProperty("wt.rmi.server.hostname");
String portUsed = propName.getProperty("wt.webserver.port");
for (int i = 0; i < contents.size() ; i++) {
if (contents.get(i) instanceof ApplicationData) {
data = (ApplicationData) contents.get(i);
URL aURL = WVSContentHelper.getDownloadURL(
data, holder);
String cURL = null;
String result = null;
if ( aURL.toString().contains("pvs") ){
cURL= aURL.toString();
result = cURL.substring(cURL.indexOf("ContentHolder=")+14, cURL.indexOf("&u8=1"));
String rmiHostName = "&objref=OR%3A";
internalUrl = internalUrl
.substring(
internalUrl.indexOf("createCDialogWindow('") +21,
internalUrl
.indexOf("http:"));
finalURL = protocol + "://" + rmiHost + ":" + portUsed +internalUrl + cURL + rmiHostName + result;
;
break;
It was working fine, but recently we found a limitation. If we revise the Drawing from Windchill and then re run the utility, It shows a Java Array size error.
wt.method.MethodContextMonitor.contexts.rmi wcadmin - 2016-06-13 14:19:41.555 +0530, 2vtvcx;ipds3u2q;6884;36sq4k;1, -, -, -, wcadmin, 10.101.11.1, ext.havells.utilities.Eight, prepareDataForExcel, , 0, 571, 0.255354489, 2, 0.002308162, 0.5148033, 0.787921406
java.lang.StringIndexOutOfBoundsException: String index out of range: -21
at java.lang.String.substring(String.java:1911)
at ext.havells.utilities.Eight.getDrawingLink(Eight.java:504)
at ext.havells.utilities.Eight.writeIntoExcel(Eight.java:283)
at ext.havells.utilities.Eight.prepareDataForExcel(Eight.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
and so on.
On my investigation, i think that it is because of these multi revisions of drawing, it is failing.I tried using some APIs could not solve this .
Request you to help me solve this.