Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11679 fixes problem creating pages #11693

Merged
merged 1 commit into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package com.dotmarketing.portlets.contentlet.ajax;

import static com.dotmarketing.business.PermissionAPI.PERMISSION_PUBLISH;
import static com.dotmarketing.business.PermissionAPI.PERMISSION_READ;
import static com.dotmarketing.business.PermissionAPI.PERMISSION_WRITE;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.dotcms.content.elasticsearch.util.ESUtils;
import com.dotcms.enterprise.FormAJAXProxy;
import com.dotcms.enterprise.LicenseUtil;
Expand All @@ -9,7 +27,6 @@
import com.dotmarketing.beans.Permission;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.CacheLocator;
import com.dotmarketing.business.DotCacheException;
import com.dotmarketing.business.DotStateException;
import com.dotmarketing.business.FactoryLocator;
import com.dotmarketing.business.PermissionAPI;
Expand Down Expand Up @@ -40,7 +57,6 @@
import com.dotmarketing.portlets.languagesmanager.model.LanguageKey;
import com.dotmarketing.portlets.structure.StructureUtil;
import com.dotmarketing.portlets.structure.factories.FieldFactory;

import com.dotmarketing.portlets.structure.model.Field;
import com.dotmarketing.portlets.structure.model.Field.FieldType;
import com.dotmarketing.portlets.structure.model.Relationship;
Expand All @@ -52,14 +68,14 @@
import com.dotmarketing.util.DateUtil;
import com.dotmarketing.util.InodeUtils;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PageRequestModeUtil;
import com.dotmarketing.util.PaginatedArrayList;
import com.dotmarketing.util.RegEX;
import com.dotmarketing.util.RegExMatch;
import com.dotmarketing.util.StringUtils;
import com.dotmarketing.util.UUIDGenerator;
import com.dotmarketing.util.UtilHTML;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.VelocityUtil;
import com.dotmarketing.util.WebKeys;
import com.dotmarketing.util.json.JSONArray;
import com.dotmarketing.util.json.JSONException;
Expand All @@ -72,24 +88,6 @@
import com.liferay.util.FileUtil;
import com.liferay.util.servlet.SessionMessages;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import static com.dotmarketing.business.PermissionAPI.PERMISSION_PUBLISH;
import static com.dotmarketing.business.PermissionAPI.PERMISSION_READ;
import static com.dotmarketing.business.PermissionAPI.PERMISSION_WRITE;

/**
* This class handles the communication between the view and the back-end
* service that returns information to the user regarding Contentlets in dotCMS.
Expand Down Expand Up @@ -1386,6 +1384,19 @@ public Map<String,Object> saveContent(List<String> formData, boolean isAutoSave,
if(contentlet.isHTMLPage()) {
HTMLPageAsset page = APILocator.getHTMLPageAssetAPI().fromContentlet(contentlet);
callbackData.put("htmlPageReferer", page.getURI() + "?" + WebKeys.HTMLPAGE_LANGUAGE + "=" + page.getLanguageId() + "&host_id=" + page.getHost());
HttpSession session = req.getSession();
boolean contentLocked = false;
boolean iCanLock = false;

try{
contentLocked = page.isLocked();
iCanLock = APILocator.getContentletAPI().canLock(contentlet, user);
}catch(DotLockException e){
iCanLock=false;
contentLocked = false;
}

PageRequestModeUtil.setBackEndModeInSession(req, contentLocked, iCanLock);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.dotmarketing.util.ActivityLogger;
import com.dotmarketing.util.HostUtil;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PageRequestModeUtil;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.WebKeys;
import com.liferay.portal.language.LanguageUtil;
Expand Down Expand Up @@ -86,17 +87,7 @@ public void processAction(ActionMapping mapping, ActionForm form, PortletConfig
HttpServletRequest hreq = reqImpl.getHttpServletRequest();

// gets the session object for the messages
HttpSession session = hreq.getSession();
if(contentLocked && iCanLock){
session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, "true");
session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
session.setAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION, "true");
}
else{
session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, "true");
session.setAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION, "true");
}
PageRequestModeUtil.setBackEndModeInSession(hreq, contentLocked, iCanLock);

IHTMLPage htmlPage = _previewHTMLPages(req, user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,24 @@ public static boolean isLive( HttpServletRequest request ){
return !( isAdminMode(session) && (isEditMode(session) || isPreviewMode(session)));
}

/**
* Activate the Edit or preview mode in session depending of the content state
* @param request Http request
* @param contentLocked boolean is the content locked
* @param canLock boolean can the user loc the content
*/
public static void setBackEndModeInSession( HttpServletRequest request, boolean contentLocked, boolean canLock ){
HttpSession session = request.getSession(false);
if(contentLocked && canLock){
session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, "true");
session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
session.setAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION, "true");
}else{
session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, "true");
session.setAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION, "true");
}
}


}