adjustType(pkg, type);
XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
JaWETypes jts = JaWEManager.getInstance().getJaWEController().getJaWETypes();
boolean hasTemplate = jts.hasTemplateId(type);
if (hasTemplate) {
jts.fillFromTemplate(pkg, type);
}
String id = pkg.getId();
if (!hasTemplate || id.equals("") || xpdlhandler.getPackageById(id) != null) {
int i = 0;
while (id.equals("") || xpdlhandler.getPackageById(id) != null) {