Java 类com.liferay.portal.kernel.util.WebKeys 实例源码

项目:flashlight-search    文件:FolderSearchFacetDisplayHandler.java   
@Override
public String displayTerm(HttpServletRequest request, FacetConfiguration facetConfiguration, String queryTerm) {
    String folderName = queryTerm;
    if ("0".equals(queryTerm)) {
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        Locale locale = themeDisplay.getLocale();
        folderName = language.get(locale, "root-folder");
    } else {
        Indexer<?> indexer = FolderSearcher.getInstance();
        SearchContext searchContext = SearchContextFactory.getInstance(request);
        searchContext.setFolderIds(new long[]{Long.parseLong(queryTerm)});
        searchContext.setKeywords(StringPool.BLANK);
        try {
            Hits results = indexer.search(searchContext);
            if (results.getLength() > 0) {
                Document document = results.doc(0);
                Field title = document.getField(Field.TITLE);
                folderName = title.getValue();
            }
        } catch (SearchException e) {
            LOG.warn("Could not retrieve folder name from id [" + queryTerm + "]", e);
        }
    }
    return folderName;
}
项目:flashlight-search    文件:SearchUrlAction.java   
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    Layout currentLayout = themeDisplay.getLayout();


    List<Layout> searchLayouts = this.getSearchLayouts(currentLayout);
    Map<Layout, List<SearchUrl>> searchUrls;

    searchUrls = searchLayouts.stream()
        .collect(Collectors.toMap(
            Function.identity(),
            layout -> generateSearchUrl(request, themeDisplay, layout)
        ));

    request.setAttribute(REQUEST_ATTR_FLASHLIGHT_URLS, new SearchUrlContainer(searchUrls));
}
项目:flashlight-search    文件:TemplatedPortlet.java   
/**
 * Renders an ADT.
 *
 * @param request the request
 * @param response the response
 * @param templateCtx the template context
 * @param templateUUID the UUID of the ADT (DDMTemplate object/table) to render
 * @throws TemplateNotFoundException if no template having such UUID could be found
 * @throws CouldNotRenderTemplateException if the template could not be rendered
 */
public void renderADT(RenderRequest request, RenderResponse response, Map<String, Object> templateCtx, String templateUUID) throws CouldNotRenderTemplateException, TemplateNotFoundException {
    HttpServletRequest httpServletRequest = this.portal.getHttpServletRequest(request);
    HttpServletResponse httpServletResponse = this.portal.getHttpServletResponse(response);
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long companyId = themeDisplay.getCompanyId();

    try {
        List<DDMTemplate> ddmTemplates = this.getDDMTemplateLocalService().getDDMTemplatesByUuidAndCompanyId(templateUUID, companyId);
        if (ddmTemplates.isEmpty()) {
            throw new TemplateNotFoundException("No ADT found with companyId ["+companyId+"] and UUID ["+templateUUID+"]");
        }
        String renderedTemplate = this.getPortletDisplayTemplate().renderDDMTemplate(httpServletRequest, httpServletResponse, ddmTemplates.get(0), Collections.emptyList(), templateCtx);
        response.getWriter().write(renderedTemplate);
    } catch (Exception e) {
        throw new CouldNotRenderTemplateException("Could not render from ADT [" + templateUUID + "]", e);
    }
}
项目:liferay-gsearch    文件:GSearchImpl.java   
/**
 * Get searchcontext.
 * 
 * @return searchcontext object
 * @throws Exception 
 */
protected SearchContext getSearchContext() throws Exception {

    ThemeDisplay themeDisplay =
        (ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContext searchContext = new SearchContext();
    searchContext.setCompanyId(themeDisplay.getCompanyId());
    searchContext.setStart(_queryParams.getStart());
    searchContext.setEnd(_queryParams.getEnd());
    searchContext.setSorts(_queryParams.getSorts());

    // Set facets.

    _facetsBuilder.setFacets(searchContext);

    return searchContext;
}
项目:liferay-gsearch    文件:QueryParamsBuilderImpl.java   
/**
 * Set groups parameter.
 */
protected void setGroupsParam() {

    ThemeDisplay themeDisplay =
        (ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String scopeFilter =
        ParamUtil.getString(_portletRequest, GSearchWebKeys.FILTER_SCOPE);

    long[] groupIds;

    if ("this-site".equals(scopeFilter)) {
        groupIds = new long[] {
            themeDisplay.getScopeGroupId()
        };
    }
    else {
        groupIds = new long[] {};
    }
    _queryParams.setGroupIds(groupIds);
}
项目:liferay-gsearch    文件:GSearchUtil.java   
/**
 * Get layout by friendlyurl.
 * 
 * @param resourceRequest
 * @return layout
 * @throws PortalException if layout is not found
 */
public static Layout getLayoutByFriendlyURL(
    PortletRequest portletRequest, String layoutFriendlyURL)
    throws PortalException {

    ThemeDisplay themeDisplay =
        (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (layoutFriendlyURL != null) {
        return LayoutLocalServiceUtil.getFriendlyURLLayout(
            themeDisplay.getScopeGroupId(),
            themeDisplay.getLayout().isPrivateLayout(), layoutFriendlyURL);
    }

    throw new PortalException(
        "Couldn't find asset publisher layout for " + layoutFriendlyURL +
            ". Please check configuration.");
}
项目:liferay-dummy-factory    文件:MBContext.java   
public MBContext(ActionRequest actionRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
            WebKeys.THEME_DISPLAY);

    //Fetch data
    numberOfMB = ParamUtil.getLong(actionRequest, "numberOfMB",0);
    categoryId = ParamUtil.getLong(actionRequest, "categoryId",MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);
    subject = ParamUtil.getString(actionRequest, "subject","dummy subject");
    body = ParamUtil.getString(actionRequest, "body","dummy body");
    anonymous = ParamUtil.getBoolean(actionRequest, "anonymous",false);
    allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks",false);
    priority = ParamUtil.getDouble(actionRequest, "priority",0.0);
    parentCategoryId = ParamUtil.getLong(actionRequest, "parentCategoryId",MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);
    categoryName = ParamUtil.getString(actionRequest, "categoryName","dummy Category Name");
    description = ParamUtil.getString(actionRequest, "description","dummy description");
    threadId = ParamUtil.getLong(actionRequest, "threadId",0);
    siteGroupId = ParamUtil.getLong(actionRequest, "siteGroupId",themeDisplay.getScopeGroupId());

    // Sites
    String[] groupsStrIds = ParamUtil.getStringValues(actionRequest, "groupIds",
            new String[] { String.valueOf(themeDisplay.getScopeGroupId()) });
    groupIds = CommonUtil.convertStringToLongArray(groupsStrIds);       
}
项目:liferay-dummy-factory    文件:DummyGenerator.java   
/**
 * Create Dummy data
 *
 * @param request
 * @throws Exception
 */
public void create(ActionRequest request) throws Exception {

    T paramContext = getContext(request);

       if(!validate(paramContext)) {
           throw new Exception("Validation Error");
       }

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), request);

    paramContext.setThemeDisplay(themeDisplay);
    paramContext.setServiceContext(serviceContext);

    exec(request, paramContext);
}
项目:lr7-test-project    文件:PortletRemover.java   
/**
 * Remove portlet from the page
 *
 * @param request The request
 * @param response The response
 */
@ProcessAction(name = "removePortlet")
public void removePortletAction(ActionRequest request, ActionResponse response) throws IOException {
    Layout currentLayout = (Layout) request.getAttribute(WebKeys.LAYOUT);
    String portletId = ParamUtil.getString(request, RQ_PARAM_PORTLET_ID, null);

    if(portletId != null) {
        Matcher m = PATTERN_PORTLET_ID.matcher(portletId);

        if(m.matches()) {
            try {
                this.serviceRef.removePortlet(currentLayout, portletId);
            } catch(PortalException e) {
                LOG.error("Unable to remove portlet", e);
            }
        }
    }

}
项目:arquillian-liferay    文件:SamplePortlet.java   
public void add(
    ActionRequest actionRequest, ActionResponse actionResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
        WebKeys.THEME_DISPLAY);

    int firstParameter = ParamUtil.getInteger(
        actionRequest, "firstParameter");
    int secondParameter = ParamUtil.getInteger(
        actionRequest, "secondParameter");

    int result = _sampleService.add(firstParameter, secondParameter);

    PortletURL portletURL = PortletURLFactoryUtil.create(
        actionRequest, "arquillian_sample_portlet", themeDisplay.getPlid(),
        PortletRequest.RENDER_PHASE);

    portletURL.setParameter(
        "firstParameter", String.valueOf(firstParameter));
    portletURL.setParameter(
        "secondParameter", String.valueOf(secondParameter));
    portletURL.setParameter("result", String.valueOf(result));

    actionRequest.setAttribute(WebKeys.REDIRECT, portletURL.toString());
}
项目:govapps    文件:ActionUtil.java   
/**
 * Creates a Application_Entitlement object out of fields from the request.
 *
 * @param request
 * @return application_Entitlement
 */
public static Application_Entitlement application_EntitlementFromRequest(ActionRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    Application_Entitlement model = new Application_EntitlementImpl();

    _log.debug("themeDisplay.getCompanyId(): " + themeDisplay.getCompanyId());

    model.setApplicationEntitlementID(ParamUtil.getLong(request, "ApplicationEntitlementId"));
    model.setCompanyId(themeDisplay.getCompanyId());
    model.setUserId(themeDisplay.getUserId());

    model.setApplicationId(ParamUtil.getLong(request, "applicationId"));
    model.setEntitlementId(ParamUtil.getLong(request, "entitlementId"));
    model.setName(ParamUtil.getString(request, "name").trim());
    model.setMotivation(ParamUtil.getString(request, "motivation").trim());

    return model;
}
项目:govapps    文件:ActionUtil.java   
/**
 * Creates a LegalDetails object out of fields from the request.
 *
 * @param request
 * @return legalDetails
 */
public static LegalDetails legalDetailsFromRequest(ActionRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    LegalDetails model = new LegalDetailsImpl();

    model.setCompanyId(themeDisplay.getCompanyId());
    model.setUserId(themeDisplay.getUserId());

    model.setLegalDetailsId(ParamUtil.getLong(request, "legalDetailsId"));
    model.setAddress(ParamUtil.getString(request, "address").trim());
    model.setEmail(ParamUtil.getString(request, "email").trim());
    model.setFax(ParamUtil.getString(request, "fax").trim());
    model.setLegalForm(ParamUtil.getString(request, "legalForm").trim());
    model.setName(ParamUtil.getString(request, "name").trim());
    model.setRegistrationCourt(ParamUtil.getString(request, "registrationCourt").trim());
    model.setTelephone(ParamUtil.getString(request, "telephone").trim());
    model.setURL(ParamUtil.getString(request, "URL").trim());
    model.setValueAddedTaxNo(ParamUtil.getString(request, "valueAddedTaxNo").trim());
    return model;
}
项目:govapps    文件:ActionUtil.java   
/**
 * Creates a Region object out of fields from the request.
 *
 * @param request
 * @return region
 */
public static Region regionFromRequest(ActionRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    Region model = new RegionImpl();

    model.setCompanyId(themeDisplay.getCompanyId());
    model.setUserId(themeDisplay.getUserId());

    model.setRegionId(ParamUtil.getLong(request, "regionId"));
    model.setAgs(ParamUtil.getInteger(request, "ags"));
    model.setCoordniates_x(ParamUtil.getDouble(request, "coordniates_x"));
    model.setCoordniates_y(ParamUtil.getDouble(request, "coordniates_y"));
    model.setName(ParamUtil.getString(request, "regionName").trim());
    model.setParentRegion(ParamUtil.getLong(request, "parentRegionId"));
    return model;
}
项目:liferaylms-portlet    文件:LearningActivityBaseAssetRenderer.java   
@Override
public final String getURLViewInContext(
        LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse,
        String noSuchEntryRedirect) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(_layout.getPlid(), _portletId, PortletRequest.RENDER_PHASE);
    portletURL.setParameter("actId",Long.toString( _learningactivity.getActId()));
    portletURL.setParameter("moduleId",Long.toString( _learningactivity.getModuleId()));
    portletURL.setParameter("actionEditingActivity", StringPool.FALSE);
    portletURL.setParameter("actionEditingDetails", StringPool.FALSE);
    portletURL.setParameter("actionEditingModule", StringPool.FALSE);
    portletURL.setParameter("actionCalifications", StringPool.FALSE);
    portletURL.setParameter("activityStarted", StringPool.TRUE);        

    String mvcPath = getMvcPathView(themeDisplay.getUserId(),liferayPortletResponse,liferayPortletRequest.getWindowState());
    if(Validator.isNotNull(mvcPath)){
        portletURL.setParameter("mvcPath",mvcPath);
    }

    prepareRuntimePortlet(portletURL);
    return portletURL.toString();
}
项目:liferaylms-portlet    文件:DeregisterAcademyMailPortlet.java   
public void saveDeregister(ActionRequest request,
        ActionResponse response) throws IOException,
        PortletException {

    try{
        ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
        User user = themeDisplay.getUser();
        boolean deregisterMail = ParamUtil.getBoolean(request, "deregister", false);

        if(user.getExpandoBridge().getAttribute(LiferaylmsUtil.DEREGISTER_USER_EXPANDO)==null){
            user.getExpandoBridge().addAttribute(LiferaylmsUtil.DEREGISTER_USER_EXPANDO, ExpandoColumnConstants.BOOLEAN);
        }
        user.getExpandoBridge().setAttribute(LiferaylmsUtil.DEREGISTER_USER_EXPANDO, deregisterMail);

        UserLocalServiceUtil.updateUser(user);
        log.debug("User updated!");
        SessionMessages.add(request, "saveDeregisterOK");

    }catch(Exception e){
        e.printStackTrace();
        SessionErrors.add(request, "saveDeregisterKO");
    }

}
项目:particity    文件:ManagementController.java   
/**
 * Unlock.
 *
 * @param request the request
 * @param response the response
 * @param model the model
 */
@ActionMapping(params = "action=unlock")
public void unlock(final ActionRequest request,
        final ActionResponse response, final Model model) {
    final Long offerId = this.getOfferId(request);
    m_objLog.debug("unlock::start(" + offerId + ")");

    if (offerId != null && offerId >= 0) {
        final ThemeDisplay themeDisplay = (ThemeDisplay) request
                .getAttribute(WebKeys.THEME_DISPLAY);
        CustomLockServiceHandler.unlock(AHOffer.class.getName(), offerId,
                themeDisplay);
    }
    // redirect to offer tab
    response.setRenderParameter("tabId", "offer");

    m_objLog.debug("unlock::end");
}
项目:liferaylms-portlet    文件:PortalAdmin.java   
@ProcessAction(name="checkgroups")
public void checkgroups(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    List<Course> courses = CourseLocalServiceUtil.findByCompanyId(themeDisplay.getCompanyId());

    int counter = 0;
    for(Course course: courses){
        if(log.isDebugEnabled())log.debug("Course::"+course.getCourseId());
        Group group = GroupLocalServiceUtil.getGroup(course.getGroupCreatedId());
        ClassName cn = ClassNameLocalServiceUtil.getClassName(Course.class.getName());
        if(!group.getClassName().equals(Course.class.getName())){
            if(log.isDebugEnabled())log.debug("Change!"+group.getGroupId());

            group.setClassNameId(cn.getClassNameId());
            group.setClassPK(course.getCourseId());

            GroupLocalServiceUtil.updateGroup(group);

            counter++;
        }
    }
    actionResponse.setRenderParameter("counter", String.valueOf(counter));

    SessionMessages.add(actionRequest, "ok");
}
项目:liferaylms-portlet    文件:LmsActivitiesList.java   
public void downmodule(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long moduleId = ParamUtil.getLong(actionRequest, "resId",0);
    long userIdAction = themeDisplay.getUserId();
    if(moduleId>0)
    {
        if(permissionChecker.hasPermission(
            themeDisplay.getScopeGroupId(),
            Module.class.getName(), moduleId,
            ActionKeys.UPDATE))
        {
        ModuleLocalServiceUtil.goDownModule(moduleId,userIdAction);
        }
    }

}
项目:liferaylms-portlet    文件:LmsActivitiesList.java   
public void moveModule(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();
    long userIdAction = themeDisplay.getUserId();
    long moduleId = ParamUtil.getLong(actionRequest, "pageId"),
         prevModId = ParamUtil.getLong(actionRequest, "prevPageId"),
         nextModId = ParamUtil.getLong(actionRequest, "nextPageId");

    if(moduleId>0){
        if(permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), Module.class.getName(), moduleId, ActionKeys.UPDATE)){
            ModuleLocalServiceUtil.moveModule(moduleId, prevModId, nextModId,userIdAction);
        }
    }

    actionResponse.setRenderParameter("jsp", "/html/lmsactivitieslist/view.jsp");
}
项目:liferaylms-portlet    文件:LmsActivitiesList.java   
public void moveActivity(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long actId = ParamUtil.getLong(actionRequest, "pageId"),
         prevActId = ParamUtil.getLong(actionRequest, "prevPageId"),
         nextActId = ParamUtil.getLong(actionRequest, "nextPageId");

    if(actId>0){
        LearningActivity larn = LearningActivityLocalServiceUtil.getLearningActivity(actId);

        if(permissionChecker.hasPermission(larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), ActionKeys.UPDATE)|| 
                permissionChecker.hasOwnerPermission(larn.getCompanyId(), LearningActivity.class.getName(), larn.getActId(),larn.getUserId(), ActionKeys.UPDATE)){
            LearningActivityLocalServiceUtil.moveActivity(actId, prevActId, nextActId, themeDisplay.getUserId());
        }
    }

    actionResponse.setRenderParameter("jsp", "/html/lmsactivitieslist/view.jsp");
}
项目:liferaylms-portlet    文件:LmsActivitiesList.java   
public void viewactivity(ActionRequest actionRequest, ActionResponse actionResponse)
    throws PortalException, SystemException, Exception {

    long actId = ParamUtil.getInteger(actionRequest, "actId");
    AssetRendererFactory laf = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(LearningActivity.class.getName());

    //auditing
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    AuditingLogFactory.audit(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), LearningActivity.class.getName(), 
            actId, themeDisplay.getUserId(), AuditConstants.GET, null);

    if (laf != null) {
        AssetRenderer assetRenderer = laf.getAssetRenderer(actId, 0);
        String urlEdit = assetRenderer.getURLViewInContext((LiferayPortletRequest) actionRequest, (LiferayPortletResponse) actionResponse, "").toString();
        actionResponse.sendRedirect(urlEdit);
    }
    SessionMessages.add(actionRequest, "asset-renderer-not-defined");

}
项目:particity    文件:MainController.java   
/**
 * Edits the offer.
 *
 * @param request the request
 * @param response the response
 * @param model the model
 */
@ActionMapping(params = "action=editOffer")
public void editOffer(final ActionRequest request,
        final ActionResponse response, final Model model) {
    final Long offerId = this.getOfferId(request);
    m_objLog.debug("editOffer::start(" + offerId + ")");

    final ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);

    if (offerId != null) {
        final OfferForm form = CustomOfferServiceHandler
                .getOfferForEdit(offerId);
        m_objLog.info("Edit offer serving offer form " + form.getOfferId());
        model.addAttribute("data", form);
        model.addAttribute("workhours", CustomPersistanceServiceHandler
                .getDataList(E_CategoryType.OFFERTIME, false));
        response.setRenderParameter("jspPage", "../shared/offer");
        response.setRenderParameter("actionType", "edit");
        CustomLockServiceHandler.lock(AHOffer.class.getName(),
                form.getOfferId(), themeDisplay);
    }

    m_objLog.debug("editOffer::end");
}
项目:liferaylms-portlet    文件:ExecActivity.java   
public void upquestion(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long actId = ParamUtil.getLong(actionRequest, "actId",0);
    long testQuestionId = ParamUtil.getLong(actionRequest, "questionId");

    if(actId>0)
    {   
        LearningActivity larn = LearningActivityLocalServiceUtil.getLearningActivity(actId);

        if(permissionChecker.hasPermission(larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(),
                ActionKeys.UPDATE)|| permissionChecker.hasOwnerPermission(larn.getCompanyId(), LearningActivity.class.getName(), larn.getActId(),larn.getUserId(),
                        ActionKeys.UPDATE))
        {
        TestQuestionLocalServiceUtil.goUpTestQuestion(testQuestionId);
        }
    }
}
项目:liferaylms-portlet    文件:ExecActivity.java   
public void downquestion(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long actId = ParamUtil.getLong(actionRequest, "actId",0);
    long testQuestionId = ParamUtil.getLong(actionRequest, "questionId");

    if(actId>0)
    {
        LearningActivity larn = LearningActivityLocalServiceUtil.getLearningActivity(actId);

        if(permissionChecker.hasPermission(larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(),
                ActionKeys.UPDATE)|| permissionChecker.hasOwnerPermission(larn.getCompanyId(), LearningActivity.class.getName(), larn.getActId(),larn.getUserId(),
                        ActionKeys.UPDATE))
        {
            TestQuestionLocalServiceUtil.goDownTestQuestion(testQuestionId);
        }
    }
}
项目:liferaylms-portlet    文件:CourseDetailPortlet.java   
public void showViewEditCourse(RenderRequest renderRequest,
        RenderResponse renderResponse) throws IOException, PortletException {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getScopeGroupId();

    Course course = null;
    try {
        course = CourseLocalServiceUtil.fetchByGroupCreatedId(groupId);
    } catch (SystemException e) {
        log.error("No se ha encontrado ningún curso con el groupCreatedId=" + groupId, e);
    }

    if (Validator.isNotNull(course)) {
        renderRequest.setAttribute("course", course);
    }

    include(this.editCourseJSP, renderRequest, renderResponse);

}
项目:particity    文件:BaseController.java   
/**
 * Checks if is logged in mgmt.
 *
 * @param request the request
 * @return true, if is logged in mgmt
 */
protected boolean isLoggedInMgmt(final PortletRequest request) {
    boolean result = false;
    final ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);
    if (themeDisplay.isSignedIn()) {
        final User user = themeDisplay.getUser();
        if (user != null) {
            try {
                final List<Role> roles = user.getRoles();
                String mgmtRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_MGMT);
                for (final Role role : roles) {
                    if (role.getName().equals(mgmtRoleName)) {
                        result = true;
                        break;
                    }
                }
            } catch (final Throwable t) {
            }
        }
    }
    return result;
}
项目:particity    文件:BaseController.java   
/**
 * Checks if is logged in org.
 *
 * @param request the request
 * @return true, if is logged in org
 */
protected boolean isLoggedInOrg(final PortletRequest request) {
    boolean result = false;
    final ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);
    if (themeDisplay.isSignedIn()) {
        final User user = themeDisplay.getUser();
        if (user != null) {
            try {
                final List<Role> roles = user.getRoles();
                final String orgRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_ORG);
                for (final Role role : roles) {
                    if (role.getName().equals(orgRoleName)) {
                        result = true;
                        break;
                    }
                }
            } catch (final Throwable t) {
            }
        }
    }
    return result;
}
项目:liferaylms-portlet    文件:SurveyActivity.java   
public void upquestion(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long actId = ParamUtil.getLong(actionRequest, "actId",0);
    long testQuestionId = ParamUtil.getLong(actionRequest, "questionId");

    if(actId>0)
    {   
        LearningActivity larn = LearningActivityLocalServiceUtil.getLearningActivity(actId);

        if(permissionChecker.hasPermission(larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(),
                ActionKeys.UPDATE)|| permissionChecker.hasOwnerPermission(larn.getCompanyId(), LearningActivity.class.getName(), larn.getActId(),larn.getUserId(),
                        ActionKeys.UPDATE))
        {
            TestQuestionLocalServiceUtil.goUpTestQuestion(testQuestionId);
        }
    }
}
项目:liferaylms-portlet    文件:SurveyActivity.java   
public void downquestion(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker=themeDisplay.getPermissionChecker();

    long actId = ParamUtil.getLong(actionRequest, "actId",0);
    long testQuestionId = ParamUtil.getLong(actionRequest, "questionId");

    if(actId>0)
    {
        LearningActivity larn = LearningActivityLocalServiceUtil.getLearningActivity(actId);

        if(permissionChecker.hasPermission(larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(),
                ActionKeys.UPDATE)|| permissionChecker.hasOwnerPermission(larn.getCompanyId(), LearningActivity.class.getName(), larn.getActId(),larn.getUserId(),
                        ActionKeys.UPDATE))
        {
            TestQuestionLocalServiceUtil.goDownTestQuestion(testQuestionId);
        }
    }
}
项目:particity    文件:MainController.java   
/**
 * Save offer.
 *
 * @param data the data
 * @param result the result
 * @param request the request
 * @param response the response
 * @param model the model
 */
@ActionMapping(params = "action=saveOffer")
public void saveOffer(@Valid @ModelAttribute("data") final OfferForm data,
        final BindingResult result, final ActionRequest request,
        final ActionResponse response, final Model model) {
    m_objLog.debug("saveOffer::start(" + data.getOfferId() + ")");

    final ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);

    this.m_objOfferFormValidator.setThemeDisplay(themeDisplay);
    this.m_objOfferFormValidator.validate(data, result);

    if (!result.hasErrors()) {
        CustomOfferServiceHandler.addOffer(data);
        CustomLockServiceHandler.unlock(AHOffer.class.getName(),
                data.getOfferId(), themeDisplay);
        data.clear();
    } else {
        response.setRenderParameter("actionType", "edit");
        response.setRenderParameter("jspPage", "../shared/offer");
    }

    m_objLog.debug("saveOffer::end");
}
项目:liferaylms-portlet    文件:modulePortlet.java   
@ProcessAction(name = "deletemodule")
public void deletemodule(ActionRequest request, ActionResponse response)throws Exception {
    long id = ParamUtil.getLong(request, "resourcePrimKey");
    if (Validator.isNotNull(id)) {
        Module module = ModuleLocalServiceUtil.getModule(id);
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        List<LearningActivity> moduleActivities = LearningActivityLocalServiceUtil.getLearningActivitiesOfModule(id);
        for(LearningActivity la : moduleActivities){
            deleteActivity(la, themeDisplay, request, response);
        }
        ModuleLocalServiceUtil.deleteModule(module);
        //MultiVMPoolUtil.clear();
        SessionMessages.add(request, "module-deleted-successfully");
    } else {
        SessionErrors.add(request, "module-error-deleting");
    }
}
项目:liferaylms-portlet    文件:DateEditor.java   
private Module updateModuleDates(Module module, ActionRequest request, boolean startDate){
    String paramValue;
    if(startDate){
        paramValue="modInit";
    }else{
        paramValue="modEnd";
    }   
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Calendar date = getDateFromRequest(request, paramValue, module.getModuleId());
    date.setTimeZone(themeDisplay.getTimeZone());
    if(startDate){
        module.setStartDate(date.getTime());
    }else{
        module.setEndDate(date.getTime());
    }

    return module;
}
项目:liferaylms-portlet    文件:DateEditor.java   
private LearningActivity updateActivityDates(LearningActivity activity, ActionRequest request, int dateType) throws SystemException{
    String paramValue;
    if(dateType == 0){
        paramValue="actInit";
    }else if(dateType == 1){
        paramValue="actEnd";
    }else if(dateType == 2){
        paramValue = "actUpdate";
    }else{
        return activity;
    }       
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    Calendar date = getDateFromRequest(request, paramValue, activity.getActId());
    date.setTimeZone(themeDisplay.getTimeZone());
    if(dateType == 0){
        activity.setStartdate(date.getTime());
    }else if(dateType == 1){
        activity.setEnddate(date.getTime());
    }else if(dateType == 2){
        SimpleDateFormat sdfP2p = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
        LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "dateupload",sdfP2p.format(date.getTime()));
    }

    return activity;
}
项目:liferaylms-portlet    文件:DateEditor.java   
private Calendar getDateFromRequest(ActionRequest request, String paramValue, long id){
    int year,month,day,hour,minute;
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    year=ParamUtil.getInteger(request, paramValue+"Year_"+id);
    month=ParamUtil.getInteger(request, paramValue+"Month_"+id);
    day=ParamUtil.getInteger(request, paramValue+"Day_"+id);
    hour=ParamUtil.getInteger(request, paramValue+"Hour_"+id);
    minute=ParamUtil.getInteger(request, paramValue+"Minute_"+id);

    Calendar date = Calendar.getInstance(themeDisplay.getTimeZone());
    date.set(Calendar.YEAR, year);
    date.set(Calendar.MONTH, month);
    date.set(Calendar.DAY_OF_MONTH, day);
    date.set(Calendar.HOUR_OF_DAY, hour);
    date.set(Calendar.MINUTE, minute);
    date.set(Calendar.SECOND, 0);
    date.set(Calendar.MILLISECOND,0);
    return date;
}
项目:liferaylms-portlet    文件:CatalogCourses.java   
public void serveResource(ResourceRequest request, ResourceResponse response)throws PortletException, IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String action = ParamUtil.getString(request, "action");

    if(action.equals("getCourses")){
        JSONArray usersJSONArray = JSONFactoryUtil.createJSONArray();

        String freeText = ParamUtil.getString(request, "courseTitle");

        List<Course> listCourse = CourseLocalServiceUtil.getCoursesCatalogByTitleCategoriesTags(freeText, null, null, themeDisplay.getCompanyId(), 
                                        themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), themeDisplay.getLanguageId(), -1, -1);

        JSONObject userJSON = null;

        for (Course course : listCourse) {
            userJSON = JSONFactoryUtil.createJSONObject();
            userJSON.put("courseTitle", course.getTitle(themeDisplay.getLocale()));
            userJSON.put("courseDescription", course.getDescription(themeDisplay.getLocale()));
            usersJSONArray.put(userJSON);
        }

        PrintWriter out = response.getWriter();
        out.println(usersJSONArray.toString());
    }
}
项目:liferaylms-portlet    文件:ActivityDatesPortlet.java   
@Override
public void doView(RenderRequest renderRequest,
        RenderResponse renderResponse) throws IOException, PortletException {

    //Cuando no tenemos actividad, ocultamos el portlet.
    if(ParamUtil.getLong(renderRequest, "actId", 0) == 0){
        renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE);
    }

    if(ParamUtil.getBoolean(renderRequest, WebKeys.PORTLET_CONFIGURATOR_VISIBILITY,true)) {
        super.doView(renderRequest, renderResponse);
    }
    else {
        renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE);
    }
}
项目:particity    文件:ManagementController.java   
/**
 * Edits the offer.
 *
 * @param request the request
 * @param response the response
 * @param model the model
 */
@ActionMapping(params = "action=editOffer")
public void editOffer(final ActionRequest request,
        final ActionResponse response, final Model model) {
    final Long offerId = this.getOfferId(request);
    m_objLog.debug("editOffer::start(" + offerId + ")");

    if (offerId != null) {
        final ThemeDisplay themeDisplay = (ThemeDisplay) request
                .getAttribute(WebKeys.THEME_DISPLAY);
        final OfferForm form = CustomOfferServiceHandler.getOffer(offerId);
        m_objLog.debug("Edit offer with agency contact: "
                + form.isRequireAgencyContact());
        model.addAttribute("data", form);
        response.setRenderParameter("jspPage", "../shared/offer");
        response.setRenderParameter("actionType", "approve");
        CustomLockServiceHandler.lock(AHOffer.class.getName(),
                form.getOfferId(), themeDisplay);
    }

    m_objLog.debug("editOffer::end");
}
项目:liferaylms-portlet    文件:CourseAdmin.java   
public void exportCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);   
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Course.class.getName(), actionRequest);

    long groupId  = ParamUtil.getLong(actionRequest, "groupId", 0);
    String fileName  = ParamUtil.getString(actionRequest, "exportFileName", "New course exported");
    if(log.isDebugEnabled()){
        log.debug("groupId:"+groupId);
        log.debug("fileName:"+fileName);
    }

    Message message = new Message();
    message.put("groupId", groupId);
    message.put("fileName", fileName);
    message.put("themeDisplay", themeDisplay);
    message.put("serviceContext", serviceContext);
    MessageBusUtil.sendMessage("liferay/lms/courseExport", message);

    SessionMessages.add(actionRequest, "courseadmin.export.confirmation.success");

}
项目:liferaylms-portlet    文件:CourseAdmin.java   
public void deleteExportedCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId  = ParamUtil.getLong(actionRequest, "groupId", 0);
    String fileName = ParamUtil.getString(actionRequest, "fileName", StringPool.BLANK);
    String redirect = ParamUtil.getString(actionRequest, "redirect", StringPool.BLANK);
    File f = new File(PropsUtil.get("liferay.home")+"/data/lms_exports/courses/"+themeDisplay.getCompanyId()+"/"+groupId+"/"+fileName);
    if (themeDisplay.getPermissionChecker().hasPermission(groupId, Course.class.getName(), groupId, ActionKeys.DELETE) && f != null && f.isFile()) {
        FileUtil.delete(f);
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.success");
    } else {
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.error");
    }
    if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
    }
}
项目:liferaylms-portlet    文件:CourseStats.java   
@Override
public void serveResource(ResourceRequest resourceRequest,
                          ResourceResponse resourceResponse) 
                throws IOException, PortletException {
    String action = ParamUtil.getString(resourceRequest, "action");
    ThemeDisplay themeDisplay  =(ThemeDisplay)resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long teamId   = ParamUtil.getLong(resourceRequest, "teamId", 0);

    if("export".equals(action)){
        long courseId = ParamUtil.getLong(resourceRequest, "courseId",0);
        exportCourse(resourceResponse, courseId, teamId, themeDisplay);
    } else if("exportModule".equals(action)){
        long moduleId = ParamUtil.getLong(resourceRequest, "moduleId",0);
        exportModule(resourceResponse, moduleId, teamId, themeDisplay, resourceRequest);
    }
}