private IIDesc loadIIDesc(String path) throws IOException { ResourceStore store = getStore(); logger.info("Loading IIDesc " + store.getReadableResourcePath(path)); IIDesc ndesc = store.getResource(path, IIDesc.class, II_DESC_SERIALIZER); if (StringUtils.isBlank(ndesc.getName())) { throw new IllegalStateException("IIDesc name must not be blank"); } ndesc.init(getMetadataManager()); return ndesc; }
/** * Create a new IIDesc * * @param iiDesc * @return * @throws IOException */ public IIDesc createIIDesc(IIDesc iiDesc) throws IOException { if (iiDesc.getUuid() == null || iiDesc.getName() == null) throw new IllegalArgumentException(); if (iiDescMap.containsKey(iiDesc.getName())) throw new IllegalArgumentException("IIDesc '" + iiDesc.getName() + "' already exists"); iiDesc.init(getMetadataManager()); // Check base validation // Semantic validation // TODO iiDesc.setSignature(iiDesc.calculateSignature()); String path = iiDesc.getResourcePath(); getStore().putResource(path, iiDesc, II_DESC_SERIALIZER); iiDescMap.put(iiDesc.getName(), iiDesc); return iiDesc; }
/** * Update IIDesc with the input. Broadcast the event into cluster * * @param desc * @return * @throws IOException */ public IIDesc updateIIDesc(IIDesc desc) throws IOException { // Validate IIDesc if (desc.getUuid() == null || desc.getName() == null) { throw new IllegalArgumentException(); } String name = desc.getName(); if (!iiDescMap.containsKey(name)) { throw new IllegalArgumentException("IIDesc '" + name + "' does not exist."); } desc.init(getMetadataManager()); // TODO: Semantic validation desc.setSignature(desc.calculateSignature()); // Save Source String path = desc.getResourcePath(); getStore().putResource(path, desc, II_DESC_SERIALIZER); // Reload the IIDesc IIDesc ndesc = loadIIDesc(path); // Here replace the old one iiDescMap.put(ndesc.getName(), desc); return ndesc; }
private IIDesc loadIIDesc(String path) throws IOException { ResourceStore store = getStore(); logger.info("Loading IIDesc " + store.getReadableResourcePath(path)); IIDesc ndesc = store.getResource(path, IIDesc.class, II_DESC_SERIALIZER); if (StringUtils.isBlank(ndesc.getName())) { throw new IllegalStateException("IIDesc name must not be blank"); } ndesc.init(getMetadataManager()); return ndesc; }
/** * Create a new IIDesc * * @param iiDesc * @return * @throws IOException */ public IIDesc createIIDesc(IIDesc iiDesc) throws IOException { if (iiDesc.getUuid() == null || iiDesc.getName() == null) throw new IllegalArgumentException(); if (iiDescMap.containsKey(iiDesc.getName())) throw new IllegalArgumentException("IIDesc '" + iiDesc.getName() + "' already exists"); iiDesc.init(getMetadataManager()); // Check base validation // Semantic validation // TODO iiDesc.setSignature(iiDesc.calculateSignature()); String path = iiDesc.getResourcePath(); getStore().putResource(path, iiDesc, II_DESC_SERIALIZER); iiDescMap.put(iiDesc.getName(), iiDesc); return iiDesc; }
/** * Update IIDesc with the input. Broadcast the event into cluster * * @param desc * @return * @throws IOException */ public IIDesc updateIIDesc(IIDesc desc) throws IOException { // Validate IIDesc if (desc.getUuid() == null || desc.getName() == null) { throw new IllegalArgumentException(); } String name = desc.getName(); if (!iiDescMap.containsKey(name)) { throw new IllegalArgumentException("IIDesc '" + name + "' does not exist."); } desc.init(getMetadataManager()); // TODO: Semantic validation desc.setSignature(desc.calculateSignature()); // Save Source String path = desc.getResourcePath(); getStore().putResource(path, desc, II_DESC_SERIALIZER); // Reload the IIDesc IIDesc ndesc = loadIIDesc(path); // Here replace the old one iiDescMap.put(ndesc.getName(), desc); return ndesc; }