use of com.sun.pkg.client.Manifest in project Payara by payara.
the class UpdateCenterHandlers method getUcList.
@Handler(id = "getUcList", input = { @HandlerInput(name = "state", type = String.class, required = true) }, output = { @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getUcList(HandlerContext handlerCtx) {
List result = new ArrayList();
if (Boolean.TRUE.equals(GuiUtil.getSessionValue("_noNetwork"))) {
handlerCtx.setOutputValue("result", result);
return;
}
try {
Image img = getUpdateCenterImage();
if (img == null) {
handlerCtx.setOutputValue("result", result);
return;
}
String state = (String) handlerCtx.getInputValue("state");
if (state.equals("update")) {
handlerCtx.setOutputValue("result", getUpdateDisplayList(img, false));
return;
}
List<Fmri> displayList = null;
if (state.equals("installed"))
displayList = getInstalledList(img);
else if (state.equals("addOn"))
displayList = getAddOnList(img);
if (displayList != null) {
for (Fmri fmri : displayList) {
Map oneRow = new HashMap();
try {
Manifest manifest = img.getManifest(fmri);
oneRow.put("selected", false);
oneRow.put("fmri", fmri);
oneRow.put("fmriStr", fmri.toString());
putInfo(oneRow, "pkgName", fmri.getName());
putInfo(oneRow, "version", getPkgVersion(fmri.getVersion()));
putInfo(oneRow, "newVersion", "");
putInfo(oneRow, "category", getCategory(manifest));
putInfo(oneRow, "pkgSize", getPkgSize(manifest));
oneRow.put("size", Integer.valueOf(manifest.getPackageSize()));
putInfo(oneRow, "auth", fmri.getAuthority());
String tooltip = manifest.getAttribute(PKG_SUMMARY);
if (GuiUtil.isEmpty(tooltip))
tooltip = manifest.getAttribute(DESC);
putInfo(oneRow, "tooltip", tooltip);
result.add(oneRow);
} catch (Exception ex) {
GuiUtil.getLogger().info("getUcList(): " + ex.getLocalizedMessage());
if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
ex.printStackTrace();
}
}
}
}
} catch (Exception ex1) {
GuiUtil.getLogger().info("getUcList(): " + ex1.getLocalizedMessage());
if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
ex1.printStackTrace();
}
}
handlerCtx.setOutputValue("result", result);
}
use of com.sun.pkg.client.Manifest in project Payara by payara.
the class UpdateCenterHandlers method getLicense.
private static String getLicense(Image img, Fmri fmri) {
StringBuffer licenseText = new StringBuffer();
try {
Manifest manifest = img.getManifest(fmri);
List<LicenseAction> lla = manifest.getActionsByType(LicenseAction.class);
for (LicenseAction la : lla) {
licenseText.append("============= ").append(la.getName()).append(" ================\n");
licenseText.append(fmri.toString());
licenseText.append("\n\n");
licenseText.append(la.getText());
licenseText.append("\n\n");
}
return "" + licenseText;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
use of com.sun.pkg.client.Manifest in project Payara by payara.
the class UpdateCenterHandlers method getUpdateDisplayList.
// If countOnly is set to true, return a List that contains only one Integer that specifies the # of updates.
// This is for displaying in the masthead
// If countOnly is set to false, it will go through each package that has update available and return a list
// suitable for displaying as a table row.
private static List getUpdateDisplayList(Image image, boolean countOnly) {
List<Image.FmriState> installed = image.getInventory(null, false);
Map<String, Fmri> updateListMap = new HashMap();
List<String> nameList = new ArrayList();
for (Image.FmriState fs : installed) {
if (fs.upgradable) {
Fmri fmri = fs.fmri;
updateListMap.put(fmri.getName(), fmri);
nameList.add(fmri.getName());
}
}
List result = new ArrayList();
String[] pkgsName = nameList.toArray(new String[nameList.size()]);
try {
Image.ImagePlan ip = image.makeInstallPlan(pkgsName, "list");
Fmri[] proposed = ip.getProposedFmris();
if (countOnly) {
result.add(Integer.valueOf(proposed.length));
return result;
}
for (Fmri newPkg : proposed) {
Map oneRow = new HashMap();
try {
String name = newPkg.getName();
Fmri oldPkg = updateListMap.get(name);
Manifest manifest = image.getManifest(newPkg);
int changedSize = manifest.getPackageSize() - image.getManifest(oldPkg).getPackageSize();
oneRow.put("selected", false);
oneRow.put("fmri", newPkg);
oneRow.put("fmriStr", newPkg.toString());
putInfo(oneRow, "pkgName", name);
putInfo(oneRow, "newVersion", getPkgVersion(newPkg.getVersion()));
putInfo(oneRow, "version", getPkgVersion(oldPkg.getVersion()));
putInfo(oneRow, "category", getCategory(manifest));
putInfo(oneRow, "pkgSize", convertSizeForDispay(changedSize));
oneRow.put("size", Integer.valueOf(changedSize));
putInfo(oneRow, "auth", newPkg.getAuthority());
String tooltip = manifest.getAttribute(PKG_SUMMARY);
if (GuiUtil.isEmpty(tooltip))
tooltip = manifest.getAttribute(DESC);
putInfo(oneRow, "tooltip", tooltip);
result.add(oneRow);
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (Exception ex) {
ex.printStackTrace();
if (countOnly) {
List tmpL = new ArrayList();
tmpL.add(Integer.valueOf(-1));
return tmpL;
}
}
GuiUtil.setSessionValue("_updateCountMsg", GuiUtil.getMessage(UpdateCenterHandlers.BUNDLE, "msg.updatesAvailable", new String[] { "" + result.size() }));
return result;
}
use of com.sun.pkg.client.Manifest in project Payara by payara.
the class UpdateCenterHandlers method getPkgDetailsInfo.
@Handler(id = "getPkgDetailsInfo", input = { @HandlerInput(name = "fmriStr", type = String.class, required = true), @HandlerInput(name = "auth", type = String.class, required = true) }, output = { @HandlerOutput(name = "details", type = java.util.Map.class) })
public static void getPkgDetailsInfo(HandlerContext handlerCtx) {
String fmriStr = (String) handlerCtx.getInputValue("fmriStr");
// Called by the intiPage and don't need to process. When we can use beforeCreate to do this, we can remove this check.
if (fmriStr == null) {
handlerCtx.setOutputValue("details", new HashMap());
return;
}
Fmri fmri = new Fmri(fmriStr);
Map details = new HashMap();
Image img = getUpdateCenterImage();
try {
details.put("pkgName", fmri.getName());
details.put("uid", fmri.toString());
details.put("version", getPkgVersion(fmri.getVersion()));
details.put("date", fmri.getVersion().getPublishDate());
details.put("auth", (String) handlerCtx.getInputValue("auth"));
details.put("url", fmri.getURLPath());
if (img != null) {
Manifest manifest = img.getManifest(fmri);
details.put("category", getCategory(manifest));
details.put("bytes", "" + manifest.getPackageSize());
details.put("pkgSize", getPkgSize(manifest));
// look for description in the following order:
// pkg.description, description_long, pkg.summary, description
// since description_long and description has been deprecated.
String desc = manifest.getAttribute(PKG_DESC);
if (GuiUtil.isEmpty(desc)) {
desc = manifest.getAttribute(DESC_LONG);
if (GuiUtil.isEmpty(desc)) {
desc = manifest.getAttribute(PKG_SUMMARY);
if (GuiUtil.isEmpty(desc))
desc = manifest.getAttribute(DESC);
}
}
details.put("desc", desc);
}
} catch (Exception ex) {
ex.printStackTrace();
}
handlerCtx.setOutputValue("details", details);
}
Aggregations