/** * Edits the container and all of the children containers. * * @pre parameters != null * @pre canEditContainer( newContainer ) == true * @post if( checkCanEdit(container) ) { edit(container); } * @param oldContainer The original container * @param newContainer The new container values * @throws IllegalArgumentException if oldContainer == null or newContainer == null or * newContainer.canEdit == false */ public void editContainer(Container oldContainer, Container newContainer) throws IllegalArgumentException { if (oldContainer == null || newContainer == null || !canEditContainer(newContainer)) { throw new IllegalArgumentException(); } System.out.println(" ------ Editing container --------"); System.out.println("Before: " + oldContainer + "\nAfter:" + newContainer + ""); if (oldContainer instanceof ProductGroup) { Container parent = oldContainer.getContainer(); // added for bug fix parent.getProductGroups().remove((ProductGroup) oldContainer); oldContainer.setName(newContainer.getName()); ((ProductGroup) oldContainer) .setThreeMonthSupply(((ProductGroup) newContainer).getThreeMonthSupply()); parent.getProductGroups().add((ProductGroup) oldContainer); } else { storageUnits.remove(oldContainer); oldContainer.setName(newContainer.getName()); storageUnits.add((StorageUnit) oldContainer); // added for bug fix } containerDAO.update(new ContainerDTO(oldContainer)); ChangeObject hint = getHintObject(oldContainer); setChanged(); notifyObservers(hint); }
/** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged */ protected void log(String message) { Logger logger = null; if (container != null) logger = container.getLogger(); if (logger != null) logger.log("StandardPipeline[" + container.getName() + "]: " + message); else System.out.println("StandardPipeline[" + container.getName() + "]: " + message); }
/** * Create an <code>ObjectName</code> for this <code>Manager</code> object. * * @param domain Domain in which this name is to be created * @param manager The Manager to be named * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Manager manager) throws MalformedObjectNameException { ObjectName name = null; Container container = manager.getContainer(); if (container instanceof Engine) { name = new ObjectName(domain + ":type=Manager"); } else if (container instanceof Host) { name = new ObjectName(domain + ":type=Manager,host=" + container.getName()); } else if (container instanceof Context) { String path = ((Context) container).getPath(); if (path.length() < 1) { path = "/"; } Host host = (Host) container.getParent(); name = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + host.getName()); } else if (container == null) { DefaultContext defaultContext = manager.getDefaultContext(); if (defaultContext != null) { Container parent = defaultContext.getParent(); if (parent instanceof Engine) { name = new ObjectName(domain + ":type=DefaultManager"); } else if (parent instanceof Host) { name = new ObjectName(domain + ":type=DefaultManager,host=" + parent.getName()); } } } return (name); }
/** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged * @param throwable Associated exception */ protected void log(String message, Throwable throwable) { Logger logger = null; if (container != null) logger = container.getLogger(); if (logger != null) logger.log("StandardPipeline[" + container.getName() + "]: " + message, throwable); else { System.out.println("StandardPipeline[" + container.getName() + "]: " + message); throwable.printStackTrace(System.out); } }
/** * Abstract Method, Checks to see if given productsName is unique among the list of ProductGroups. * * @pre container != null * @param groupName String name in question * @return True if all of the qualifications are met and false otherwise. */ private boolean isUniqueProductGroupName(Container container) { assert container != null; if (container.getName() == null) { return false; } for (ProductGroup productGroup : container.getContainer().getProductGroups()) { if (container.getName().equals(productGroup.getName())) { return false; } } return true; }
/** Recursively save all child elements and then call ObjBase to save itself. */ @Override public synchronized boolean save(ClothoConnection conn) { System.out.println("============ Starting plate save of " + getUUID()); if (!isChanged()) { System.out.println("Collection didn't require saving"); return true; } if (Collector.isLocal(this._plateDatum._authorUUID)) { if (!getAuthor().saveDefault()) { return false; } } if (!Collector.getCurrentUser().getUUID().equals(this.getAuthor().getUUID())) { if (!Collector.getCurrentUser().isAdmin()) { System.out.println( "Current user " + this.getAuthor().getDisplayName() + " does not have permission to modify " + this.getName()); return false; } } if (!super.save(conn)) { return false; } for (int row = 0; row < getNumRows(); row++) { for (int col = 0; col < getNumCols(); col++) { String containerref = this.getContainerRefAt(row, col); if (!Collector.isLocal(containerref)) { continue; } Container acon = Collector.getContainer(containerref); System.out.println("plate about to save " + acon.getName()); System.out.println(acon.getUUID()); System.out.println(acon.getName()); System.out.println(acon.getDateCreated()); System.out.println(acon.getLastModified()); System.out.println(acon.getRowAsInt()); System.out.println(acon.getCol()); System.out.println(acon.getBarcode()); System.out.println(acon.isFixed()); System.out.println(acon.getPlateLink()); if (!acon.save(conn)) { return false; } } } return true; }
protected void postShowContainer(Container c) { if ("Main".equals(c.getName())) { postContainerMain(c); aboutToShowThisContainer = null; return; } }
protected void beforeShowContainer(Container c) { aboutToShowThisContainer = c; if ("Main".equals(c.getName())) { beforeContainerMain(c); aboutToShowThisContainer = null; return; } }
/** * Compares storage name with Set<StorageUnit> for uniqueness. * * @pre container != null * @param container * @return boolean true if container.name == Unique, otherwise false. */ private boolean isUniqueStorageUnitName(Container container) { assert container != null; for (StorageUnit storageUnit : storageUnits) { if (container.getName().equals(storageUnit.getName())) { return false; } } return true; }
public Container getContainerWithName(String name) { for (Container container : getContainers()) { if (container.getName().equals(name)) { return container; } } return null; }
/** * Create an <code>ObjectName</code> for this <code>Valve</code> object. * * @param domain Domain in which this name is to be created * @param valve The Valve to be named * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, GlassFishValve valve) throws MalformedObjectNameException { if (valve instanceof ValveBase) { ObjectName name = ((ValveBase) valve).getObjectName(); if (name != null) return name; } ObjectName name = null; Container container = null; String className = valve.getClass().getName(); int period = className.lastIndexOf('.'); if (period >= 0) className = className.substring(period + 1); if (valve instanceof Contained) { container = ((Contained) valve).getContainer(); } if (container == null) { throw new MalformedObjectNameException( "Cannot create mbean for non-contained valve " + valve); } if (container instanceof Engine) { String local = ""; int seq = getSeq(local); String ext = ""; if (seq > 0) { ext = ",seq=" + seq; } name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local); } else if (container instanceof Host) { String local = ",host=" + container.getName(); int seq = getSeq(local); String ext = ""; if (seq > 0) { ext = ",seq=" + seq; } name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local); } else if (container instanceof Context) { String path = ((Context) container).getPath(); if (path.length() < 1) { path = "/"; } Host host = (Host) container.getParent(); String local = ",path=" + path + ",host=" + host.getName(); int seq = getSeq(local); String ext = ""; if (seq > 0) { ext = ",seq=" + seq; } name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local); } return (name); }
/** * Log a message on the Logger associated with our Container (if any) * * @param message Message to be logged */ protected void log(String message) { Logger logger = null; String name = null; if (container != null) { logger = container.getLogger(); name = container.getName(); } if (logger != null) { logger.log(getName() + "[" + name + "]: " + message); } else { System.out.println(getName() + "[" + name + "]: " + message); } }
/** * Logs the given message to the Logger associated with the Container (if any) of this * StandardPipeline. * * @param message the message * @param t the Throwable */ protected void log(String message, Throwable t) { org.apache.catalina.Logger logger = null; if (container != null) { logger = container.getLogger(); String msg = MessageFormat.format( rb.getString(STANDARD_PIPELINE_INFO), new Object[] {container.getName(), message}); if (logger != null) { logger.log(msg, t, org.apache.catalina.Logger.WARNING); } else { log.log(Level.WARNING, msg, t); } } else { String msg = MessageFormat.format(rb.getString(STANDARD_PIPELINE_NULL_INFO), message); log.log(Level.WARNING, msg, t); // INFO set to WARNING } }
/** * Create an <code>ObjectName</code> for this <code>Realm</code> object. * * @param domain Domain in which this name is to be created * @param realm The Realm to be named * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Realm realm) throws MalformedObjectNameException { ObjectName name = null; Container container = realm.getContainer(); if (container instanceof Engine) { name = new ObjectName(domain + ":type=Realm"); } else if (container instanceof Host) { name = new ObjectName(domain + ":type=Realm,host=" + container.getName()); } else if (container instanceof Context) { String path = ((Context) container).getPath(); if (path.length() < 1) { path = "/"; } Host host = (Host) container.getParent(); name = new ObjectName(domain + ":type=Realm,path=" + path + ",host=" + host.getName()); } return (name); }
protected void handleComponentAction(Component c, ActionEvent event) { Container rootContainerAncestor = getRootAncestor(c); if (rootContainerAncestor == null) return; String rootContainerName = rootContainerAncestor.getName(); if (c.getParent().getLeadParent() != null) { c = c.getParent().getLeadParent(); } if (rootContainerName == null) return; if (rootContainerName.equals("Main")) { if ("TextArea".equals(c.getName())) { onMain_TextAreaAction(c, event); return; } if ("MultiButton".equals(c.getName())) { onMain_MultiButtonAction(c, event); return; } if ("Button".equals(c.getName())) { onMain_ButtonAction(c, event); return; } if ("MultiButton2".equals(c.getName())) { onMain_MultiButton2Action(c, event); return; } if ("MultiButton4".equals(c.getName())) { onMain_MultiButton4Action(c, event); return; } if ("MultiButton1".equals(c.getName())) { onMain_MultiButton1Action(c, event); return; } if ("MultiButton3".equals(c.getName())) { onMain_MultiButton3Action(c, event); return; } } }
@Test public void testParsePodList() throws Exception { KubernetesList podList = assertParseExampleFile("pod-list.json", KubernetesList.class); List<HasMetadata> items = podList.getItems(); assertNotEmpty("items", items); Pod pod = (Pod) items.get(0); assertNotNull("pod1", pod); assertEquals("pod1.name", "my-pod-1", KubernetesHelper.getName(pod)); PodSpec podSpec = pod.getSpec(); assertNotNull("pod1.podSpec", podSpec); List<Container> containers = podSpec.getContainers(); assertNotEmpty("pod1.podSpec.containers", containers); Container container = containers.get(0); assertNotNull("pod1.podSpec.container[0]", container); assertEquals("pod1.podSpec.container[0].name", "nginx", container.getName()); assertEquals("pod1.podSpec.container[0].image", "dockerfile/nginx", container.getImage()); LOG.info("pod1 container1 " + container); String json = KubernetesHelper.toJson(podList); LOG.info("Got JSON: " + json); }
/** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged */ protected void log(String message) { org.apache.catalina.Logger logger = null; if (container != null) { logger = container.getLogger(); String msg = MessageFormat.format( rb.getString(STANDARD_PIPELINE_INFO), new Object[] {container.getName(), message}); if (logger != null) { logger.log(msg); } else { if (log.isLoggable(Level.INFO)) { log.log(Level.INFO, msg); } } } else { if (log.isLoggable(Level.INFO)) { String msg = MessageFormat.format(rb.getString(STANDARD_PIPELINE_NULL_INFO), message); log.log(Level.INFO, msg); } } }