<commit_before>/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.slc.sli.headerfooter.service.impl;

import java.io.IOException;
import java.util.List;

import org.slc.sli.headerfooter.model.HeaderFooter;
import org.slc.sli.headerfooter.model.impl.HeaderFooterImpl;
import org.slc.sli.headerfooter.service.base.HeaderFooterLocalServiceBaseImpl;
import org.slc.sli.login.json.bean.UserData;
import org.slc.sli.util.Constants;
import org.slc.sli.util.RolesUtil;
import org.slc.sli.util.PropsKeys;
import org.slc.sli.util.ServerUtil;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.Validator;

/**
 * The implementation of the header footer local service.
 * 
 * <p>
 * All custom service methods should be put in this class. Whenever methods are
 * added, rerun ServiceBuilder to copy their definitions into the
 * {@link org.slc.sli.headerfooter.service.HeaderFooterLocalService} interface.
 * 
 * <p>
 * This is a local service. Methods of this service will not have security
 * checks based on the propagated JAAS credentials because this service can only
 * be accessed from within the same VM.
 * </p>
 * 
 * @author manoj
 * @see org.slc.sli.headerfooter.service.base.HeaderFooterLocalServiceBaseImpl
 * @see org.slc.sli.headerfooter.service.HeaderFooterLocalServiceUtil
 */
public class HeaderFooterLocalServiceImpl extends
		HeaderFooterLocalServiceBaseImpl {
	/*
	 * NOTE FOR DEVELOPERS:
	 * 
	 * Never reference this interface directly. Always use {@link
	 * org.slc.sli.headerfooter.service.HeaderFooterLocalServiceUtil} to access
	 * the header footer local service.
	 */

	protected boolean isAdmin(UserData userdata) {
		boolean isAdmin = false;
		String[] SLI_ROLE_ADMINISTRATOR = PropsUtil
				.getArray(PropsKeys.SLI_ROLE_ADMINISTRATOR);

		if (Validator.isNotNull(userdata)) {
			String[] granted_authorities = userdata.getGranted_authorities();
			for (String role : granted_authorities) {
				for (String admin : SLI_ROLE_ADMINISTRATOR) {
					if(role.equalsIgnoreCase(admin)){
						isAdmin = true;
						break;
					}
				}
			}
		}
		return isAdmin;
	}

	protected String getFullName(UserData userdata) {
		return userdata.getFull_name();
	}

	public HeaderFooter addHeader(String headerData) throws SystemException,
			PortalException {

		HeaderFooter header = headerFooterPersistence
				.create(counterLocalService.increment());

		header.setType("header");
		header.setData(headerData);

		return headerFooterPersistence.update(header, false);
	}

	public HeaderFooter editHeader(long id, String headerData)
			throws SystemException, PortalException {

		HeaderFooter header = new HeaderFooterImpl();

		header.setId(id);<commit_msg>DE896: Portal throws NullPointException when a user logout.<commit_after>/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.slc.sli.headerfooter.service.impl;

import java.io.IOException;
import java.util.List;

import org.slc.sli.headerfooter.model.HeaderFooter;
import org.slc.sli.headerfooter.model.impl.HeaderFooterImpl;
import org.slc.sli.headerfooter.service.base.HeaderFooterLocalServiceBaseImpl;
import org.slc.sli.login.json.bean.UserData;
import org.slc.sli.util.Constants;
import org.slc.sli.util.RolesUtil;
import org.slc.sli.util.PropsKeys;
import org.slc.sli.util.ServerUtil;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.Validator;

/**
 * The implementation of the header footer local service.
 * 
 * <p>
 * All custom service methods should be put in this class. Whenever methods are
 * added, rerun ServiceBuilder to copy their definitions into the
 * {@link org.slc.sli.headerfooter.service.HeaderFooterLocalService} interface.
 * 
 * <p>
 * This is a local service. Methods of this service will not have security
 * checks based on the propagated JAAS credentials because this service can only
 * be accessed from within the same VM.
 * </p>
 * 
 * @author manoj
 * @see org.slc.sli.headerfooter.service.base.HeaderFooterLocalServiceBaseImpl
 * @see org.slc.sli.headerfooter.service.HeaderFooterLocalServiceUtil
 */
public class HeaderFooterLocalServiceImpl extends
		HeaderFooterLocalServiceBaseImpl {
	/*
	 * NOTE FOR DEVELOPERS:
	 * 
	 * Never reference this interface directly. Always use {@link
	 * org.slc.sli.headerfooter.service.HeaderFooterLocalServiceUtil} to access
	 * the header footer local service.
	 */

	protected boolean isAdmin(UserData userdata) {
		boolean isAdmin = false;
		String[] SLI_ROLE_ADMINISTRATOR = PropsUtil
				.getArray(PropsKeys.SLI_ROLE_ADMINISTRATOR);

		if (Validator.isNotNull(userdata)) {
			String[] granted_authorities = userdata.getGranted_authorities();
			if( granted_authorities != null ) {
				for (String role : granted_authorities) {
					for (String admin : SLI_ROLE_ADMINISTRATOR) {
						if(role.equalsIgnoreCase(admin)){
							isAdmin = true;
							break;
						}
					}
				}
			}
		}
		return isAdmin;
	}

	protected String getFullName(UserData userdata) {
		return userdata.getFull_name();
	}

	public HeaderFooter addHeader(String headerData) throws SystemException,
			PortalException {

		HeaderFooter header = headerFooterPersistence
				.create(counterLocalService.increment());

		header.setType("header");
		header.setData(headerData);

		return headerFooterPersistence.update(header, false);
	}

	public HeaderFooter editHeader(long id, String headerData)
			throws SystemException, PortalException {

		HeaderFooter header = new HeaderFooterImpl();

		header.setId(id);
{'fraction_non_alphanumeric': 0.08884529147982063, 'fraction_numerical': 0.0032230941704035876, 'mean_word_length': 4.481566820276497, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5137429', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2131, 'n_words': 589}