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:it.smc.calendar.sync.caldav.CalendarResourceImpl.java

License:Open Source License

public CalendarResourceImpl(Calendar calendar, String parentPath, Locale locale) {

    super(parentPath, StringPool.BLANK, calendar.getName(locale), calendar.getCreateDate(),
            calendar.getModifiedDate());

    setModel(calendar);//from  ww w .  j  a  v a 2  s.  c  o  m
    setClassName(Calendar.class.getName());
    setPrimaryKey(calendar.getPrimaryKey());

    try {
        StringBuilder sb = new StringBuilder();

        sb.append(PortalUtil.getPathContext());
        sb.append("/webdav/");
        sb.append(calendar.getCalendarResource().getUuid());
        sb.append(StringPool.SLASH);
        sb.append(WebKeys.CALDAV_TOKEN);
        sb.append(StringPool.SLASH);
        sb.append(calendar.getUuid());

        _href = sb.toString();
    } catch (Exception e) {
        _href = parentPath;
        _log.error(e);
    }

    _calendar = calendar;
}

From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java

License:Open Source License

public static CalendarBooking getCalendarBookingFromURL(String URL) throws PortalException, SystemException {

    if (!URL.endsWith(CalendarDataFormat.ICAL.getValue())) {
        return null;
    }//  www .j a  v  a  2s . c om

    String calendarBookingICSStr = StringUtil.extractLast(URL, StringPool.SLASH);

    String calendarBookingIdStr = StringUtil.extractFirst(calendarBookingICSStr, StringPool.PERIOD);

    long calendarBookingId = GetterUtil.getLong(calendarBookingIdStr);

    return CalendarBookingServiceUtil.getCalendarBooking(calendarBookingId);
}

From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java

License:Open Source License

public static String getCalendarBookingURL(CalendarBooking calendarBooking)
        throws PortalException, SystemException {

    StringBuilder sb = new StringBuilder(11);
    sb.append(PortalUtil.getPathContext());
    sb.append("/webdav/");
    sb.append(calendarBooking.getCalendarResource().getUuid());
    sb.append(StringPool.SLASH);
    sb.append(WebKeys.CALDAV_TOKEN);/*from  w  w  w  . ja  v  a  2  s  .c o m*/
    sb.append(StringPool.SLASH);
    sb.append(calendarBooking.getCalendar().getUuid());
    sb.append(StringPool.SLASH);
    sb.append(calendarBooking.getCalendarBookingId());
    sb.append(StringPool.PERIOD);
    sb.append(CalendarDataFormat.ICAL.getValue());

    return sb.toString();
}

From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java

License:Open Source License

public static String getCalendarResourceURL(CalendarResource calendarResource) {

    StringBuilder sb = new StringBuilder(6);

    sb.append(PortalUtil.getPathContext());
    sb.append("/webdav/");
    sb.append(calendarResource.getUuid());
    sb.append(StringPool.SLASH);
    sb.append(WebKeys.CALDAV_TOKEN);// www .j a  va 2 s  . c  o m
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java

License:Open Source License

public static String getCalendarURL(Calendar calendar) {

    StringBuilder sb = new StringBuilder(3);

    String baseURL = StringPool.BLANK;

    try {/*from w w  w  .ja v a  2  s  .com*/
        baseURL = getCalendarResourceURL(calendar.getCalendarResource());
    } catch (Exception e) {
        _log.error(e);
    }

    sb.append(baseURL);
    sb.append(calendar.getUuid());
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java

License:Open Source License

public static String getPrincipalURL(long userId) {
    StringBuilder sb = new StringBuilder(6);

    sb.append(PortalUtil.getPathContext());
    sb.append("/webdav/user/");
    sb.append(WebKeys.CALDAV_TOKEN);/*w  w w.j  a va2  s  .  com*/
    sb.append(StringPool.SLASH);
    sb.append(userId);
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:m.omarh.liferay.resources.importer.generator.SitemapGeneratorPortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

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

    Group scopeGroup = themeDisplay.getScopeGroup();

    if (scopeGroup.getGroupId() == themeDisplay.getCompanyGroupId()) {

        SessionMessages.add(renderRequest,
                PortalUtil.getPortletId(renderRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
        SessionErrors.add(renderRequest, "company-group-exception");

        super.doView(renderRequest, renderResponse);

    } else {/*w w  w  .  j ava2  s. co  m*/

        JSONObject sitemapJsonObject = SiteMapUtil.generateJSONSitemap(scopeGroup);

        renderRequest.setAttribute("autoDeployDestDir",
                AutoDeployUtil.getAutoDeployDestDir() + StringPool.SLASH);
        renderRequest.setAttribute("sitemap", JSONUtil.beautify(sitemapJsonObject.toString()));

        super.doView(renderRequest, renderResponse);
    }
}

From source file:m.omarh.liferay.resources.importer.generator.SitemapGeneratorPortlet.java

License:Open Source License

public void saveResourceImporter(ActionRequest actionRequest, ActionResponse actionResponse) {

    PortletPreferences portletPreferences = actionRequest.getPreferences();

    String resourceImporterURL = PrefsParamUtil.getString(portletPreferences, actionRequest,
            "resourceImporterURL");
    String pluginSourceURL = PrefsParamUtil.getString(portletPreferences, actionRequest, "pluginSourceURL");

    try {//from   www.  ja v  a  2 s.co  m
        portletPreferences.setValue("resourceImporterURL", resourceImporterURL);
        portletPreferences.setValue("pluginSourceURL", pluginSourceURL);

        portletPreferences.store();

    } catch (ReadOnlyException | ValidatorException | IOException e) {
        _log.error(e.getMessage());
    }

    String fullPathResourceImporterURL = AutoDeployUtil.getAutoDeployDestDir() + StringPool.SLASH
            + resourceImporterURL + "/resources-importer/";
    String fullPathPluginSourceURL = pluginSourceURL + "/docroot/WEB-INF/src/resources-importer/";

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

    //writting tree with flag writeFlag set to true
    TreeUtil.buildJSONTree(themeDisplay, true, fullPathResourceImporterURL, fullPathPluginSourceURL);
}

From source file:org.oep.cmon.timhoso.portlet.utils.TimHoSoUtils.java

License:Apache License

/**
 * This is function getURL/*w ww. j a  va 2s  .c om*/
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param fileEntry
 * @return String
 */
private static String getURL(FileEntry fileEntry) {
    try {

        String url = "/documents/" + fileEntry.getGroupId() + StringPool.SLASH + fileEntry.getFolderId()
                + StringPool.SLASH + fileEntry.getTitle() + "?version=" + fileEntry.getVersion();
        return url;
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }

    return "";
}

From source file:org.opencps.api.service.impl.ApiServiceServiceImpl.java

License:Open Source License

@JSONWebService(value = "dossiers", method = "GET")
public JSONObject getByoid(String oid) {
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    Dossier dossier;/*from   w w w  . j  a v  a  2  s.c  om*/
    try {
        SimpleDateFormat sdf = new SimpleDateFormat(DateTimeUtil._VN_DATE_TIME_FORMAT);
        dossier = dossierLocalService.getByoid(oid);
        if (dossier != null) {
            jsonObject.put("oid", dossier.getOid());
            ServiceInfo serviceInfo = null;
            try {
                serviceInfo = ServiceInfoLocalServiceUtil.getServiceInfo(dossier.getServiceInfoId());
                jsonObject.put("serviceNo", serviceInfo.getServiceNo());
                jsonObject.put("serviceName", serviceInfo.getServiceName());
            } catch (NoSuchServiceInfoException e) {
                jsonObject.put("serviceNo", "");
                jsonObject.put("serviceName", "");
            } catch (PortalException e) {
                // TODO Auto-generated catch block
                jsonObject.put("serviceNo", "");
                jsonObject.put("serviceName", "");
            }
            jsonObject.put("govAgencyCode", dossier.getGovAgencyCode());
            jsonObject.put("govAgencyName", dossier.getGovAgencyName());
            jsonObject.put("subjectName", dossier.getSubjectName());
            jsonObject.put("address", dossier.getAddress());
            jsonObject.put("cityCode", dossier.getCityCode());
            jsonObject.put("cityName", dossier.getCityName());
            jsonObject.put("districtCode", dossier.getDistrictCode());
            jsonObject.put("districtName", dossier.getDistrictName());
            jsonObject.put("wardCode", dossier.getWardCode());
            jsonObject.put("wardName", dossier.getWardName());
            jsonObject.put("contactName", dossier.getContactName());
            jsonObject.put("contactTelNo", dossier.getContactTelNo());
            jsonObject.put("contactEmail", dossier.getContactEmail());
            jsonObject.put("note", dossier.getNote());
            if (dossier.getSubmitDatetime() != null) {
                jsonObject.put("submitDatetime", sdf.format(dossier.getSubmitDatetime()));
            }
            if (dossier.getReceiveDatetime() != null) {
                jsonObject.put("receiveDatetime", sdf.format(dossier.getReceiveDatetime()));
            }
            jsonObject.put("receptionNo", dossier.getReceptionNo());
            if (dossier.getEstimateDatetime() != null) {
                jsonObject.put("estimateDatetime", sdf.format(dossier.getEstimateDatetime()));
            }
            if (dossier.getFinishDatetime() != null) {
                jsonObject.put("finishDatetime", sdf.format(dossier.getFinishDatetime()));
            }
            jsonObject.put("dossierStatus", dossier.getDossierStatus());
            jsonObject.put("delayStatus", dossier.getDelayStatus());

            List<DossierFile> dossierFiles = DossierFileLocalServiceUtil
                    .getDossierFileByDossierId(dossier.getDossierId());
            JSONArray dfArr = JSONFactoryUtil.createJSONArray();

            for (DossierFile df : dossierFiles) {
                JSONObject jsonDossierFile = JSONFactoryUtil.createJSONObject();
                jsonDossierFile.put("dossierFileOid", df.getOid());
                try {
                    DossierPart dpart = DossierPartLocalServiceUtil.getDossierPart(df.getDossierPartId());
                    jsonDossierFile.put("dossierPartNo", dpart.getPartNo());
                } catch (NoSuchDossierPartException e) {

                } catch (PortalException e) {
                    // TODO Auto-generated catch block

                }
                jsonDossierFile.put("dossierFileName", df.getDisplayName());
                jsonDossierFile.put("templateFileNo", df.getTemplateFileNo());
                jsonDossierFile.put("dossierFileNo", df.getDossierFileNo());
                if (df.getFileEntryId() > 0) {
                    System.out.println("FILE ENTRY==============" + df.getFileEntryId());
                    FileEntry fileEntry;
                    try {
                        fileEntry = DLAppLocalServiceUtil.getFileEntry(df.getFileEntryId());
                        jsonDossierFile.put("dossierFullFileName",
                                df.getDisplayName() + "." + fileEntry.getExtension());

                        String url = PortletProps.get("VIRTUAL_HOST") + ":" + PortletProps.get("VIRTUAL_PORT")
                                + "/documents/" + fileEntry.getGroupId() + StringPool.SLASH
                                + fileEntry.getFolderId() + StringPool.SLASH + fileEntry.getTitle()
                                + "?version=" + fileEntry.getVersion();

                        jsonDossierFile.put("dossierFileURL", url);

                    } catch (PortalException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } else {
                    jsonDossierFile.put("dossierFileContent", df.getFormData());
                    jsonDossierFile.put("dossierFileURL", "");
                }

                if (df.getDossierFileDate() != null) {
                    jsonDossierFile.put("dossierFileDate", sdf.format(df.getDossierFileDate()));
                }
                dfArr.put(jsonDossierFile);
            }

            jsonObject.put("dossierFiles", dfArr);
            System.out.println("COME HERE IN GET DOSSIER BY OID==========");
            try {
                ServiceContext serviceContext = new ServiceContext();
                serviceContext.setUserId(getUser().getUserId());
                serviceContext.setScopeGroupId(getUser().getGroupId());
                serviceContext.setCompanyId(getUser().getCompanyId());
                String ipAddress = PortalUtil.getComputerAddress();

                JSONObject params = JSONFactoryUtil.createJSONObject();
                params.put("oid", oid);

                ApiServiceLocalServiceUtil.addApiService(getUser().getUserId(), "03", ipAddress, "",
                        params.toString(), "success", serviceContext);
            } catch (SystemException se) {
                _log.error(se);
            } catch (PortalException pe) {
                _log.error(pe);
            }
        } else {
            jsonObject.put("statusCode", "DossierNotFound");
            _log.info("COME HERE===============");
            try {
                ServiceContext serviceContext = new ServiceContext();
                serviceContext.setUserId(getUser().getUserId());
                serviceContext.setScopeGroupId(getUser().getGroupId());
                serviceContext.setCompanyId(getUser().getCompanyId());
                String ipAddress = PortalUtil.getComputerAddress();

                JSONObject params = JSONFactoryUtil.createJSONObject();
                params.put("oid", oid);

                ApiServiceLocalServiceUtil.addApiService(getUser().getUserId(), "03", ipAddress, "",
                        params.toString(), "error", serviceContext);
            } catch (SystemException se) {
                _log.error(se);
            } catch (PortalException pe) {
                _log.error(pe);
            }
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        jsonObject.put("statusCode", "DossierNotFound");
        _log.info("COME HERE===============");
        try {
            ServiceContext serviceContext = new ServiceContext();
            serviceContext.setUserId(getUser().getUserId());
            serviceContext.setScopeGroupId(getUser().getGroupId());
            serviceContext.setCompanyId(getUser().getCompanyId());
            String ipAddress = PortalUtil.getComputerAddress();

            JSONObject params = JSONFactoryUtil.createJSONObject();
            params.put("oid", oid);

            ApiServiceLocalServiceUtil.addApiService(getUser().getUserId(), "03", ipAddress, "",
                    params.toString(), "error", serviceContext);
        } catch (SystemException se) {
            _log.error(se);
        } catch (PortalException pe) {
            _log.error(pe);
        }

    }

    return jsonObject;
}