本文整理汇总了Java中com.liferay.portal.service.ServiceContext.setScopeGroupId方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceContext.setScopeGroupId方法的具体用法?Java ServiceContext.setScopeGroupId怎么用?Java ServiceContext.setScopeGroupId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.service.ServiceContext
的用法示例。
在下文中一共展示了ServiceContext.setScopeGroupId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCourse
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
@JSONWebService
public Course createCourse(long groupId,String title, String description,boolean published,String summary,int evaluationmethod,int calificationType,int template,int registermethod,int maxusers, Date startregistrationdate,Date endregistrationdate) throws PortalException, SystemException
{
User user=getUser();
java.util.Date ahora=new java.util.Date(System.currentTimeMillis());
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
serviceContext.setUserId(user.getUserId());
serviceContext.setScopeGroupId(groupId);
String groupName = GroupConstants.GUEST;
long companyId = PortalUtil.getDefaultCompanyId();
if( getPermissionChecker().hasPermission(groupId, "com.liferay.lms.coursemodel",groupId,"ADD_COURSE"))
{
Course course = com.liferay.lms.service.CourseLocalServiceUtil.addCourse(
title, description, summary, StringPool.BLANK,
user.getLocale(), ahora, startregistrationdate, endregistrationdate,template,registermethod,evaluationmethod,
calificationType,maxusers,serviceContext,false);
com.liferay.lms.service.CourseLocalServiceUtil.setVisible(course.getCourseId(), published);
return course;
}
else
{
return null;
}
}
示例2: importEntry
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
/**
* Llamamos a esta función con el nodo moduleentry del archivo portlet-dat.xml dentro de \groups\xxxx\portlets\courseadmin_WAR_liferaylmsportlet
* @param context todo el war
* @param entryElement elemento moduleentry
* @param entry modulo cogido del war, de momento contiene los ids antiguos
* @param hashLearningActivityType
* @param relationActivities
* @return
* @throws SystemException
* @throws PortalException
* @throws DocumentException
*/
private long importEntry(PortletDataContext context, Element entryElement, Module entry, HashMap<Long, Long> relationActivities, HashMap<Integer, LearningActivityType> hashLearningActivityType ) throws SystemException, PortalException {
long userId = context.getUserId(entry.getUserUuid());
ServiceContext serviceContext=new ServiceContext();
serviceContext.setUserId(userId);
serviceContext.setCompanyId(context.getCompanyId());
serviceContext.setScopeGroupId(context.getScopeGroupId());
//Cargamos los datos del contexto del curso actual, sobre el que vamos a importar
entry.setGroupId(context.getScopeGroupId());
entry.setUserId(userId);
entry.setCompanyId(context.getCompanyId());
//Para convertir < correctamente.
entry.setDescription(entry.getDescription().replace("&lt;", "<"));
log.info("entry companyId: " + entry.getCompanyId());
log.info("entry groupId: " +entry.getGroupId() );
log.info("entry userId: " +entry.getUserId() );
log.info("entry moduleId: " +entry.getModuleId() );
log.info("ENTRY ELEMENT-->"+entryElement);
//Creamos el nuevo módulo en el curso
Module newModule = ModuleLocalServiceUtil.addmodule(entry);
//Importamos las imagenes de los módulos
ModuleImport.importImageModule(context, entryElement, serviceContext, userId, newModule);
//Importamos los archivos de la descripción
ModuleImport.importDescriptionFile(context, entryElement, serviceContext, userId, newModule);
//Importamos las actividades
long newActId = 0;
LearningActivity larn = null;
String path = null;
for (Element actElement : entryElement.elements("learningactivity")) {
path = actElement.attributeValue("path");
larn=(LearningActivity)context.getZipEntryAsObject(path);
log.info("tipo a comprobar: " + larn.getTypeId());
if(hashLearningActivityType.containsKey(larn.getTypeId())){
log.info("actividad correcta: " + larn.getTypeId());
newActId = LearningActivityImport.importLearningActivity(context, entryElement, serviceContext, userId, newModule, actElement, larn);
//Comprobamos que podamos crear una actividad de ese tipo
relationActivities.put(larn.getActId(), newActId);
}else{
log.info("actividad incorrecta: " + larn.getTypeId());
throw new NoLearningActivityTypeActiveException("No existe el tipo de actividad: " + larn.getTypeId());
}
}
log.info("Fin importación de módulo: " + newModule.getModuleId());
return newModule.getModuleId();
}
示例3: importLearningActivity
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
/**
* Función para importar las actividades del módulo
* @param context
* @param entryElement elemento módulo
* @param serviceContext
* @param userId
* @param newModule módulo nuevo al que pertenecerá
* @param actElement elemento actividad
* @throws SystemException
* @throws PortalException
*/
public static long importLearningActivity(PortletDataContext context, Element entryElement, ServiceContext serviceContext, long userId, Module newModule, Element actElement, LearningActivity larn) throws SystemException, PortalException {
if(larn != null){
log.info("*********************ACTIVIDAD ID ANTIGUO: " + larn.getActId() + "**************************");
log.info("***************TIPO DE ACTIVIDAD: " + larn.getTypeId() + "**************************");
serviceContext.setAssetCategoryIds(context.getAssetCategoryIds(LearningActivity.class, larn.getActId()));
serviceContext.setAssetTagNames(context.getAssetTagNames(LearningActivity.class, larn.getActId()));
serviceContext.setUserId(userId);
serviceContext.setCompanyId(context.getCompanyId());
serviceContext.setScopeGroupId(context.getScopeGroupId());
larn.setGroupId(newModule.getGroupId());
larn.setModuleId(newModule.getModuleId());
LearningActivity newLarn=LearningActivityLocalServiceUtil.addLearningActivity(larn,serviceContext);
serviceContext.setScopeGroupId(newLarn.getGroupId());
//Para actividad de recurso externo
if(larn.getTypeId() == 2){
//changeExtraContentDocumentIds(newLarn, newModule, userId, context, serviceContext);
}
//Seteo de contenido propio de la actividad
log.debug("***IMPORT EXTRA CONTENT****");
LearningActivityType learningActivityType=new LearningActivityTypeRegistry().getLearningActivityType(larn.getTypeId());
String importExtraContentResult = null;
try {
importExtraContentResult = learningActivityType.importExtraContent(newLarn, userId, context, serviceContext, actElement);
} catch (Exception e) {
e.printStackTrace();
}
log.debug("++++ importExtraContentResult:"+importExtraContentResult);
log.debug("***FIN IMPORT EXTRA CONTENT****");
importDLFileEntries(newLarn, userId, context, serviceContext, actElement);
importDescriptionFileActivities(newLarn, userId, context, serviceContext, actElement);
importQuestions(newLarn, userId, context, serviceContext, actElement);
return newLarn.getActId();
}else{
return 0;
}
}
示例4: addArticle
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
public static JournalArticle addArticle(long userId, long groupId, String name, String title, String srcContent) {
JournalArticle result = null;
try {
Locale defLocale = LocaleUtil.getDefault();
if (defLocale == null)
defLocale = Locale.GERMAN;
String localShort = defLocale.getLanguage()+"_"+defLocale.getCountry();
Map<Locale, String> titleMap = new HashMap<Locale, String>();
titleMap.put(defLocale, title);
//titleMap.put(Locale.GERMAN, title);
//titleMap.put(Locale.ENGLISH, title);
ServiceContext ctx = new ServiceContext();
ctx.setScopeGroupId(groupId);
String content = "<?xml version=\"1.0\"?><root available-locales=\""+localShort+"\" default-locale=\""+localShort+"\"><static-content language-id=\""+localShort+"\"><![CDATA[ "+srcContent+" ]]></static-content></root>";
String lid = LocalizationUtil.getDefaultLocale(content);
Locale defaultLocale = LocaleUtil.fromLanguageId(lid);
m_objLog.debug("Adding title for locale "+defLocale+", short "+localShort+" with lid "+lid+" and defaultLocale "+defaultLocale+" with content "+title);
result = JournalArticleLocalServiceUtil.addArticle(
userId,
groupId,
0, // folder id
0, 0, //classNameId, classPK,
name, //articleId,
false, //autoArticleId,
JournalArticleConstants.VERSION_DEFAULT,
titleMap,
null, //descriptionMap,
content,
"general", // type,
null,
null, // templateId,
StringPool.BLANK, //layoutUuid,
1, 1, 1970, 0, 0, // displayDateMonth, displayDateDay, displayDateYear,
// displayDateHour, displayDateMinute,
0, 0, 0, 0, 0, true, // expirationDateMonth, expirationDateDay,
// expirationDateYear, expirationDateHour,
//expirationDateMinute, neverExpire,
0, 0, 0, 0, 0, true, // reviewDateMonth, reviewDateDay, reviewDateYear,
//reviewDateHour, reviewDateMinute, neverReview,
true, // indexable,
false, StringPool.BLANK, null, // smallImage, smallImageURL, smallImageFile,
null, StringPool.BLANK, // images, articleURL,
ctx
);
} catch (Throwable t) {
m_objLog.warn(t);
}
return result;
}
示例5: createOrganisationLogoFolder
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
public static void createOrganisationLogoFolder(long groupId, long userId) throws PortalException, SystemException {
final ServiceContext ctx = new ServiceContext();
ctx.setUserId(userId);
ctx.setScopeGroupId(groupId);
ctx.setAddGroupPermissions(true);
ctx.setAddGuestPermissions(true);
// ctx.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);
String orgFolder = getConfigValue(E_ConfigKey.ORGANISATION_LOGO_FOLDER);
Folder parent = null;
try {
parent = DLAppServiceUtil.getFolder(groupId, 0,
orgFolder);
} catch (final Throwable t) {
}
if (parent == null) {
parent = DLAppServiceUtil.addFolder(groupId, 0,
orgFolder, "", ctx);
m_objLog.info("Folder "
+ orgFolder
+ " created ....");
} else {
m_objLog.info("Folder "
+ orgFolder
+ " already existing ....");
}
final String[] actionids = new String[2];
final Role guestRole = RoleLocalServiceUtil.getRole(
PortalUtil.getDefaultCompanyId(), RoleConstants.GUEST);
actionids[0] = ActionKeys.VIEW;
actionids[1] = ActionKeys.ACCESS;
// actionids[2] = ActionKeys.ADD_FILE;
ResourcePermissionServiceUtil.setIndividualResourcePermissions(
parent.getGroupId(), parent.getCompanyId(),
DLFolder.class.getName(), parent.getFolderId() + "",
guestRole.getRoleId(), actionids);
}
示例6: createServiceContext
import com.liferay.portal.service.ServiceContext; //导入方法依赖的package包/类
/**
* Create a serviceContext with given arguments
* @param request
* @param className
* @param userId
* @param groupId
* @return
* @throws PortalException
* @throws SystemException
*/
private ServiceContext createServiceContext(ActionRequest request, String className, Long userId, Long groupId) throws PortalException, SystemException{
ServiceContext serviceContext = ServiceContextFactory.getInstance(className, request);
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
serviceContext.setUserId(userId);
serviceContext.setScopeGroupId(groupId);
return serviceContext;
}