private List <Folder> GetFolders(IFolderInfo fldObj, AdamAppContext appContext = null) { var firstList = _folderManager.GetFolders(fldObj); var folders = firstList?.Select(f => DnnToAdam(appContext, f)).ToList() ?? new List <Folder>(); return(folders); }
public IAdamFileSystem <int, int> Init(AdamAppContext <int, int> adamContext, ILog parentLog) { Log.LinkTo(parentLog); var wrapLog = Log.Call(); AdamContext = adamContext; wrapLog("ok"); return(this); }
protected override void PrepCore(IApp app, Guid entityGuid, string fieldName, bool usePortalRoot) { Log.Add("PrepCore(...)"); AdamAppContext = new AdamAppContext <TFolderId, TFileId>(); AdamAppContext.Init(Permissions.Context.Tenant, app, Block, 10, Log); ContainerContext = usePortalRoot ? new AdamOfTenant <TFolderId, TFileId>(AdamAppContext) as AdamOfBase <TFolderId, TFileId> : new AdamOfField <TFolderId, TFileId>(AdamAppContext, entityGuid, fieldName); }
private void PrepCore(App app, Guid entityGuid, string fieldName, bool usePortalRoot) { var tenant = new DnnTenant(Dnn.Portal); AdamAppContext = new AdamAppContext(tenant, app, SxcInstance); ContainerContext = usePortalRoot ? new ContainerOfTenant(AdamAppContext) as ContainerBase : new ContainerOfField(AdamAppContext, entityGuid, fieldName); }
/// <inheritdoc /> public IFolder AsAdam(IEntity entity, string fieldName) { var envFs = Factory.Resolve <IEnvironmentFileSystem>(); if (_adamAppContext == null) { _adamAppContext = new AdamAppContext(_tenant, App, BlockBuilder, CompatibilityLevel, Log); } return(new FolderOfField(envFs, _adamAppContext, entity.EntityGuid, fieldName)); }
/// <summary> /// Provides an Adam instance for this item and field /// </summary> /// <param name="entity">The entity, often Content or similar</param> /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param> /// <returns>An Adam object for navigating the assets</returns> public FolderOfField AsAdam(Eav.Interfaces.IEntity entity, string fieldName) { var envFs = Factory.Resolve <IEnvironmentFileSystem>(); if (_adamAppContext == null) { _adamAppContext = new AdamAppContext(_tenant, App, SxcInstance, Log); } return(new FolderOfField(envFs, _adamAppContext, entity.EntityGuid, fieldName)); }
private void PrepCore(App app, Guid entityGuid, string fieldName, bool usePortalRoot) { Log.Add("PrepCore(...)"); var dnn = new DnnHelper(SxcInstance?.EnvInstance); var tenant = new DnnTenant(dnn.Portal); AdamAppContext = new AdamAppContext(tenant, app, SxcInstance, Log); ContainerContext = usePortalRoot ? new ContainerOfTenant(AdamAppContext) as ContainerBase : new ContainerOfField(AdamAppContext, entityGuid, fieldName); }
private void PrepCore(IApp app, Guid entityGuid, string fieldName, bool usePortalRoot) { Log.Add("PrepCore(...)"); var dnn = new DnnContext(BlockBuilder?.Container); var tenant = new DnnTenant(dnn.Portal); AdamAppContext = new AdamAppContext(tenant, app, BlockBuilder, 10, Log); ContainerContext = usePortalRoot ? new ContainerOfTenant(AdamAppContext) as ContainerBase : new ContainerOfField(AdamAppContext, entityGuid, fieldName); }
private Folder DnnToAdam(AdamAppContext appContext, IFolderInfo f) => new Folder(appContext, this) { Path = f.FolderPath, Id = f.FolderID, Name = f.DisplayName, Created = f.CreatedOnDate, Modified = f.LastUpdated, // note: there are more properties in the DNN data, but we don't use it, // because it will probably never be cross-platform };
public override XmlExporter Init(int zoneId, int appId, AppRuntime appRuntime, bool appExport, string[] attrSetIds, string[] entityIds, Log parentLog) { var tenant = new DnnTenant(PortalSettings.Current); var app = new App(tenant, zoneId, appId); AdamAppContext = new AdamAppContext(tenant, app, null); Constructor(zoneId, appRuntime, app.AppGuid, appExport, attrSetIds, entityIds, parentLog); // this must happen very early, to ensure that the file-lists etc. are correct for exporting when used externally InitExportXDocument(PortalSettings.Current.DefaultLanguage, Settings.ModuleVersion); return(this); }
public List <File> GetFiles(int folderId, AdamAppContext appContext) { var fldObj = _folderManager.GetFolder(folderId); // sometimes the folder doesn't exist for whatever reason if (fldObj == null) { return(new List <File>()); } // try to find the files var firstList = _folderManager.GetFiles(fldObj); var files = firstList?.Select(f => DnnToAdam(appContext, f)).ToList() ?? new List <File>(); return(files); }
private static File DnnToAdam(AdamAppContext appContext, IFileInfo f) => new File(appContext) { FullName = f.FileName, Extension = f.Extension, Size = f.Size, Id = f.FileId, Folder = f.Folder, FolderId = f.FolderId, Path = f.RelativePath, Created = f.CreatedOnDate, Name = System.IO.Path.GetFileNameWithoutExtension(f.FileName) // note: there are more properties in the DNN data, but we don't use it, // because it will probably never be cross-platform };
public IAdamFileSystem <string, string> Init(AdamAppContext <string, string> adamContext, ILog parentLog) { Log.LinkTo(parentLog); AdamContext = adamContext; return(this); }
public IAdamFileSystem <int, int> Init(AdamAppContext <int, int> adamContext, ILog parentLog) { Log.LinkTo(parentLog); AdamContext = adamContext; return(this); }
public AdamOfTenant(AdamAppContext <TFolderId, TFileId> appContext) : base(appContext) { }
protected ContainerBase(AdamAppContext appContext) { AppContext = appContext; }
protected AdamOfBase(AdamAppContext <TFolderId, TFileId> appContext) { AppContext = appContext; }
public IFile UploadOne(Stream stream, string originalFileName, string contentType, Guid guid, string field, string subFolder, bool usePortalRoot, bool skipFieldAndContentTypePermissionCheck) { Log.Add($"upload one a:{_appId}, i:{guid}, field:{field}, subfold:{subFolder}, useRoot:{usePortalRoot}"); var state = new AdamSecureState(BlockBuilder, _appId, contentType, field, guid, usePortalRoot, Log); HttpResponseException exp; if (!skipFieldAndContentTypePermissionCheck) { if (!state.UserIsPermittedOnField(GrantSets.WriteSomething, out exp)) { throw exp; } // check that if the user should only see drafts, he doesn't see items of published data if (!state.UserIsNotRestrictedOrItemIsDraft(guid, out var permissionException)) { throw permissionException; } } var folder = state.ContainerContext.Folder(); if (!string.IsNullOrEmpty(subFolder)) { folder = state.ContainerContext.Folder(subFolder, false); } // start with a security check... var dnnFolder = FolderManager.Instance.GetFolder(folder.Id); // validate that dnn user have write permissions for folder in case dnn file system is used (usePortalRoot) if (usePortalRoot && !SecurityChecks.CanEdit(dnnFolder)) { throw Http.PermissionDenied("can't upload - permission denied"); } // we only upload into valid adam if that's the scenario if (!state.SuperUserOrAccessingItemFolder(dnnFolder.PhysicalPath, out exp)) { throw exp; } #region check content-type extensions... // Check file size and extension var fileName = String.Copy(originalFileName); if (!state.ExtensionIsOk(fileName, out exp)) { throw exp; } // check metadata of the FieldDef to see if still allowed extension var additionalFilter = state.Attribute.Metadata.GetBestValue <string>("FileFilter"); if (!string.IsNullOrWhiteSpace(additionalFilter) && !state.CustomFileFilterOk(additionalFilter, originalFileName)) { throw Http.NotAllowedFileType(fileName, "field has custom file-filter, which doesn't match"); } // note 2018-04-20 2dm: can't do this for wysiwyg, as it doesn't have a setting for allowed file-uploads #endregion if (stream.Length > 1024 * MaxFileSizeKb) { throw new Exception($"file too large - more than {MaxFileSizeKb}Kb"); } // remove forbidden / troubling file name characters fileName = fileName .Replace("+", "plus") .Replace("%", "per") .Replace("#", "hash"); if (fileName != originalFileName) { Log.Add($"cleaned file name from'{originalFileName}' to '{fileName}'"); } // Make sure the image does not exist yet, cycle through numbers (change file name) fileName = RenameFileToNotOverwriteExisting(fileName, dnnFolder); // Everything is ok, add file to DNN var dnnFile = FileManager.Instance.AddFile(dnnFolder, Path.GetFileName(fileName), stream); var adamcontext = new AdamAppContext(BlockBuilder.Block.Tenant, state.App, BlockBuilder, 10, Log); var eavFile = new File(adamcontext) { Created = dnnFile.CreatedOnDate, Extension = dnnFile.Extension, FullName = dnnFile.FileName, Folder = dnnFile.Folder, FolderId = dnnFile.FolderId, Id = dnnFile.FileId, Modified = dnnFile.LastModificationTime }; return(eavFile); }
public DnnXmlExporter(AdamAppContext <int, int> adamAppContext, IContextResolver ctxResolver, XmlSerializer xmlSerializer) : base(xmlSerializer, DnnConstants.LogName) { _ctxResolver = ctxResolver.Init(Log); AdamAppContext = adamAppContext; }
public Eav.Apps.Assets.Folder Get(int tenantId, string path, AdamAppContext appContext) => DnnToAdam(appContext, _folderManager.GetFolder(tenantId, path));
public List <Folder> GetFolders(int folderId, AdamAppContext appContext) => GetFolders(GetFolder(folderId), appContext);
public AdamOfSite(AdamAppContext <TFolderId, TFileId> appContext) : base(appContext) { }
public ContainerOfTenant(AdamAppContext appContext) : base(appContext) { }