Example usage for com.liferay.portal.kernel.util StringPool SLASH

List of usage examples for com.liferay.portal.kernel.util StringPool SLASH

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool SLASH.

Prototype

String SLASH

To view the source code for com.liferay.portal.kernel.util StringPool SLASH.

Click Source Link

Usage

From source file:com.rivetlogic.crafter.social.listeners.CustomTrashEntryListener.java

License:Open Source License

private void init(long companyId) {
    try {/* w ww.ja v  a2  s  . c o  m*/
        CrafterManager.init();

        // add crafterAuthCookie to HTTP client
        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
        client.setCookieStore(new BasicCookieStore());
        AuthenticationCookie authCookie = CrafterManager
                .getCrafterProfileCookie(PrefsPropsUtil.getString(companyId, CrafterConstants.PROFILE_ADMIN_KEY,
                        GetterUtil.getString(PropsUtil.get(CrafterConstants.PROFILE_ADMIN_KEY),
                                CrafterConstants.PROFILE_DEFAULT_USER)));

        BasicClientCookie cookie = new BasicClientCookie(AuthenticationCookie.COOKIE,
                authCookie.toCookieValue());
        cookie.setDomain(CrafterConstants.CRAFTER_DOMAIN);
        cookie.setExpiryDate(authCookie.getProfileOutdatedAfter());
        cookie.setPath(StringPool.SLASH);
        client.getCookieStore().addCookie(cookie);

    } catch (Exception e) {
        LOG.error(e.getMessage());
    }
}

From source file:com.slayer.service.impl.LMSBookLocalServiceImpl.java

License:Open Source License

public void attachFiles(long bookId, ServiceContext serviceContext) {
    // uploading the image
    File coverImage = (File) serviceContext.getAttribute("COVER_IMAGE");

    if (Validator.isNotNull(coverImage)) {
        try {//from w w w.  ja v a 2s. co m
            imageLocalService.updateImage(bookId, coverImage);
        } catch (PortalException e) {
            e.printStackTrace();
        } catch (SystemException e) {
            e.printStackTrace();
        }
    }

    File sampleChapter = (File) serviceContext.getAttribute("SAMPLE_CHAPTER");

    if (Validator.isNotNull(sampleChapter)) {
        LMSBook lmsBook = null;
        try {
            lmsBook = fetchLMSBook(bookId);
        } catch (SystemException e) {
            e.printStackTrace();
        }

        if (Validator.isNotNull(lmsBook)) {

            // update the original object
            String fileName = (String) serviceContext.getAttribute("FILE_NAME");

            lmsBook.setSampleChapter(fileName);

            try {
                updateLMSBook(lmsBook);
            } catch (SystemException e) {
                e.printStackTrace();
            }

            // create a folder to store this file
            long companyId = serviceContext.getCompanyId();
            String folderName = "Sample_Chapters";
            LMSUtil.createFolder(folderName, companyId);

            // Saving the file now
            String filePath = folderName + StringPool.SLASH + fileName;
            try {
                DLStoreUtil.addFile(companyId, CompanyConstants.SYSTEM, filePath, sampleChapter);
            } catch (PortalException e) {
                e.printStackTrace();
            } catch (SystemException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.sohlman.liferay.bffss.service.impl.FileInfoLocalServiceImpl.java

License:Open Source License

@Override
public void deleteFileInfosByDirectory(long companyId, long repositoryId, String dirName)
        throws SystemException, PortalException {

    if (!dirName.endsWith(StringPool.SLASH)) {
        dirName = dirName.concat(StringPool.SLASH);
    }//from w  ww.ja  v a 2  s  .  c om

    dirName = dirName.concat(StringPool.PERCENT);

    List<FileInfo> fileInfos = fileInfoPersistence.findByC_R_LikeP(companyId, repositoryId, dirName);

    for (FileInfo fileInfo : fileInfos) {
        deleteFileInfo(fileInfo);
    }
}

From source file:com.sohlman.liferay.bffss.service.impl.FileInfoLocalServiceImpl.java

License:Open Source License

@Override
public List<FileInfo> getFileInfosByDirectory(long companyId, long repositoryId, String dirName)
        throws SystemException {

    if (!dirName.endsWith(StringPool.SLASH)) {
        dirName = dirName.concat(StringPool.SLASH);
    }/*from   ww  w .  ja  va2 s  .co m*/

    dirName = dirName.concat(StringPool.PERCENT);

    return fileInfoPersistence.findByC_R_LikeP(companyId, repositoryId, dirName);
}

From source file:com.stoxx.portlet.controller.RegistrationController.java

@ActionMapping(params = "action=setupProfileAction")
public void setupProfileAction(ActionRequest actionRequest, ActionResponse actionResponse, Model model,
        @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean, BindingResult bindingResult) {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String emailVelocityTemplate = StringPool.BLANK;
    try {//from  w w w .j a v  a 2  s  .co m
        ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);
        log.info("Within setupProfileAction...");
        log.info("registrationBean.toString() : " + registrationBean.toString());
        HttpServletRequest httpreq = PortalUtil.getHttpServletRequest(actionRequest);
        HttpServletRequest httpOriginalreq = PortalUtil.getOriginalServletRequest(httpreq);
        //String remoteAddr = httpOriginalreq.getHeader("remote_addr"); // Should be Client-IP to retrieve IP address of the client machine  //
        String remoteAddr = httpOriginalreq.getHeader("Client-IP");
        if (Validator.isNull(remoteAddr)) {
            remoteAddr = httpOriginalreq.getRemoteAddr();
        }
        try {
            CaptchaUtil.check(actionRequest);
        } catch (Exception e) {
            if (e instanceof CaptchaTextException) {
                SessionErrors.add(actionRequest, e.getClass(), e);
                actionResponse.setRenderParameter(ACTION, "CaptchaException");
                return;
            }
        }
        log.info("the remote address is " + remoteAddr);
        String location = RegistrationVOUtil.getLocationForUser(remoteAddr);
        if (null != location) {
            registrationBean.setLocation(location);
        }
        RegistrationBean registrationBean1 = registrationDelegator.fetchFromStoxxUser(registrationBean);
        registrationBean.setUserType(registrationBean1.getUserType());
        registrationBean.setCompanyId(themeDisplay.getCompanyId());
        registrationBean.setActivationLink(registrationBean.getActivationLink());
        log.info("registrationBean.getActivationLink() : " + registrationBean.getActivationLink());
        log.info("registrationBean.getIsExistingUser() : " + registrationBean.getIsExistingUser());
        log.info("registrationBean.getIsDeletedUser() : " + registrationBean.getIsDeletedUser());
        registrationBean.setActivationLinkCreatedDate(new Date());
        registrationDelegator.addUserRegistration(registrationBean, serviceContext, themeDisplay,
                registrationBean.getIsExistingUser(), registrationBean.getIsDeletedUser());

        Layout layout = themeDisplay.getLayout();
        PortletURL loginActionUrl = PortletURLFactoryUtil.create(actionRequest, "58", layout.getPlid(),
                "ACTION_PHASE");
        loginActionUrl.setWindowState(WindowState.MAXIMIZED);
        loginActionUrl.setPortletMode(PortletMode.VIEW);
        loginActionUrl.setParameter("saveLastPath", "0");
        loginActionUrl.setParameter("struts_action", "/login/login");
        loginActionUrl.setParameter("login", registrationBean.getBusinessEmailAddress());
        loginActionUrl.setParameter("password", registrationBean.getUserPassword());

        Map<String, Object> emailBodyMap = new HashMap<String, Object>();
        String emailTemplateFolder = "templates";
        emailBodyMap.put("toName", registrationBean.getBusinessEmailAddress());
        emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-reg-mail-from-name"));
        emailBodyMap.put("fromAddress", PrefsPropsUtil.getString("stoxx-reg-mail-fromAddress"));
        emailVelocityTemplate = emailTemplateFolder + StringPool.SLASH + "willingtocontact.vm";
        String subject = LanguageUtil.get(themeDisplay.getLocale(),
                "stoxx-reg-mail-subject-for-wiiling-to-contact");
        if (registrationBean.isContactMe())
            stoxxMailUtil.shareByEmail(registrationBean.getBusinessEmailAddress(),
                    PrefsPropsUtil.getString("stoxx-reg-mail-from-name"), emailVelocityTemplate, subject,
                    emailBodyMap, themeDisplay);
        if (null != registrationBean.getUserType()) {
            if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) {
                log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                        + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET)
                        + RegistrationConstants.REGISTRATION_DASHBOARD);
                log.info("registrationBean.getDashboardRedirectCondition()  1>>>>>>>>>"
                        + registrationBean.getDashboardRedirectCondition());
                loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                        + PropsUtil.get("INTRANET") + RegistrationConstants.REGISTRATION_DASHBOARD);

                actionResponse.sendRedirect(loginActionUrl.toString());
            } else if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) {
                log.info("registrationBean.getDashboardRedirectCondition()  2>>>>>>>>>"
                        + registrationBean.getDashboardRedirectCondition());
                if (StringUtils.isNotBlank(registrationBean.getDashboardRedirectCondition())) {
                    log.info("registrationBean.getDashboardRedirectCondition()  3>>>>>>>>>"
                            + registrationBean.getDashboardRedirectCondition());
                    if ("yes".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) {
                        log.info("registrationBean.getDashboardRedirectCondition()  4>>>>>>>>>"
                                + registrationBean.getDashboardRedirectCondition());

                        log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                                + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTERNET)
                                + RegistrationConstants.REGISTRATION_MYPROFILE);

                        loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                                + PropsUtil.get(INTERNET) + RegistrationConstants.REGISTRATION_MYPROFILE);
                        actionResponse.sendRedirect(loginActionUrl.toString());
                    } else {
                        if ("no".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) {
                            log.info("registrationBean.getDashboardRedirectCondition()  4>>>>>>>>>"
                                    + registrationBean.getDashboardRedirectCondition());

                            log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                                    + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET)
                                    + RegistrationConstants.REGISTRATION_DASHBOARD);

                            loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                                    + PropsUtil.get(INTRANET) + RegistrationConstants.REGISTRATION_DASHBOARD);
                            actionResponse.sendRedirect(loginActionUrl.toString());

                        }
                    }
                }
            } else {
                log.info("else redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                        + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get("INTERNET")
                        + RegistrationConstants.REGISTRATION_DASHBOARD);
                loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                        + PropsUtil.get("INTERNET") + RegistrationConstants.REGISTRATION_DASHBOARD);
                actionResponse.sendRedirect(loginActionUrl.toString());
            }
        }

    } catch (STOXXException e) {
        log.error("STOXXException createActivationLink", e);
    } catch (Exception e) {
        log.error("Exception createActivationLink", e);
        try {
            registrationDelegator.deleteUser(registrationBean.getBusinessEmailAddress(),
                    themeDisplay.getCompanyId());
        } catch (STOXXException e1) {
            log.info("the delete user STOXXException ", e1);
        }
        log.error("Exception in setupProfileAction" + e.getMessage(), e);
    }
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String decodePath(String path) {
    if (Validator.isNull(path)) {
        return path;
    }//from   w w w  .  jav  a2  s .  com

    path = StringUtil.replace(path, StringPool.SLASH, _TEMP_SLASH);
    path = decodeURL(path, true);
    path = StringUtil.replace(path, _TEMP_SLASH, StringPool.SLASH);

    return path;
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String encodePath(String path) {
    if (Validator.isNull(path)) {
        return path;
    }/*from  w  w w . j  a  v a2s .  c o m*/

    path = StringUtil.replace(path, StringPool.SLASH, _TEMP_SLASH);
    path = encodeURL(path, true);
    path = StringUtil.replace(path, _TEMP_SLASH, StringPool.SLASH);

    return path;
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String getCompleteURL(HttpServletRequest request) {
    StringBuffer sb = request.getRequestURL();

    if (sb == null) {
        sb = new StringBuffer();
    }//from   w w w.j a  v a 2  s .  co  m

    if (request.getQueryString() != null) {
        sb.append(StringPool.QUESTION);
        sb.append(request.getQueryString());
    }

    String proxyPath = PortalUtil.getPathProxy();

    if (Validator.isNotNull(proxyPath)) {
        int x = sb.indexOf(Http.PROTOCOL_DELIMITER) + Http.PROTOCOL_DELIMITER.length();
        int y = sb.indexOf(StringPool.SLASH, x);

        sb.insert(y, proxyPath);
    }

    String completeURL = sb.toString();

    if (request.isRequestedSessionIdFromURL()) {
        HttpSession session = request.getSession();

        String sessionId = session.getId();

        completeURL = PortalUtil.getURLWithSessionId(completeURL, sessionId);
    }

    if (_log.isWarnEnabled()) {
        if (completeURL.contains("?&")) {
            _log.warn("Invalid url " + completeURL);
        }
    }

    return completeURL;
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String getPath(String url) {
    if (Validator.isNull(url)) {
        return url;
    }//from w  ww  .j  a va2  s.  c  o m

    if (url.startsWith(Http.HTTP)) {
        int pos = url.indexOf(StringPool.SLASH, Http.HTTPS_WITH_SLASH.length());

        url = url.substring(pos);
    }

    int pos = url.indexOf(CharPool.QUESTION);

    if (pos == -1) {
        return url;
    }

    return url.substring(0, pos);
}

From source file:de.fraunhofer.fokus.movepla.service.impl.ApplicationLocalServiceImpl.java

License:Open Source License

public List<List> getNewApplications(long companyId, int year, int month, int day, int count)
        throws SystemException {

    List<List> result = new ArrayList<List>();

    Date modifiedDate = PortalUtil.getDate(month, day, year);
    Date now = new Date();

    List<Application> applications = applicationPersistence.findAll();
    List<Application> applications2 = new ArrayList<Application>();
    for (Application app : applications) {
        applications2.add(app);//from w ww .  ja v a  2 s .c  o m
    }

    OrderByComparator orderByComparator = CustomComparatorUtil.getApplicationOrderByComparator("modifiedDate",
            "desc");

    Collections.sort(applications2, orderByComparator);
    applications2 = applications2.subList(0, count);

    for (Application application : applications2) {
        if (application.getLifeCycleStatus() >= 4) {
            List toAdd = new ArrayList();
            toAdd.add(application);

            DLFileEntry fe;
            try {
                fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId());
                String iconUrl = "http://localhost/documents/10180/0/"
                        + HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) + StringPool.SLASH + fe.getUuid()
                        + "?version=" + fe.getVersion() + "&t=" + fe.getModifiedDate().getTime()
                        + "&imageThumbnail=1";

                toAdd.add(iconUrl);
            } catch (PortalException e) {
                _log.error(e.getMessage());
            }

            result.add(toAdd);
        }
    }
    return result;
}