diff --git a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/DeploymentInfoController.java b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/DeploymentInfoController.java index a4788143ae8b5a3cf40f6ea26d7c5216d4a9e018..414deed87b5d8e3f68a5988ea5b3d06e37e75a2f 100644 --- a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/DeploymentInfoController.java +++ b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/DeploymentInfoController.java @@ -26,6 +26,7 @@ import org.universAAL.ucc.configuration.view.ConfigurationOverviewWindow; import org.universAAL.ucc.database.aalspace.DataAccess; import org.universAAL.ucc.frontend.api.impl.FrontendImpl; import org.universAAL.ucc.model.AALService; +import org.universAAL.ucc.model.UAPP; import org.universAAL.ucc.model.UAPPPart; import org.universAAL.ucc.model.UAPPReqAtom; import org.universAAL.ucc.model.jaxb.EnumObject; @@ -82,27 +83,27 @@ public class DeploymentInfoController implements Button.ClickListener, dcvMap = new HashMap<String, DeployConfigView>(); mapLayout = new HashMap<Part, List<PeerCard>>(); int i = 0; - - for (UAPPPart uapp : aal.getUaapList()) { + for(UAPP ua : aal.getUaapList()) { + for (Map.Entry<String, UAPPPart>uapp : ua.getParts().entrySet()) { i++; if (i == 1) { - selected = uapp.getPart().getPartId(); + selected = uapp.getValue().getPart().getPartId(); } - System.err.println(uapp.getPart().getPartId() + " "+aal.getUaapList().size()); - win.getTree().addItem(uapp.getPart().getPartId()); - win.getTree().setChildrenAllowed(uapp.getPart().getPartId(), false); + System.err.println(uapp.getValue().getPart().getPartId() + " "+aal.getUaapList().size()); + win.getTree().addItem(uapp.getValue().getPart().getPartId()); + win.getTree().setChildrenAllowed(uapp.getValue().getPart().getPartId(), false); DeployStrategyView dsv = new DeployStrategyView(aal.getName(), - aal.getServiceId(), uapp.getUappLocation()); + aal.getServiceId(), uapp.getValue().getUappLocation()); dsv.getOptions().addListener(this); - dsvMap.put(uapp.getPart().getPartId(), dsv); + dsvMap.put(uapp.getValue().getPart().getPartId(), dsv); DeployConfigView dcv = new DeployConfigView(app, - aal.getServiceId(), uapp.getUappLocation()); - dcv.getTxt().setValue(uapp.getPart().getPartId()); + aal.getServiceId(), uapp.getValue().getUappLocation()); + dcv.getTxt().setValue(uapp.getValue().getPart().getPartId()); dcv.getTxt().setEnabled(false); System.err.println("Befor getValidPeers()"); //Insert valid PeerNodes to dropbox of DeployConfigView - List<PeerCard> validpeers = getValidPeers(uapp.getReqAtoms(), uapp.getPart().getPartId()); + List<PeerCard> validpeers = getValidPeers(uapp.getValue().getReqAtoms(), uapp.getValue().getPart().getPartId()); System.err.println("In validpeers size: "+validpeers.size()); for(PeerCard pc : validpeers) { if (pc != null) { @@ -116,16 +117,17 @@ public class DeploymentInfoController implements Button.ClickListener, dcv.getSelect().setEnabled(false); dcv.setEnabled(false); - dcvMap.put(uapp.getPart().getPartId(), dcv); + dcvMap.put(uapp.getValue().getPart().getPartId(), dcv); } win.getTree().select(selected); - for (UAPPPart ua : aal.getUaapList()) { - if (ua.getPart().getPartId().equals(selected)) { - DeployStrategyView dsv = dsvMap.get(ua.getPart().getPartId()); - DeployConfigView dcv = dcvMap.get(ua.getPart().getPartId()); + for (Map.Entry<String, UAPPPart> u : ua.getParts().entrySet()) { + if (u.getValue().getPart().getPartId().equals(selected)) { + DeployStrategyView dsv = dsvMap.get(u.getValue().getPart().getPartId()); + DeployConfigView dcv = dcvMap.get(u.getValue().getPart().getPartId()); actVL = win.createSecondComponent(dsv, dcv); } } + } win.getTree().addListener(this); win.getOk().addListener((Button.ClickListener) this); win.getCancel().addListener((Button.ClickListener) this); @@ -137,28 +139,30 @@ public class DeploymentInfoController implements Button.ClickListener, Map<Part, List<PeerCard>> config = null; // TODO: Deployment peers = installer.getPeers(); - for (UAPPPart uapp : aal.getUaapList()) { + for(UAPP up : aal.getUaapList()) { + for (Map.Entry<String, UAPPPart> uapp : up.getParts().entrySet()) { // Selected part in tree - if (uapp.getPart().getPartId().equals(selected)) { + if (uapp.getValue().getPart().getPartId().equals(selected)) { // Default Deployment Strategy if (dsvMap.get(selected).getOptions().getValue().toString() .equals(bundle.getString("opt.available.nodes"))) { - config = buildDefaultInstallationLayout(uapp); + config = buildDefaultInstallationLayout(uapp.getValue()); } // User selection strategy else if (dsvMap.get(selected).getOptions().getValue() .toString() .equals(bundle.getString("opt.selected.nodes"))) { - System.err.println("User Installation for part: "+uapp.getPart().getPartId()); - config = buildUserInstallationLayout(uapp); + System.err.println("User Installation for part: "+uapp.getValue().getPart().getPartId()); + config = buildUserInstallationLayout(uapp.getValue()); if (config.isEmpty()) return; } } } + } // Remove installed part view and item from tree win.getHp().removeComponent(actVL); @@ -186,11 +190,12 @@ public class DeploymentInfoController implements Button.ClickListener, } // Deploy to MW - for(UAPPPart uapp : aal.getUaapList()) { + for(UAPP up : aal.getUaapList()) { + for(Map.Entry<String, UAPPPart> uapp : up.getParts().entrySet()) { UAPPPackage uapack = null; // Get uapp location uri - String appLocation = uapp.getUappLocation(); - System.err.println("THE UAPP_LOCATION: "+uapp.getUappLocation()); + String appLocation = uapp.getValue().getUappLocation(); + System.err.println("THE UAPP_LOCATION: "+uapp.getValue().getUappLocation()); appLocation = FrontendImpl.getUappURI(); System.err.println("LOCATION URI: "+appLocation); File uf = new File(appLocation.trim()); @@ -204,19 +209,19 @@ public class DeploymentInfoController implements Button.ClickListener, //MW installation uapack = new UAPPPackage(aal.getServiceId(), - uapp.getAppId(), uf.toURI(), peerMap); + uapp.getValue().getAppId(), uf.toURI(), peerMap); InstallationResultsDetails res = installer.requestToInstall(uapack); // add app and bundles to "services.xml" file. System.err.println("The GLOBAL RESULT: "+res.getGlobalResult().toString()); - System.err.println("Service ID: "+aal.getServiceId()+ " App ID: "+uapp.getAppId()+" Bundle ID: "+uapp.getBundleId()+ "Bundle Version: "+uapp.getBundleId()); + System.err.println("Service ID: "+aal.getServiceId()+ " App ID: "+uapp.getValue().getAppId()+" Bundle ID: "+uapp.getValue().getBundleId()+ "Bundle Version: "+uapp.getValue().getBundleId()); if (res.getGlobalResult().toString().equals(InstallationResults.SUCCESS.name())) { srvRegistration.registerApp(aal.getServiceId(), - uapp.getAppId()); + uapp.getValue().getAppId()); // get bundles for each part in the appId; // for each bundle: srvRegistration.registerBundle(aal.getServiceId(), - uapp.getBundleId(), uapp.getBundleVersion()); + uapp.getValue().getBundleId(), uapp.getValue().getBundleVersion()); // TODO: Call configurator to configure the uapps, after // uapp is running (for every uapp) @@ -230,10 +235,10 @@ public class DeploymentInfoController implements Button.ClickListener, + reg.getAllConfigDefinitions().size()); for (Configuration configurator : reg .getAllConfigDefinitions()) { - System.err.println(uapp.getBundleId()+" + "+configurator.getBundlename()); + System.err.println(uapp.getValue().getBundleId()+" + "+configurator.getBundlename()); if (configurator.getBundlename() != null && configurator.getBundlename().equals( - uapp.getBundleId())) { + uapp.getValue().getBundleId())) { conf = configurator; } } @@ -354,6 +359,7 @@ public class DeploymentInfoController implements Button.ClickListener, } } + } selected = (String) win.getTree().getItemIds().iterator().next(); win.getTree().select(selected); @@ -387,16 +393,17 @@ public class DeploymentInfoController implements Button.ClickListener, } public void valueChange(ValueChangeEvent event) { - for (UAPPPart ua : aal.getUaapList()) { + for(UAPP up : aal.getUaapList()) { + for (Map.Entry<String, UAPPPart> ua : up.getParts().entrySet()) { System.err.println(aal.getUaapList().size()); - if (ua.getPart().getPartId().equals(event.getProperty().toString())) { + if (ua.getValue().getPart().getPartId().equals(event.getProperty().toString())) { selected = event.getProperty().toString(); - DeployStrategyView dsv = dsvMap.get(ua.getPart().getPartId()); - DeployConfigView dcv = dcvMap.get(ua.getPart().getPartId()); + DeployStrategyView dsv = dsvMap.get(ua.getValue().getPart().getPartId()); + DeployConfigView dcv = dcvMap.get(ua.getValue().getPart().getPartId()); actVL = win.createSecondComponent(dsv, dcv); } } - + } if (event.getProperty().getValue().toString() .equals(bundle.getString("opt.selected.nodes"))) { dcvMap.get(selected).setEnabled(true); diff --git a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/LicenseController.java b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/LicenseController.java index b6170703a0d47cecac67315c778dd019b8c55d71..578c77cd19f5369b45fd6b136bbf36d4bfdb088a 100644 --- a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/LicenseController.java +++ b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/controller/install/LicenseController.java @@ -122,7 +122,7 @@ public class LicenseController implements Property.ValueChangeListener, if (event.getButton() == win.getGo()) { app.getMainWindow().removeWindow(win); // Test, if uapps size greater than 0 - if (appCounter > 0) { + if (aal.getUaapList().size() > 0) { System.err.println("[LicenseController]: appCounter " + appCounter); // Load Infoview for Deployment of uapps diff --git a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/frontend/api/impl/FrontendImpl.java b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/frontend/api/impl/FrontendImpl.java index b7f51174dc8b1ddf3c3e2ad56566d546877e81ba..ddb14a2d0ed43cfe920860f828e2a28ec797dc15 100644 --- a/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/frontend/api/impl/FrontendImpl.java +++ b/uCC/ucc.frontend/src/main/java/org/universAAL/ucc/frontend/api/impl/FrontendImpl.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.ResourceBundle; import java.util.zip.ZipEntry; import java.util.zip.ZipException; @@ -31,6 +32,7 @@ import org.universAAL.middleware.deploymanager.uapp.model.Feature; import org.universAAL.middleware.deploymanager.uapp.model.Part.PartRequirements; import org.universAAL.middleware.deploymanager.uapp.model.ReqType; import org.universAAL.ucc.model.usrv.AalUsrv; +import org.universAAL.ucc.model.usrv.ApplicationType; import org.universAAL.middleware.deploymanager.uapp.model.Part; import org.universAAL.middleware.managers.api.InstallationResults; import org.universAAL.middleware.managers.api.InstallationResultsDetails; @@ -38,6 +40,8 @@ import org.universAAL.middleware.managers.api.InstallationResultsDetails; import org.universAAL.ucc.controller.install.UsrvInfoController; import org.universAAL.ucc.frontend.api.IFrontend; import org.universAAL.ucc.model.AALService; +import org.universAAL.ucc.model.Provider; +import org.universAAL.ucc.model.UAPP; import org.universAAL.ucc.model.UAPPPart; import org.universAAL.ucc.model.UAPPReqAtom; import org.universAAL.ucc.model.install.License; @@ -70,11 +74,12 @@ public class FrontendImpl implements IFrontend { private static String userSession; private String base; private ResourceBundle bundle; - + public FrontendImpl() { base = "resources.ucc"; bundle = ResourceBundle.getBundle(base); - usrvLocalStore = Activator.getModuleConfigHome().getAbsolutePath() + "/tempUsrvFiles/"; + usrvLocalStore = Activator.getModuleConfigHome().getAbsolutePath() + + "/tempUsrvFiles/"; } public boolean installService(String sessionkey, String serviceId, @@ -84,65 +89,72 @@ public class FrontendImpl implements IFrontend { // if(sessionkey.equals(DesktopController.getSessionKey())) { // downloads a usrv-file from the given download-uri // TO be unmarked - System.err.println("[[FrontendImpl]] SessionKey: "+sessionkey+ " Service-Link: "+serviceLink+ " Service-ID: "+serviceId); - - System.err.println("The service link from ustore: "+serviceLink); - - if(serviceLink != null && !serviceLink.equals("")) { + System.err + .println("[[FrontendImpl]] SessionKey: " + sessionkey + + " Service-Link: " + serviceLink + " Service-ID: " + + serviceId); + + System.err.println("The service link from ustore: " + serviceLink); + + if (serviceLink != null && !serviceLink.equals("")) { try { - downloadUsrvFile(serviceLink, serviceId+".usrv"); + downloadUsrvFile(serviceLink, serviceId + ".usrv"); } catch (IOException e2) { e2.printStackTrace(); } } - System.out.println("Using the usrfile:"+System.getProperty("uAAL.uCC.usrvfile",usrvLocalStore - + serviceId+".usrv")); - File temp = new File(System.getProperty("uAAL.uCC.usrvfile",usrvLocalStore - + serviceId+".usrv")); - if (temp.exists()) { - try { - extractFolder(temp.getAbsolutePath(),usrvLocalStore); - } catch (ZipException e2) { - e2.printStackTrace(); - } catch (IOException e2) { - e2.printStackTrace(); - } - - // Copy uapp files to C:/tempUsrvFiles/hwo_uapp/ - uappURI = createUAPPLocation(usrvLocalStore + "bin", serviceId+"_temp"); - - // extract available uapp files - File usrv = new File(uappURI); - File[] uapps = usrv.listFiles(); - for (File cur : uapps) { - try { - extractFolder(usrvLocalStore + serviceId+"_temp"+ "/" + cur.getName(), - usrvLocalStore + serviceId+"_temp"+ "/"); - } catch (ZipException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - // parse uapp.config.xml -// Get uapp.xml name out of the file extension - File f = new File(usrvLocalStore + serviceId+"_temp" + "/config"); - File[] confi = f.listFiles(); - String configFileName = ""; - for(File cf : confi) { - if(cf.getName().contains(".xml")) { - configFileName = cf.getName(); - System.err.println(configFileName); + System.out.println("Using the usrfile:" + + System.getProperty("uAAL.uCC.usrvfile", usrvLocalStore + + serviceId + ".usrv")); + File temp = new File(System.getProperty("uAAL.uCC.usrvfile", + usrvLocalStore + serviceId + ".usrv")); + if (temp.exists()) { + try { + extractFolder(temp.getAbsolutePath(), usrvLocalStore); + } catch (ZipException e2) { + e2.printStackTrace(); + } catch (IOException e2) { + e2.printStackTrace(); + } + + // Copy uapp files to C:/tempUsrvFiles/hwo_uapp/ + uappURI = createUAPPLocation(usrvLocalStore + "bin", serviceId + + "_temp"); + + // extract available uapp files + File usrv = new File(uappURI); + File[] uapps = usrv.listFiles(); + for (File cur : uapps) { + try { + extractFolder(usrvLocalStore + serviceId + "_temp" + "/" + + cur.getName(), usrvLocalStore + serviceId + + "_temp" + "/"); + } catch (ZipException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // parse uapp.config.xml + // Get uapp.xml name out of the file extension + File f = new File(usrvLocalStore + serviceId + "_temp" + "/config"); + File[] confi = f.listFiles(); + String configFileName = ""; + for (File cf : confi) { + if (cf.getName().contains(".xml")) { + configFileName = cf.getName(); + System.err.println(configFileName); + } } + parseUappConfiguration(usrvLocalStore + serviceId + "_temp" + + "/config/" + configFileName, serviceId); + return true; + // } else { + // //TODO: SessionKey was not right, what todo? + // return false; + // } } - parseUappConfiguration(usrvLocalStore+serviceId+"_temp"+"/config/"+configFileName, serviceId); - return true; -// } else { -// //TODO: SessionKey was not right, what todo? -// return false; -// } - } return false; } @@ -160,8 +172,10 @@ public class FrontendImpl implements IFrontend { URL url = new URL(downloadUri); URLConnection con = url.openConnection(); InputStream in = new BufferedInputStream(con.getInputStream()); - FileOutputStream out = new FileOutputStream( - Activator.getModuleConfigHome().getAbsolutePath() + "/tempUsrvFiles/" + filename); + FileOutputStream out = new FileOutputStream(Activator + .getModuleConfigHome().getAbsolutePath() + + "/tempUsrvFiles/" + + filename); byte[] chunk = new byte[153600]; int chunkSize; while ((chunkSize = in.read(chunk)) > 0) { @@ -180,8 +194,8 @@ public class FrontendImpl implements IFrontend { * information from the uapp file * */ - private ArrayList<UAPPPart> parseUappConfiguration(String f, String serviceId) { - ArrayList<UAPPPart> appsList = new ArrayList<UAPPPart>(); + private ArrayList<UAPP> parseUappConfiguration(String f, String serviceId) { + ArrayList<UAPP> appsList = new ArrayList<UAPP>(); File l = null; String txt = ""; String slaName = ""; @@ -193,17 +207,31 @@ public class FrontendImpl implements IFrontend { AalUapp uapp = null; System.err.println(f); ParserService ps = Activator.getParserService(); - if(ps != null) + if (ps != null) System.err.println("Got ParserService"); uapp = ps.getUapp(f); System.err.println(f); System.err.println(uapp.getApp().getAppId()); - List<Part> parts = uapp - .getApplicationPart().getPart(); + List<Part> parts = uapp.getApplicationPart().getPart(); System.err.println(parts.size()); - - System.err.println("Size of parts: "+parts.size() + " "+ parts.get(0).getBundleId()); - System.err.println("Bundle-Version: "+parts.get(0).getBundleVersion()); + + System.err.println("Size of parts: " + parts.size() + " " + + parts.get(0).getBundleId()); + System.err + .println("Bundle-Version: " + parts.get(0).getBundleVersion()); + UAPP up = new UAPP(); + up.setName(uapp.getApp().getName()); + Provider provider = new Provider(uapp.getApp().getApplicationProvider() + .getContactPerson(), uapp.getApp().getApplicationProvider() + .getPhone(), uapp.getApp().getApplicationProvider().getEmail(), + uapp.getApp().getApplicationProvider().getWebAddress()); + + up.setProvider(provider); + String version = String.valueOf(uapp.getApp().getVersion().getMajor()) + .concat(".") + .concat(String.valueOf(uapp.getApp().getVersion().getMicro())) + .concat(String.valueOf(uapp.getApp().getVersion().getMinor())); + up.setVersion(version); for (Part p : parts) { UAPPPart ua = new UAPPPart(); ua.setUappLocation(uappURI); @@ -215,176 +243,202 @@ public class FrontendImpl implements IFrontend { System.err.println(p.getBundleId()); ua.setBundleVersion(p.getBundleVersion()); System.err.println(p.getDeploymentUnit().size()); - //Here starts the error and breaks the parsing - //Getting DeploymentUnit - System.err.println("Deployment-UNIT-Size: "+p.getDeploymentUnit().size()); - for(DeploymentUnit du : p.getDeploymentUnit()) { - //Getting ContainerUnits - if(du.isSetContainerUnit()) { - //Karaf features - if(du.getContainerUnit().isSetKaraf()) { - if ( du.getContainerUnit().getKaraf().getFeatures() == null ) { - System.err.println("No features for "+du.getId()); + // Here starts the error and breaks the parsing + // Getting DeploymentUnit + System.err.println("Deployment-UNIT-Size: " + + p.getDeploymentUnit().size()); + for (DeploymentUnit du : p.getDeploymentUnit()) { + // Getting ContainerUnits + if (du.isSetContainerUnit()) { + // Karaf features + if (du.getContainerUnit().isSetKaraf()) { + if (du.getContainerUnit().getKaraf().getFeatures() == null) { + System.err.println("No features for " + du.getId()); continue; } - for(Serializable so : du.getContainerUnit().getKaraf().getFeatures().getRepositoryOrFeature()) { - if(so instanceof Feature) { - Feature feat = (Feature)so; - for(Serializable dco : feat.getDetailsOrConfigOrConfigfile()) { - if(dco instanceof Bundle) { - Bundle b = (Bundle)dco; - System.err.println("Bundle-Value: "+b.getValue()); + for (Serializable so : du.getContainerUnit().getKaraf() + .getFeatures().getRepositoryOrFeature()) { + if (so instanceof Feature) { + Feature feat = (Feature) so; + for (Serializable dco : feat + .getDetailsOrConfigOrConfigfile()) { + if (dco instanceof Bundle) { + Bundle b = (Bundle) dco; + System.err.println("Bundle-Value: " + + b.getValue()); ua.setUappLocation(b.getValue().trim()); - System.err.println("Bundle-Value: "+b.getValue()); + System.err.println("Bundle-Value: " + + b.getValue()); } } } } - System.err.println("Featuresize: "+du.getContainerUnit().getKaraf().getFeatures().getRepositoryOrFeature().size()); - - System.err.println("Feauture: "+du.getContainerUnit().getKaraf().getFeatures().getRepositoryOrFeature().get(0).toString()); + System.err.println("Featuresize: " + + du.getContainerUnit().getKaraf() + .getFeatures().getRepositoryOrFeature() + .size()); + + System.err.println("Feauture: " + + du.getContainerUnit().getKaraf() + .getFeatures().getRepositoryOrFeature() + .get(0).toString()); } - //Android app - if(du.getContainerUnit().isSetAndroid()) { - for(String loc : du.getContainerUnit().getAndroid().getLocation()) { + // Android app + if (du.getContainerUnit().isSetAndroid()) { + for (String loc : du.getContainerUnit().getAndroid() + .getLocation()) { ua.setUappLocation(loc); System.err.println(loc); } } - //Equinox Container as runtime - if(du.getContainerUnit().isSetEquinox()) { - //TODO: Parsing for Equinox Container + // Equinox Container as runtime + if (du.getContainerUnit().isSetEquinox()) { + // TODO: Parsing for Equinox Container } - //Felix Container as runtime - if(du.getContainerUnit().isSetFelix()) { - //TODO: Parsing for Felix + // Felix Container as runtime + if (du.getContainerUnit().isSetFelix()) { + // TODO: Parsing for Felix } - if(du.getContainerUnit().isSetTomcat()) { - //TODO: Parsing for Tomcat + if (du.getContainerUnit().isSetTomcat()) { + // TODO: Parsing for Tomcat } - if(du.getContainerUnit().isSetOsgiAndroid()) { - //TODO: Parsing for OSGI Android + if (du.getContainerUnit().isSetOsgiAndroid()) { + // TODO: Parsing for OSGI Android } } - //OS Unit - if(du.isSetOsUnit()) { - //TODO: Parse Values for OSUnit + // OS Unit + if (du.isSetOsUnit()) { + // TODO: Parse Values for OSUnit } - //PlatformUnit - if(du.isSetPlatformUnit()) { - //TODO: Parse Values for PlatformUnit + // PlatformUnit + if (du.isSetPlatformUnit()) { + // TODO: Parse Values for PlatformUnit } - + } - - //Getting UAPPReqAtom for validation + + // Getting UAPPReqAtom for validation UAPPReqAtom atom = null; PartRequirements pr = p.getPartRequirements(); - for(ReqType rt : pr.getRequirement()) { + for (ReqType rt : pr.getRequirement()) { atom = new UAPPReqAtom(); - if(rt.isSetReqAtom()) { - System.err.println("ReqAtom Name: "+rt.getReqAtom().getReqAtomName()); + if (rt.isSetReqAtom()) { + System.err.println("ReqAtom Name: " + + rt.getReqAtom().getReqAtomName()); atom.setName(rt.getReqAtom().getReqAtomName()); - System.err.println("ReqAtom Value: "+rt.getReqAtom().getReqAtomValue()); -// List<String> ll = new ArrayList<String>(); -// ll.add(rt.getReqAtom().getReqAtomValue()); + System.err.println("ReqAtom Value: " + + rt.getReqAtom().getReqAtomValue()); + // List<String> ll = new ArrayList<String>(); + // ll.add(rt.getReqAtom().getReqAtomValue()); atom.setValue(rt.getReqAtom().getReqAtomValue()); - if(rt.getReqAtom().getReqCriteria() != null) { - System.err.println("ReqAtom Criteria: "+rt.getReqAtom().getReqCriteria().value()); - atom.setCriteria(rt.getReqAtom().getReqCriteria().value()); + if (rt.getReqAtom().getReqCriteria() != null) { + System.err.println("ReqAtom Criteria: " + + rt.getReqAtom().getReqCriteria().value()); + atom.setCriteria(rt.getReqAtom().getReqCriteria() + .value()); } } - if(rt.isSetReqGroup()) { - for(ReqType rType : rt.getReqGroup().getRequirement()) { - if(rType.isSetReqAtom()) { - System.err.println(rType.getReqAtom().getReqAtomName()); - System.err.println(rType.getReqAtom().getReqAtomValue()); - System.err.println(rType.getReqAtom().getReqCriteria()); + if (rt.isSetReqGroup()) { + for (ReqType rType : rt.getReqGroup().getRequirement()) { + if (rType.isSetReqAtom()) { + System.err.println(rType.getReqAtom() + .getReqAtomName()); + System.err.println(rType.getReqAtom() + .getReqAtomValue()); + System.err.println(rType.getReqAtom() + .getReqCriteria()); } } } ua.addReqAtoms(atom); } - + ua.setAppId(uapp.getApp().getAppId()); ua.setDescription(uapp.getApp().getDescription()); ua.setMultipart(uapp.getApp().isMultipart()); ua.setName(uapp.getApp().getName()); - - if(uapp.getApp().isSetVersion()) { - if(uapp.getApp().getVersion().isSetMajor()) { + + if (uapp.getApp().isSetVersion()) { + if (uapp.getApp().getVersion().isSetMajor()) { ua.setMajor(uapp.getApp().getVersion().getMajor()); aal.setMajor(ua.getMajor()); System.err.println(ua.getMajor()); } - if(uapp.getApp().getVersion().isSetMinor()) { + if (uapp.getApp().getVersion().isSetMinor()) { ua.setMinor(uapp.getApp().getVersion().getMinor()); aal.setMinor(ua.getMinor()); System.err.println(ua.getMinor()); } - if(uapp.getApp().getVersion().isSetMicro()) { + if (uapp.getApp().getVersion().isSetMicro()) { ua.setMicro(uapp.getApp().getVersion().getMicro()); aal.setMicro(ua.getMicro()); System.err.println(ua.getMicro()); } - + } - appsList.add(ua); - - //Creating license files - for(AalUapp.App.Licenses ls : uapp.getApp().getLicenses()) { + up.addPart(ua.getPart().getPartId(), ua); + appsList.add(up); + + // Creating license files + for (AalUapp.App.Licenses ls : uapp.getApp().getLicenses()) { license = new License(); - if(ls.isSetSla()) { + if (ls.isSetSla()) { slaName = ls.getSla().getName(); - System.err.println("SLA-Name: "+slaName); + System.err.println("SLA-Name: " + slaName); license.setAppName(slaName); - if(ls.getSla().isSetLink() && !ls.getSla().getLink().trim().isEmpty() ) { -// try { -// URL slaContent = new URL(ls.getSla().getLink()); -// slaContent.get -// } catch (MalformedURLException e) { -// e.printStackTrace(); -// } - try{ - String link = ls.getSla().getLink(); - System.err.println(link); - link = link.substring(link.indexOf("./")); - System.err.println(link); - File file = new File(usrvLocalStore + serviceId+"_temp" + link); - license.getSlaList().add(file); - }catch(Throwable t){ + if (ls.getSla().isSetLink() + && !ls.getSla().getLink().trim().isEmpty()) { + // try { + // URL slaContent = new URL(ls.getSla().getLink()); + // slaContent.get + // } catch (MalformedURLException e) { + // e.printStackTrace(); + // } + try { + String link = ls.getSla().getLink(); + System.err.println(link); + link = link.substring(link.indexOf("./")); + System.err.println(link); + File file = new File(usrvLocalStore + serviceId + + "_temp" + link); + license.getSlaList().add(file); + } catch (Throwable t) { t.printStackTrace(); } } - + } - if(ls.isSetLicense()) { - for(org.universAAL.middleware.deploymanager.uapp.model.LicenseType lt : ls.getLicense()) { - - System.err.println("LicenseType is set!!! "+lt.getLink()); - if(lt.isSetLink() && !lt.getLink().trim().isEmpty() ) { - try{ + if (ls.isSetLicense()) { + for (org.universAAL.middleware.deploymanager.uapp.model.LicenseType lt : ls + .getLicense()) { + + System.err.println("LicenseType is set!!! " + + lt.getLink()); + if (lt.isSetLink() && !lt.getLink().trim().isEmpty()) { + try { txt = lt.getLink(); System.err.println(txt); txt = txt.substring(txt.indexOf("./")); System.err.println(txt); - l = new File(usrvLocalStore + serviceId+"_temp" + txt); + l = new File(usrvLocalStore + serviceId + + "_temp" + txt); list.add(l); - }catch(Throwable t){ - t.printStackTrace(); - } + } catch (Throwable t) { + t.printStackTrace(); } - + } + } } - + } license.setLicense(list); licenseList.add(license); aal.setLicenses(license); - + } - parseConfiguration(serviceId+"_temp", appsList, licenseList, aal); + aal.setUaapList(appsList); + parseConfiguration(serviceId + "_temp", appsList, licenseList, aal); return appsList; } @@ -397,87 +451,105 @@ public class FrontendImpl implements IFrontend { * @throws SAXException * @throws IOException */ - private AALService parseConfiguration(String f, ArrayList<UAPPPart> apps, ArrayList<License>licenseList, AALService aal) { - - //Parsing usrv.xml + private AALService parseConfiguration(String f, ArrayList<UAPP> apps, + ArrayList<License> licenseList, AALService aal) { + + // Parsing usrv.xml ParserService ps = Activator.getParserService(); - //Getting usrv.xml - File configFile = new File(usrvLocalStore+"config"); - File[]confis = configFile.listFiles(); + // Getting usrv.xml + File configFile = new File(usrvLocalStore + "config"); + File[] confis = configFile.listFiles(); String configFileName = ""; - for(File cf : confis) { - if(cf.getName().contains(".xml")) { + for (File cf : confis) { + if (cf.getName().contains(".xml")) { configFileName = cf.getName(); } } - AalUsrv usrv = ps.getUsrv(usrvLocalStore+"config/"+configFileName); - System.err.println(aal.getMajor()+"."+aal.getMinor()+"."+aal.getMicro()); - - for(UAPPPart ua : apps) { - System.err.println(ua.getAppId()); - aal.getUaapList().add(ua); + AalUsrv usrv = ps.getUsrv(usrvLocalStore + "config/" + configFileName); + System.err.println(aal.getMajor() + "." + aal.getMinor() + "." + + aal.getMicro()); + List<ApplicationType> xmlApps = usrv.getComponents().getApplication(); + for (ApplicationType xmlApp : xmlApps) { + UAPP modelUAAP = new UAPP(); + modelUAAP.setName(xmlApp.getName()); + Provider provider = new Provider(usrv.getSrv().getServiceProvider().getOrganizationName(), usrv.getSrv().getServiceProvider().getPhone(), + usrv.getSrv().getServiceProvider().getEmail(), usrv.getSrv().getServiceProvider().getWebAddress()); + modelUAAP.setProvider(provider); + String version = usrv.getSrv().getVersion().getMajor()+ "."+ usrv.getSrv().getVersion().getMicro() + "." + usrv.getSrv().getVersion().getMinor(); + modelUAAP.setVersion(version); + for(Map.Entry<String, UAPPPart> part : modelUAAP.getParts().entrySet()) { + modelUAAP.getParts().put(part.getKey(), part.getValue()); + aal.getUaapList().add( modelUAAP ); + } + } + /* + for (UAPP up : aal.getUaapList()) { + for (Map.Entry<String, UAPPPart> ua : up.getParts().entrySet()) { + System.err.println(ua.getValue().getAppId()); + aal.getUaapList().add(up); + } } - if(usrv.isSetSrv()) { - if(usrv.getSrv().isSetServiceId()) { - System.err.println("Service-ID: "+usrv.getSrv().getServiceId()); + */ + if (usrv.isSetSrv()) { + if (usrv.getSrv().isSetServiceId()) { + System.err.println("Service-ID: " + + usrv.getSrv().getServiceId()); aal.setServiceId(usrv.getSrv().getServiceId()); } - if(usrv.getSrv().isSetName()) { + if (usrv.getSrv().isSetName()) { aal.setName(usrv.getSrv().getName()); - System.err.println("Service-Name: "+usrv.getSrv().getName()); + System.err.println("Service-Name: " + usrv.getSrv().getName()); } - if(usrv.getSrv().isSetServiceProvider()) { - aal.setProvider(usrv.getSrv().getServiceProvider().getOrganizationName()); - System.err.println("ServiceProvider: "+aal.getProvider()); + if (usrv.getSrv().isSetServiceProvider()) { + aal.setProvider(usrv.getSrv().getServiceProvider() + .getOrganizationName()); + System.err.println("ServiceProvider: " + aal.getProvider()); } - if(usrv.getSrv().isSetDescription()) { + if (usrv.getSrv().isSetDescription()) { aal.setDescription(usrv.getSrv().getDescription()); - System.err.println("Description: "+aal.getDescription()); + System.err.println("Description: " + aal.getDescription()); } - - -// if(usrv.getSrv().isSetVersion()) { -// if(usrv.getSrv().getVersion().isSetMajor()) { -// aal.setMajor(usrv.getSrv().getVersion().getMajor()); -// System.err.println(aal.getMajor()); -// } -// if(usrv.getSrv().getVersion().isSetMinor()) { -// aal.setMinor(usrv.getSrv().getVersion().getMinor()); -// System.err.println(aal.getMinor()); -// } -// if(usrv.getSrv().getVersion().isSetMicro()) { -// aal.setMicro(usrv.getSrv().getVersion().getMicro()); -// System.err.println(aal.getMicro()); -// } -// } - if(usrv.getSrv().isSetTags()) { + + // if(usrv.getSrv().isSetVersion()) { + // if(usrv.getSrv().getVersion().isSetMajor()) { + // aal.setMajor(usrv.getSrv().getVersion().getMajor()); + // System.err.println(aal.getMajor()); + // } + // if(usrv.getSrv().getVersion().isSetMinor()) { + // aal.setMinor(usrv.getSrv().getVersion().getMinor()); + // System.err.println(aal.getMinor()); + // } + // if(usrv.getSrv().getVersion().isSetMicro()) { + // aal.setMicro(usrv.getSrv().getVersion().getMicro()); + // System.err.println(aal.getMicro()); + // } + // } + if (usrv.getSrv().isSetTags()) { aal.getTags().add(usrv.getSrv().getTags()); - System.err.println("Tags: "+aal.getTags()); + System.err.println("Tags: " + aal.getTags()); } - - System.err.println("SET LicenseWindow"); - LicenceWindow lw = null; - try { - lw = new LicenceWindow(UccUI.getInstance(), licenseList, aal); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - new UsrvInfoController(aal, lw, UccUI.getInstance()); + System.err.println("SET LicenseWindow"); + LicenceWindow lw = null; + try { + lw = new LicenceWindow(UccUI.getInstance(), licenseList, aal); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + new UsrvInfoController(aal, lw, UccUI.getInstance()); } return aal; } - - private String createUAPPLocation(String path, String newPath) { File pa = new File(path); File[] dirs = pa.listFiles(); - File rootFile = new File(usrvLocalStore +newPath); + File rootFile = new File(usrvLocalStore + newPath); rootFile.mkdir(); for (int i = 0; i < dirs.length; i++) { - File f = new File(usrvLocalStore + newPath +"/" + dirs[i].getName()); + File f = new File(usrvLocalStore + newPath + "/" + + dirs[i].getName()); System.err.println("Dir-Name: " + dirs[i].getName()); if (dirs[i].isDirectory()) { f.mkdir(); @@ -485,7 +557,7 @@ public class FrontendImpl implements IFrontend { dirs[i].renameTo(f); System.err.println(f.getAbsolutePath()); } - System.err.println("UAPP Path: "+usrvLocalStore + newPath); + System.err.println("UAPP Path: " + usrvLocalStore + newPath); return usrvLocalStore + newPath; } @@ -500,27 +572,33 @@ public class FrontendImpl implements IFrontend { // update the service registration IServiceManagement sm = Activator.getMgmt(); List<String> uappList = sm.getInstalledApps(serviceId); - if(uappList != null) { - System.err.println("Size of apps to uninstall: "+uappList.size()); - for (String del : uappList) { - System.err.println("Apps to delete: "+del); - InstallationResultsDetails result = - Activator.getDeinstaller().requestToUninstall(serviceId, del); - System.err.println("Uninstall Result: "+result); - if(result.getGlobalResult().toString().equals(InstallationResults.SUCCESS)) { - Activator.getReg().unregisterService(serviceId); - } else if(result.getGlobalResult().toString().equals(InstallationResults.MISSING_PEER)){ - NoConfigurationWindow nw = new NoConfigurationWindow(bundle.getString("uninstall.failure")+"<br>Error: Missing peer"); - UccUI.getInstance().getMainWindow().addWindow(nw); - } else { - NoConfigurationWindow nw = new NoConfigurationWindow(bundle.getString("uninstall.failure")); - UccUI.getInstance().getMainWindow().addWindow(nw); - } + if (uappList != null) { + System.err.println("Size of apps to uninstall: " + uappList.size()); + for (String del : uappList) { + System.err.println("Apps to delete: " + del); + InstallationResultsDetails result = Activator.getDeinstaller() + .requestToUninstall(serviceId, del); + System.err.println("Uninstall Result: " + result); + if (result.getGlobalResult().toString() + .equals(InstallationResults.SUCCESS)) { + Activator.getReg().unregisterService(serviceId); + } else if (result.getGlobalResult().toString() + .equals(InstallationResults.MISSING_PEER)) { + NoConfigurationWindow nw = new NoConfigurationWindow( + bundle.getString("uninstall.failure") + + "<br>Error: Missing peer"); + UccUI.getInstance().getMainWindow().addWindow(nw); + } else { + NoConfigurationWindow nw = new NoConfigurationWindow( + bundle.getString("uninstall.failure")); + UccUI.getInstance().getMainWindow().addWindow(nw); + } + } + } else { + NoConfigurationWindow nw = new NoConfigurationWindow( + bundle.getString("no.service")); + UccUI.getInstance().getMainWindow().addWindow(nw); } - } else { - NoConfigurationWindow nw = new NoConfigurationWindow(bundle.getString("no.service")); - UccUI.getInstance().getMainWindow().addWindow(nw); - } } @@ -618,15 +696,15 @@ public class FrontendImpl implements IFrontend { } public void startUCC() { - if(UccUI.getInstance() == null) { - System.err.println("UCC is null so not running"); - // Opens a browser window and loads the ucc site - Desktop desk = Desktop.getDesktop(); - try { - desk.browse(new URI("http://127.0.0.1:8080/ucc")); - } catch (Exception e) { - e.printStackTrace(); - } + if (UccUI.getInstance() == null) { + System.err.println("UCC is null so not running"); + // Opens a browser window and loads the ucc site + Desktop desk = Desktop.getDesktop(); + try { + desk.browse(new URI("http://127.0.0.1:8080/ucc")); + } catch (Exception e) { + e.printStackTrace(); + } } } } diff --git a/uCC/ucc.model/src/main/java/org/universAAL/ucc/model/AALService.java b/uCC/ucc.model/src/main/java/org/universAAL/ucc/model/AALService.java index 0d37cab143e820e0868564c324707db55460ba79..1c76cfe201e27fec0c0864c0ecaddc88db0ce2f4 100644 --- a/uCC/ucc.model/src/main/java/org/universAAL/ucc/model/AALService.java +++ b/uCC/ucc.model/src/main/java/org/universAAL/ucc/model/AALService.java @@ -13,13 +13,13 @@ public class AALService { private String provider = ""; private ArrayList<String> tags; private License licenses; - private ArrayList<UAPPPart> uaapList; + private ArrayList<UAPP> uaapList; private String ontologyUri; private String iconPath; public AALService() { tags = new ArrayList<String>(); - uaapList = new ArrayList<UAPPPart>(); + uaapList = new ArrayList<UAPP>(); } public AALService(String serviceId, int minor, int major, int micro, @@ -37,7 +37,7 @@ public class AALService { this.ontologyUri = ontologyUri; this.iconPath = iconPath; tags = new ArrayList<String>(); - uaapList = new ArrayList<UAPPPart>(); + uaapList = new ArrayList<UAPP>(); } public int getMinor() { @@ -104,11 +104,11 @@ public class AALService { this.provider = provider; } - public ArrayList<UAPPPart> getUaapList() { + public ArrayList<UAPP> getUaapList() { return uaapList; } - public void setUaapList(ArrayList<UAPPPart> uaapList) { + public void setUaapList(ArrayList<UAPP> uaapList) { this.uaapList = uaapList; }