Book Printing URL Configuration
You may encounter issues with the book printing feature if you have external and internal URLs in your environment. There is a configuration property that can be set in this situation.
• Property: com.ptc.sc.sce.util.SCEBulkPrintUtility.remotePrintServiceExtUrl
• Example: $(wt.webserver.protocol)://<server external hostname>:server external http port>/PrintMS/rest/PrintService
|
This property should be modified only when the server has an external address different than its internal one.
|
Configuring Download URL for bookPrint functionality in a Cluster Environment
To configure the download URL for bookPrint functionality in a cluster environment, perform these steps:
|
These steps are required only when the Viewers configured in a cluster environment are not accessible from an outside domain to the Servigistics InService users and they can access the Servigistics InService delivery site only through the load balancer URL.
|
1. Extend the default com.ptc.sc.sce.services.SCEBulkPrintService and override the following methods:
◦ getBulkPrintsStatus
◦ printBulk
These two methods are responsible for building the URL that is used by the client containing the download URL for the bookPrint functionality.
2. Add a new property entry in the site.xconf:
<Property name="com.custom.sc.sce.util.CustomSCEBulkPrintUtility.
webAliasPrintServiceUrl"
default="<load balance protocol>://<load balancer host name>:< load balancer
port>/PrintMS/rest/PrintService"
overridable="true"/>
3. Create the following custom JAVA classes:
◦ CustomSCEBulkPrintService.java
package com.custom.sc.sce.services;
import java.util.List;
import javax.ws.rs.core.MultivaluedMap;
import com.custom.sc.sce.util.CustomSCEBulkPrintUtility;
import com.ptc.sc.conceptualmodel.SCItem;
import com.ptc.sc.conceptualmodel.SCList;
import com.ptc.sc.sce.services.SCEBulkPrintService;
import com.ptc.sc.servicecommon.BulkPrintService;
public class CustomSCEBulkPrintService extends SCEBulkPrintService {
private static final long serialVersionUID = 1L;
/**
* Create a new instance of the
<code>CustomSCEBulkPrintService</code>.
* This factory method is required in order for the method server
process to start successfully.
*/
public static CustomSCEBulkPrintService newCustomSCEBulkPrintService() {
CustomSCEBulkPrintService bulkPrintService = new CustomSCEBulkPrintService();
return bulkPrintService;
}
@Override
public SCList getBulkPrintsStatus(List<String> statusList) throws Exception {
SCList bulkPrintsStatus = super.getBulkPrintsStatus(statusList);
List<SCItem> bulkPrintStatusItems = bulkPrintsStatus.getItems();
for(SCItem bulkPrintStatusItem : bulkPrintStatusItems) {
if(bulkPrintStatusItem.containsAttribute(BulkPrintService.BULK_PRINT_URL)) {
bulkPrintStatusItem.removeAttribute(BulkPrintService.BULK_PRINT_URL);
String printJobId = bulkPrintStatusItem.getAttribute(BulkPrintService.BULK_PRINT_JOB_ID);
bulkPrintStatusItem.addAttribute(BulkPrintService.BULK_PRINT_URL,
getWebAliasPrintJobUrl(printJobId));
}
}
return bulkPrintsStatus;
}
public SCItem printBulk(String bulkPrintId, MultivaluedMap<String, String> headersMap) throws
Exception {
SCItem printBulkItem = super.printBulk(bulkPrintId, headersMap);
if(printBulkItem.containsAttribute(BulkPrintService.BULK_PRINT_URL)) {
String printJobId = printBulkItem.getAttribute(BulkPrintService.BULK_PRINT_JOB_ID);
printBulkItem.removeAttribute(BulkPrintService.BULK_PRINT_URL);
printBulkItem.addAttribute(BulkPrintService.BULK_PRINT_URL,
getWebAliasPrintJobUrl(printJobId));
return printBulkItem;
} }
private String getWebAliasPrintJobUrl(String printJobId) {
String url = CustomSCEBulkPrintUtility.getWebAliasPrintServerUrl() + "/pdf?id=" + printJobId;
return url;
}
}
◦ CustomSCEBulkPrintUtility.java
package com.custom.sc.sce.util;
import wt.util.WTProperties;
public class CustomSCEBulkPrintUtility {
private static final String WEB_ALIAS_PRINT_SERVICE_URL;
static {
try {
WEB_ALIAS_PRINT_SERVICE_URL =
WTProperties.getLocalProperties().
getProperty(CustomSCEBulkPrintUtility.class.getName() +
".webAliasPrintServiceUrl", "http://localhost:8080/webrest/rest/PrintService");
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
public static String getWebAliasPrintServerUrl() {
return WEB_ALIAS_PRINT_SERVICE_URL;
}
}
4. To compile these JAVA classes, perform the following steps:
a. Create a new custom folder in the <WT_HOME>/codebase.war/ directory.
b. Create the package structure for com.custom.sc.sce.services and com.custom.sc.sce.util.
c. Place the CustomSCEBulkPrintService.java file in package com.custom.sc.sce.services.
d. Place the CustomSCEBulkPrintUtility.java file in package com.custom.sc.sce.util.
e. Open a command prompt and go to <WT_HOME>/bin directory.
f. Run Windchill shell. This will open a Windchill shell required for compiling JAVA files.
g. Change directory to <WT_HOME>.
h. Run the javac codebase.war/custom/com/custom/sc/sce/services/CustomSCEBulkPrintService.java command.
i. Run the javac codebase.war/custom/com/custom/sc/sce/util/CustomSCEBulkPrintUtility.java command.
j. Create a similar package structure as com/custom/sc/sce/services/ and com/custom/sc/sce/util/ inside the <WT_HOME>/codebase.war/WEB-INF/classes/ folder.
k. Place the compiled JAVA classes in the respective locations.
l. Add the following entry in the site.xconf file:
<Property name="wt.services.service.24440"
targetFile="codebase.war/sc.properties"
default="com.ptc.sc.servicecommon.BulkPrintService
/com.custom.ptc.sc.sce.services.CustomSCEBulkPrintService"
overridable="true"
/>
m. Run xconfmanager -pF from Windchill shell.
n. Restart Servigistics InService.