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.documentlibrary.context;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
021    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
022    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
023    
024    import java.util.UUID;
025    
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Iv??n Zaera
031     */
032    public class BaseDLEditFileEntryDisplayContext
033            extends BaseDLDisplayContext<DLEditFileEntryDisplayContext>
034            implements DLEditFileEntryDisplayContext {
035    
036            public BaseDLEditFileEntryDisplayContext(
037                    UUID uuid,
038                    DLEditFileEntryDisplayContext parentDLEditFileEntryDisplayContext,
039                    HttpServletRequest request, HttpServletResponse response,
040                    DLFileEntryType dlFileEntryType) {
041    
042                    super(uuid, parentDLEditFileEntryDisplayContext, request, response);
043    
044                    this.dlFileEntryType = dlFileEntryType;
045            }
046    
047            public BaseDLEditFileEntryDisplayContext(
048                    UUID uuid,
049                    DLEditFileEntryDisplayContext parentDLEditFileEntryDisplayContext,
050                    HttpServletRequest request, HttpServletResponse response,
051                    FileEntry fileEntry) {
052    
053                    super(uuid, parentDLEditFileEntryDisplayContext, request, response);
054    
055                    this.fileEntry = fileEntry;
056    
057                    if (fileEntry.getModel() instanceof DLFileEntry) {
058                            DLFileEntry dlFileEntry = (DLFileEntry)fileEntry.getModel();
059    
060                            try {
061                                    this.dlFileEntryType = dlFileEntry.getDLFileEntryType();
062                            }
063                            catch (PortalException pe) {
064                                    throw new SystemException(pe);
065                            }
066                    }
067            }
068    
069            @Override
070            public long getMaximumUploadSize() throws PortalException {
071                    return parentDLDisplayContext.getMaximumUploadSize();
072            }
073    
074            @Override
075            public String getPublishButtonLabel() throws PortalException {
076                    return parentDLDisplayContext.getPublishButtonLabel();
077            }
078    
079            @Override
080            public String getSaveButtonLabel() throws PortalException {
081                    return parentDLDisplayContext.getSaveButtonLabel();
082            }
083    
084            @Override
085            public boolean isCancelCheckoutDocumentButtonDisabled()
086                    throws PortalException {
087    
088                    return parentDLDisplayContext.isCancelCheckoutDocumentButtonDisabled();
089            }
090    
091            @Override
092            public boolean isCancelCheckoutDocumentButtonVisible()
093                    throws PortalException {
094    
095                    return parentDLDisplayContext.isCancelCheckoutDocumentButtonVisible();
096            }
097    
098            @Override
099            public boolean isCheckinButtonDisabled() throws PortalException {
100                    return parentDLDisplayContext.isCheckinButtonDisabled();
101            }
102    
103            @Override
104            public boolean isCheckinButtonVisible() throws PortalException {
105                    return parentDLDisplayContext.isCheckinButtonVisible();
106            }
107    
108            @Override
109            public boolean isCheckoutDocumentButtonDisabled() throws PortalException {
110                    return parentDLDisplayContext.isCheckoutDocumentButtonDisabled();
111            }
112    
113            @Override
114            public boolean isCheckoutDocumentButtonVisible() throws PortalException {
115                    return parentDLDisplayContext.isCheckoutDocumentButtonVisible();
116            }
117    
118            @Override
119            public boolean isDDMStructureVisible(DDMStructure ddmStructure)
120                    throws PortalException {
121    
122                    return parentDLDisplayContext.isDDMStructureVisible(ddmStructure);
123            }
124    
125            @Override
126            public boolean isPublishButtonDisabled() throws PortalException {
127                    return parentDLDisplayContext.isPublishButtonDisabled();
128            }
129    
130            @Override
131            public boolean isPublishButtonVisible() throws PortalException {
132                    return parentDLDisplayContext.isPublishButtonVisible();
133            }
134    
135            @Override
136            public boolean isSaveButtonDisabled() throws PortalException {
137                    return parentDLDisplayContext.isSaveButtonDisabled();
138            }
139    
140            @Override
141            public boolean isSaveButtonVisible() throws PortalException {
142                    return parentDLDisplayContext.isSaveButtonVisible();
143            }
144    
145            protected DLFileEntryType dlFileEntryType;
146            protected FileEntry fileEntry;
147    
148    }