001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.bookmarks.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    
023    import com.liferay.portlet.bookmarks.model.BookmarksFolder;
024    import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
025    
026    import java.util.ArrayList;
027    import java.util.List;
028    
029    /**
030     * The extended model base implementation for the BookmarksFolder service. Represents a row in the "BookmarksFolder" database table, with each column mapped to a property of this class.
031     *
032     * <p>
033     * This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BookmarksFolderImpl}.
034     * </p>
035     *
036     * @author Brian Wing Shun Chan
037     * @see BookmarksFolderImpl
038     * @see com.liferay.portlet.bookmarks.model.BookmarksFolder
039     * @generated
040     */
041    @ProviderType
042    public abstract class BookmarksFolderBaseImpl extends BookmarksFolderModelImpl
043            implements BookmarksFolder {
044            /*
045             * NOTE FOR DEVELOPERS:
046             *
047             * Never modify or reference this class directly. All methods that expect a bookmarks folder model instance should use the {@link BookmarksFolder} interface instead.
048             */
049            @Override
050            public void persist() {
051                    if (this.isNew()) {
052                            BookmarksFolderLocalServiceUtil.addBookmarksFolder(this);
053                    }
054                    else {
055                            BookmarksFolderLocalServiceUtil.updateBookmarksFolder(this);
056                    }
057            }
058    
059            @Override
060            @SuppressWarnings("unused")
061            public String buildTreePath() throws PortalException {
062                    List<BookmarksFolder> bookmarksFolders = new ArrayList<BookmarksFolder>();
063    
064                    BookmarksFolder bookmarksFolder = this;
065    
066                    while (bookmarksFolder != null) {
067                            bookmarksFolders.add(bookmarksFolder);
068    
069                            bookmarksFolder = BookmarksFolderLocalServiceUtil.fetchBookmarksFolder(bookmarksFolder.getParentFolderId());
070                    }
071    
072                    StringBundler sb = new StringBundler((bookmarksFolders.size() * 2) + 1);
073    
074                    sb.append(StringPool.SLASH);
075    
076                    for (int i = bookmarksFolders.size() - 1; i >= 0; i--) {
077                            bookmarksFolder = bookmarksFolders.get(i);
078    
079                            sb.append(bookmarksFolder.getFolderId());
080                            sb.append(StringPool.SLASH);
081                    }
082    
083                    return sb.toString();
084            }
085    
086            @Override
087            public void updateTreePath(String treePath) {
088                    BookmarksFolder bookmarksFolder = this;
089    
090                    bookmarksFolder.setTreePath(treePath);
091    
092                    BookmarksFolderLocalServiceUtil.updateBookmarksFolder(bookmarksFolder);
093            }
094    }