List of usage examples for com.liferay.portal.kernel.webdav WebDAVRequest getPath
public String getPath();
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public Resource getResource(WebDAVRequest webDAVRequest) throws WebDAVException { try {// www . ja v a2 s. c o m String[] pathArray = webDAVRequest.getPathArray(); long companyId = webDAVRequest.getCompanyId(); long parentFolderId = getParentFolderId(companyId, pathArray); String name = WebDAVUtil.getResourceName(pathArray); if (Validator.isNull(name)) { String path = getRootPath() + webDAVRequest.getPath(); return new BaseResourceImpl(path, StringPool.BLANK, getToken()); } try { Folder folder = _dlAppService.getFolder(webDAVRequest.getGroupId(), parentFolderId, name); if ((folder.getParentFolderId() != parentFolderId) || (webDAVRequest.getGroupId() != folder.getRepositoryId())) { StringBundler sb = new StringBundler(6); sb.append("No DLFolder exists with the key "); sb.append("{parendFolderId="); sb.append(parentFolderId); sb.append(", repositoryId="); sb.append(webDAVRequest.getGroupId()); sb.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchFolderException(sb.toString()); } return toResource(webDAVRequest, folder, false); } catch (NoSuchFolderException nsfe) { if (_log.isDebugEnabled()) { _log.debug(nsfe, nsfe); } try { String title = getTitle(pathArray); FileEntry fileEntry = _dlAppService.getFileEntry(webDAVRequest.getGroupId(), parentFolderId, title); return toResource(webDAVRequest, fileEntry, false); } catch (NoSuchFileEntryException nsfee) { if (_log.isDebugEnabled()) { _log.debug(nsfee, nsfee); } return null; } } } catch (Exception e) { throw new WebDAVException(e); } }
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
protected Resource toResource(WebDAVRequest webDAVRequest, Folder folder, boolean appendPath) { String parentPath = getRootPath() + webDAVRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = folder.getName();/* w ww . j a v a 2s . co m*/ } Resource resource = new BaseResourceImpl(parentPath, name, folder.getName(), folder.getCreateDate(), folder.getModifiedDate()); resource.setModel(folder); resource.setClassName(Folder.class.getName()); resource.setPrimaryKey(folder.getPrimaryKey()); return resource; }
From source file:com.liferay.dynamic.data.mapping.webdav.DDMWebDav.java
License:Open Source License
public Resource getResource(WebDAVRequest webDAVRequest, String rootPath, String token, long classNameId) throws WebDAVException { try {/*from w w w .j a v a 2s . com*/ String[] pathArray = webDAVRequest.getPathArray(); if (pathArray.length == 2) { String path = rootPath + webDAVRequest.getPath(); return new BaseResourceImpl(path, StringPool.BLANK, token); } else if (pathArray.length == 3) { String type = pathArray[2]; return toResource(webDAVRequest, type, rootPath, false); } else if (pathArray.length == 4) { String type = pathArray[2]; String typeId = pathArray[3]; if (type.equals(TYPE_STRUCTURES)) { DDMStructure structure = _ddmStructureLocalService.fetchStructure(GetterUtil.getLong(typeId)); if (structure == null) { structure = _ddmStructureLocalService.fetchStructure(webDAVRequest.getGroupId(), classNameId, typeId); } if (structure == null) { return null; } return toResource(webDAVRequest, structure, rootPath, false); } else if (type.equals(TYPE_TEMPLATES)) { DDMTemplate template = _ddmTemplateLocalService.fetchDDMTemplate(GetterUtil.getLong(typeId)); if (template == null) { template = _ddmTemplateLocalService.fetchTemplate(webDAVRequest.getGroupId(), classNameId, typeId); } if (template == null) { return null; } return toResource(webDAVRequest, template, rootPath, false); } } return null; } catch (Exception e) { throw new WebDAVException(e); } }
From source file:com.liferay.dynamic.data.mapping.webdav.DDMWebDav.java
License:Open Source License
public Resource toResource(WebDAVRequest webDAVRequest, DDMStructure structure, String rootPath, boolean appendPath) { String parentPath = rootPath + webDAVRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = String.valueOf(structure.getStructureId()); }/* w w w .ja v a 2s. com*/ return new DDMStructureResourceImpl(structure, parentPath, name); }
From source file:com.liferay.dynamic.data.mapping.webdav.DDMWebDav.java
License:Open Source License
public Resource toResource(WebDAVRequest webDAVRequest, DDMTemplate template, String rootPath, boolean appendPath) { String parentPath = rootPath + webDAVRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = String.valueOf(template.getTemplateId()); }//from w w w. ja v a 2 s. c o m return new DDMTemplateResourceImpl(template, parentPath, name); }
From source file:com.liferay.dynamic.data.mapping.webdav.DDMWebDav.java
License:Open Source License
public Resource toResource(WebDAVRequest webDAVRequest, String type, String rootPath, boolean appendPath) { String parentPath = rootPath + webDAVRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = type;// w w w.ja va 2s. c o m } Resource resource = new BaseResourceImpl(parentPath, name, type); resource.setModel(type); return resource; }
From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java
License:Open Source License
public Resource getResource(WebDAVRequest webDavRequest) throws WebDAVException { try {// w w w. j a v a 2 s . c o m String[] pathArray = webDavRequest.getPathArray(); long companyId = webDavRequest.getCompanyId(); long parentFolderId = getParentFolderId(companyId, pathArray); String name = WebDAVUtil.getResourceName(pathArray); if (Validator.isNull(name)) { String path = getRootPath() + webDavRequest.getPath(); return new BaseResourceImpl(path, StringPool.BLANK, getToken()); } try { Folder folder = DLAppServiceUtil.getFolder(webDavRequest.getGroupId(), parentFolderId, name); if ((folder.getParentFolderId() != parentFolderId) || (webDavRequest.getGroupId() != folder.getRepositoryId())) { throw new NoSuchFolderException(); } return toResource(webDavRequest, folder, false); } catch (NoSuchFolderException nsfe) { try { String titleWithExtension = name; FileEntry fileEntry = DLAppServiceUtil.getFileEntry(webDavRequest.getGroupId(), parentFolderId, titleWithExtension); return toResource(webDavRequest, fileEntry, false); } catch (NoSuchFileEntryException nsfee) { return null; } } } catch (Exception e) { throw new WebDAVException(e); } }
From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java
License:Open Source License
protected Resource toResource(WebDAVRequest webDavRequest, FileEntry fileEntry, boolean appendPath) { String parentPath = getRootPath() + webDavRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = fileEntry.getTitle();//from w ww . j av a2 s . c om } return new DLFileEntryResourceImpl(webDavRequest, fileEntry, parentPath, name); }
From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java
License:Open Source License
protected Resource toResource(WebDAVRequest webDavRequest, Folder folder, boolean appendPath) { String parentPath = getRootPath() + webDavRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = folder.getName();//from ww w .j av a 2 s . c o m } Resource resource = new BaseResourceImpl(parentPath, name, folder.getName(), folder.getCreateDate(), folder.getModifiedDate()); resource.setModel(folder); resource.setClassName(Folder.class.getName()); resource.setPrimaryKey(folder.getPrimaryKey()); return resource; }
From source file:com.liferay.portlet.journal.webdav.JournalWebDAVStorageImpl.java
License:Open Source License
public Resource getResource(WebDAVRequest webDavRequest) throws WebDAVException { try {/*w w w . jav a2 s . co m*/ String[] pathArray = webDavRequest.getPathArray(); if (pathArray.length == 2) { String path = getRootPath() + webDavRequest.getPath(); return new BaseResourceImpl(path, StringPool.BLANK, getToken()); } else if (pathArray.length == 3) { String type = pathArray[2]; return toResource(webDavRequest, type, false); } else if (pathArray.length == 4) { String type = pathArray[2]; String journalTypeId = pathArray[3]; if (type.equals(_TYPE_STRUCTURES)) { try { JournalStructure journalStructure = JournalStructureServiceUtil .getStructure(webDavRequest.getGroupId(), journalTypeId, true); return toResource(webDavRequest, journalStructure, false); } catch (NoSuchStructureException nsse) { return null; } } else if (type.equals(_TYPE_TEMPLATES)) { try { JournalTemplate journalTemplate = JournalTemplateServiceUtil .getTemplate(webDavRequest.getGroupId(), journalTypeId, true); return toResource(webDavRequest, journalTemplate, false); } catch (NoSuchTemplateException nste) { return null; } } } return null; } catch (Exception e) { throw new WebDAVException(e); } }