List of usage examples for com.liferay.portal.kernel.webdav BaseResourceImpl BaseResourceImpl
public BaseResourceImpl(String parentPath, String name, String displayName)
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 {// w w w .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.dynamic.data.mapping.webdav.DDMWebDav.java
License:Open Source License
public Resource getResource(WebDAVRequest webDAVRequest, String rootPath, String token, long classNameId) throws WebDAVException { try {//w w w. ja v a2s .co m 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, String type, String rootPath, boolean appendPath) { String parentPath = rootPath + webDAVRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = type;/*from w w w . j av a 2 s .c om*/ } 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 {//from w w w . j a v a 2 s . co 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.journal.webdav.JournalWebDAVStorageImpl.java
License:Open Source License
public Resource getResource(WebDAVRequest webDavRequest) throws WebDAVException { try {/*from w ww .j av a 2 s . com*/ 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); } }
From source file:com.liferay.portlet.journal.webdav.JournalWebDAVStorageImpl.java
License:Open Source License
protected Resource toResource(WebDAVRequest webDavRequest, String type, boolean appendPath) { String parentPath = getRootPath() + webDavRequest.getPath(); String name = StringPool.BLANK; if (appendPath) { name = type;// ww w. j a v a 2s . co m } Resource resource = new BaseResourceImpl(parentPath, name, type); resource.setModel(type); return resource; }