@Override public void addAllPermanent(Collection<NamespaceProperties> properties) { this.clear(); for (NamespaceProperties nsp : properties) { this.setNamespaceProperties(nsp.getNamespace(), nsp); } }
@Override public NamespaceProperties getNamespaceProperties(String namespace) { String prefix = this.getPrefix(namespace); return new NamespaceProperties(namespace, prefix); }
@Override public void forceDelete(GenericId id) { FileUtils.forceDelete(this.id2AbsolutePath(id)); }
/** * This method is synchronized with an extra static object (meaning all instances are locked). The same lock object * is also used in {@link #addCommit(RepositoryFileReference)}. This is to ensure that every commit only has one * change. * * @param message The message that is used in the commit. * @throws GitAPIException thrown when anything with adding or committing goes wrong. */ public void addCommit(String message) throws GitAPIException { addCommit(new String[] {"."}, message); }
@Override public String getPrefix(String namespace) { return getNamespaceProperties(Objects.isNull(namespace) ? "" : namespace).getPrefix(); }
@Override public boolean flagAsExisting(GenericId id) { Path path = this.id2AbsolutePath(id); try { FileUtils.createDirectory(path); } catch (IOException e) { FilebasedRepository.LOGGER.debug(e.toString()); return false; } return true; }
@Override public void addAllPermanent(Collection<NamespaceProperties> properties) { properties.forEach(prop -> this.namespaceProperties.put(prop.getNamespace(), prop)); this.save(); }
@Override public boolean hasPermanentProperties(String namespace) { Map<String, NamespaceProperties> map = this.loadNamespacePropertiesFromFile(); return map.containsKey(namespace) && Objects.nonNull(map.get(namespace).getPrefix()) && !map.get(namespace).getPrefix().isEmpty(); }
@Override public void replaceAll(Map<String, NamespaceProperties> map) { this.namespaceProperties = map; this.save(); }
@Override public void rename(DefinitionsChildId oldId, DefinitionsChildId newId) throws IOException { this.duplicate(oldId, newId, true); }
@Override public <T extends DefinitionsChildId> SortedSet<T> getAllDefinitionsChildIds(Class<T> idClass) { return getDefinitionsChildIds(idClass, false); }
@Override public InputStream newInputStream(RepositoryFileReference ref) throws IOException { Path path = this.ref2AbsolutePath(ref); return Files.newInputStream(path); }
public static void reconfigure(GitBasedRepositoryConfiguration gitBasedRepositoryConfiguration) throws IOException, GitAPIException { RepositoryFactory.gitBasedRepositoryConfiguration = gitBasedRepositoryConfiguration; RepositoryFactory.fileBasedRepositoryConfiguration = null; RepositoryFactory.jCloudsConfiguration = null; repository = new GitBasedRepository(gitBasedRepositoryConfiguration); }
public static void reconfigure(FileBasedRepositoryConfiguration fileBasedRepositoryConfiguration) { RepositoryFactory.fileBasedRepositoryConfiguration = fileBasedRepositoryConfiguration; RepositoryFactory.gitBasedRepositoryConfiguration = null; RepositoryFactory.jCloudsConfiguration = null; repository = new FilebasedRepository(fileBasedRepositoryConfiguration); }
@Override public Collection<Namespace> getUsedNamespaces() { return getNamespaces(DefinitionsChildId.ALL_TOSCA_COMPONENT_ID_CLASSES); }
public void forceDelete(Class<? extends DefinitionsChildId> definitionsChildIdClazz, Namespace namespace) { // instantiate new definitions child id with "ID" as id // this is used to get the absolute path DefinitionsChildId id = BackendUtils.getDefinitionsChildId(definitionsChildIdClazz, namespace.getEncoded(), "ID", true); Path path = this.id2AbsolutePath(id); // do not delete the id, delete the complete namespace // patrent folder is the namespace folder path = path.getParent(); FileUtils.forceDelete(path); }
@Override public void removeNamespaceProperties(String namespace) { this.namespaceProperties.remove(namespace); this.save(); }
@Override public void duplicate(DefinitionsChildId from, DefinitionsChildId newId) throws IOException { this.duplicate(from, newId, false); }
public <T extends DefinitionsChildId> SortedSet<T> getStableDefinitionsChildIdsOnly(Class<T> idClass) { return getDefinitionsChildIds(idClass, true); }
@Override public FileTime getLastModifiedTime(RepositoryFileReference ref) throws IOException { Path path = this.ref2AbsolutePath(ref); return Files.getLastModifiedTime(path); }