Beispiel #1
0
        private string doDeleteContainer(string line)
        {
            string givenContainerName = line;

            if (line.Equals(this.loggedInUsername))
            {
                return(MESSAGES.ERR);
            }
            Services.IResourceManage r = new Services.Resource();
            //int uid = srv.getAzureLink().findUserId(this.loggedInUserid);
            int rid = r.getContainerID(loggedInUserid, givenContainerName);

            if (rid == -1)
            {
                return(MESSAGES.E_NOFOLDER);
            }
            if (!r.isOwner(loggedInUserid, rid))
            {
                return(MESSAGES.E_NOACCESS);
            }
            try
            {
                r.deleteSharedContainer(rid);
            }
            catch (ArgumentException e)
            {
                if (e.Message.Equals("container not empty"))
                {
                    return(MESSAGES.E_NOTEMPTY);
                }
                else
                {
                    throw;
                }
            }
            return(MESSAGES.OK);
        }
Beispiel #2
0
        private string doList(string line)
        {
            if (!isLoggedIn())
            {
                return(MESSAGES.ERR);
            }

            var cloudInfo = srv.getAzureLink().getUserCloudFileSystem(this.loggedInUsername);

            StringBuilder replyStr = new StringBuilder();

            replyStr.Append("<?xml version='1.0' encoding='UTF-8'?>\r\n");
            replyStr.Append("<cloudinfo>\r\n");
            Services.IResourceManage mg = new Services.Resource();
            /* this is INCREDIBLY FUGLY CODE */


            //int uid = srv.getAzureLink().findUserId(this.loggedInUserid);
            foreach (String containerName in cloudInfo.Keys)
            {
                replyStr.Append("\t<container name='");
                replyStr.Append(containerName);
                replyStr.Append("' access='");
                int containerID = mg.getContainerID(loggedInUserid, containerName);

                if (mg.isOwner(loggedInUserid, containerID))
                {
                    replyStr.Append("owner");
                }
                else if (mg.canWrite(loggedInUserid, containerID))
                {
                    replyStr.Append("readwrite");
                }
                else
                {
                    replyStr.Append("readonly");
                }
                replyStr.Append("'>\r\n");

                var containerFiles = cloudInfo[containerName];
                foreach (String fileName in containerFiles.Keys)
                {
                    var file = containerFiles[fileName];
                    replyStr.Append("\t\t<file name='" + fileName + "' ");
                    replyStr.Append(" size='" + file.getSize() + "' ");
                    replyStr.Append(" timestamp='" + file.getLastmodifiedTime() + "' ");
                    replyStr.Append(" md5='" + file.getMD5HashValue() + "'");
                    replyStr.Append(" deleted='" + file.isDeleted() + "'");
                    replyStr.Append(" />\r\n");
                    //replyStr.Append("\t\t</file>\r\n");
                }
                if (mg.isOwner(loggedInUserid, containerID))
                {
                    string sharedUsersXML = makeSharedUsersXML(containerID);
                    replyStr.Append(sharedUsersXML);
                }
                replyStr.Append("\t</container>\r\n");
            }
            replyStr.Append("</cloudinfo>");
            replyStr.Replace('\'', '\"');
            return(replyStr.ToString());
        }