Java tutorial
/* *Copyright 2016 Dominik Szalai (emptulik@gmail.com) * *Licensed under the Apache License, Version 2.0 (the "License"); *you may not use this file except in compliance with the License. *You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *Unless required by applicable law or agreed to in writing, software *distributed under the License is distributed on an "AS IS" BASIS, *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *See the License for the specific language governing permissions and *limitations under the License. */ /* * Copyright 2016 Dominik Szalai (emptulik@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cz.muni.fi.editor.services.api.cmis; import lombok.extern.log4j.Log4j2; import org.apache.chemistry.opencmis.client.api.FileableCmisObject; import org.apache.chemistry.opencmis.client.api.Tree; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @author Dominik Szalai - emptulik at gmail.com on 24.05.2016. */ @Component @Log4j2 public class RepoTreeServiceImpl implements RepoTreeService { @Autowired private CMISProxy cmisProxy; @Override public List<RepoTreeEntry> generateTree() { return new ArrayList<>(cmisProxy.getSession().getRootFolder().getFolderTree(-1).stream().map(this::realWalk) .collect(Collectors.toList())); } @Override public List<RepoTreeEntry> getTreeForPath(String repo, String path, int depth) { return null; } private RepoTreeEntry realWalk(Tree<FileableCmisObject> tree) { List<RepoTreeEntry> children = new ArrayList<>(); RepoTreeEntry thisEntry = new RepoTreeEntry(); thisEntry.setPath(tree.getItem().getPaths().get(0)); thisEntry.setText(tree.getItem().getName()); thisEntry.setId(tree.getItem().getId()); children.addAll(tree.getChildren().stream().map(this::realWalk).collect(Collectors.toList())); thisEntry.setChildren(children); return thisEntry; } }