Changeset 980


Ignore:
Timestamp:
12/10/10 22:05:19 (13 years ago)
Author:
gaba
Message:

admin/cache/del - created, notifyUser-messages

Location:
MDService2/trunk/MDService2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/WebContent/index.jsp

    r945 r980  
    3939                                        <% }%>
    4040                        </div>
    41                 <div id="notify" class="cmds-elem-plus note"></div>
     41                        <div id="notify" class="cmds-elem-plus note" >
     42                                <div id="notifylist" class="note"> <!--  class="cmds-elem-plus note" > -->
     43                                </div>
     44                        </div>
     45                       
     46               
    4247        <!-- <a href="static/profiles_stats.html" >Info from CompReg and DCR about Elements vs. DatCats</a>  -->
    4348        </div>
     
    143148        <div id="detail-float"> 
    144149        </div>
     150        <div id="notify-float"> 
     151        </div>
    145152        <div id="detail">               
    146153        </div> 
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js

    r961 r980  
    118118
    119119
     120function showNotifyMessages(){
     121        try {
     122                $('#notify-float').html($('#notify').html());
     123                var title = "Notify - Messages";
     124                $('#notify-float').dialog( "option", "title", title );
     125               
     126                //ui-state-default
     127                $('#notify-float').dialog('open');
     128                $('#notify-float').siblings('div.ui-dialog-titlebar').addClass('ui-state-default');
     129                $('#notify-float').siblings('div.ui-dialog-titlebar').children().remove();
     130                var x = '<span class="cmd cmd_del ui-dialog-titlebar-del "/><span class="cmd cmd_up ui-dialog-titlebar-up"/><span>' + title +'</span>';
     131                $('#notify-float').siblings('div.ui-dialog-titlebar').prepend(x);
     132               
     133                } catch (e) {
     134                        notifyUser(e,'debug');
     135                }               
     136}
     137
    120138function showDetail(data, textStatus) {
    121139        try {
     
    159177}
    160178
    161 function notifyUser (msg) {     
    162           $('#notify').text(msg);         
     179function getNotifyMessagesText(){
     180        var text = "";
     181        for(var i=0;i<notify_messages.length;i++){
     182                text = text  + "/n" + notify_messages[i].getText();
     183        }
     184        return text;
     185}
     186function notifyUser (msg) {
     187        var notifymessage = new NotifyMessage(new Date(),msg); 
     188        notifyset.add(notifymessage);
     189          //notify_messages[notify_messages.length] = new NotifyMessage( new Date(),msg);
     190          //$('#notify').text(msg);
     191          //$('#notify').text(getNotifyMessagesText());
     192          //$('#notify-all').find('textarea').attr("value",$('#notify-all').find('textarea').attr("value") + '\n' + msg);
    163193}
    164194
     
    168198                        console.log(msg);
    169199                } else {
    170                 $('#notify').text(msg);   
     200                        var notifymessage = new NotifyMessage(new Date(),msg); 
     201                        notifyset.add(notifymessage);
     202                        //notify_messages[notify_messages.length] = new NotifyMessage(new Date(),msg);
     203                        //$('#notify').text(msg);       
     204                        //$('#notify').text(getNotifyMessagesText());
     205                        //$('#notify-all').find('textarea').attr("value",$('#notify-all').find('textarea').attr("value") + '\n' + msg);
    171206          }
    172207}
     
    176211function addToQuerylist (x) {   
    177212        $("#querylist").prepend(x);     
     213}
     214
     215function addToNotifylist (x) { 
     216        $("#notifylist").prepend(x);   
    178217}
    179218
     
    13031342        $('.ui-dialog-titlebar-up').live('click', function(event){
    13041343                var t = $(this).parents('.ui-widget').children('.ui-dialog-content');
    1305                 $(t).find(".ui-dialog-buttonpane:first, .ui-dialog-content").stop({clearQueue:true}).fadeOut(300);
    1306                 $(t).stop({clearQueue:true}).animate({height:'0px'},300)
     1344               
     1345                $(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height());
     1346                //notifyUser("up(height):" + $(this).parents('.ui-widget').height(),'debug');
     1347                $(this).parents('.ui-widget').height(30);
     1348                //notifyUser("up(tempheight):" + $(this).parents('.ui-widget').attr("tempheight"),'debug');
     1349               
     1350               
     1351                //$(t).find(".ui-dialog-buttonpane:first, .ui-dialog-content").stop({clearQueue:true}).fadeOut(300);
     1352                //$(t).stop({clearQueue:true}).animate({height:'0px'},300);
    13071353               
    13081354                $(this).removeClass('cmd_up ui-dialog-titlebar-up');
     
    13111357        $('.ui-dialog-titlebar-down').live('click', function(event){
    13121358                var t = $(this).parents('.ui-widget').children('.ui-dialog-content');
    1313                 $(t).find(".ui-dialog-content, .ui-dialog-buttonpane:first").stop({clearQueue:true}).fadeIn(800)
    1314                 .end().stop({clearQueue:true}).animate({height:'100%'},300);
     1359               
     1360                var h = $(this).parents('.ui-widget').attr("tempheight");
     1361                //notifyUser("down(tempheight):" + h,'debug');
     1362                $(this).parents('.ui-widget').height(parseInt(h));
     1363                //notifyUser("down(height):" + $(this).parents('.ui-widget').height(),'debug');
     1364               
     1365               
     1366                //$(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height());
     1367                //$(t).find(".ui-dialog-content, .ui-dialog-buttonpane:first").stop({clearQueue:true}).fadeIn(800)
     1368                //.end().stop({clearQueue:true}).animate({height:'100%'},300);
    13151369
    13161370                $(this).removeClass('cmd_down ui-dialog-titlebar-down');
     
    13571411                        $("#detail-float").dialog();
    13581412                        $("#detail-float").tabs();
     1413                       
     1414                        /// notify-messages
     1415                        $("#notify-float").dialog({ autoOpen: false,
     1416                                position: ['right','10px'],
     1417                                height: 200,
     1418                                width: 400,
     1419                                minHeigh: 100});                       
     1420                        $("#notify-float").dialog();
     1421                        $("#notify-float").tabs();
    13591422
    13601423}
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_widgets.js

    r945 r980  
     1
     2
     3function NotifyMessage(dt, msg){
     4        this.dt = dt;
     5        this.msg = msg;
     6};
     7
     8NotifyMessage.prototype.getText = function(){
     9
     10        var month = this.dt.getMonth() + 1;
     11        var day = this.dt.getDate();
     12        var year = this.dt.getFullYear();
     13        var h = this.dt.getHours();
     14        var m = this.dt.getMinutes();
     15        var s = this.dt.getSeconds();
     16        var m =  year + "-" +  month + "-" + day + " "  + h + ":" + m + ":" + s + "  :" + this.msg;
     17        return m;
     18};
     19
     20
     21NotifyMessage.prototype.render = function () {
     22        var x = "<div id='" + this.listid + "' class='notify_wrapper ui-widget' >" +
     23                        //"<span class='notifymessage_id'>" + this.listid + "</span>: " +
     24                        "<span class='notifymessage'>" + this.getText() + "</span></div>";
     25        addToNotifylist(x);     
     26       
     27        this.container = $('#' + this.listid );
     28        $(this.container).find('.notifymessage').dblclick(function(){
     29                showNotifyMessages();
     30        });
     31 };
     32var notify_container = $("#notifylist");
     33
     34var notifyset = { notifymessages: [],
     35        container: '#notifylist',
     36               
     37        add: function (notifymessage){
     38                       
     39                this.notifymessages[this.notifymessages.length] = notifymessage;
     40                notifymessage.listid = "nm" + this.notifymessages.length;
     41                notifymessage.render();                         
     42        },
     43
     44        remove: function (mid) {               
     45                 for (var i = 0; i < this.notifymessages.length; i++) {
     46                        if (this.notifymessages[i].listid == mid) {
     47                                this.notifymessages.splice(i, 1);
     48                        }
     49                }       
     50                $('#' + mid).remove();
     51        }       
     52};
     53////////////////////////////////////////////////////////////////////////
     54
    155var collections_widget = null;
    256var columns_widget = null;
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/AdminAction.java

    r893 r980  
    11package eu.clarin.cmdi.mdservice.action;
    22
     3import java.io.ByteArrayInputStream;
    34import java.io.IOException;
    45import java.net.MalformedURLException;
    56import java.net.URL;
     7import java.text.DateFormat;
     8import java.text.SimpleDateFormat;
     9import java.util.Date;
     10import java.util.HashMap;
    611
    712import net.sf.json.JSONObject;
     
    1823       
    1924        private String proxy_key = "admin";
     25        private String date;
     26        private String datefrom;
     27        private String dateto;
     28       
     29        @Override
     30        protected void  initialize(){
     31                setRepository(0);
     32         }
     33        public String getDate() {
     34                return date;
     35        }
    2036
     37        public void setDate(String date) {
     38                this.date = date;
     39        }
     40       
     41        public String getDatefrom() {
     42                return datefrom;
     43        }
     44
     45        public void setDatefrom(String datefrom) {
     46                this.datefrom = datefrom;
     47        }
     48
     49        public String getDateto() {
     50                return dateto;
     51        }
     52
     53        public void setDateto(String dateto) {
     54                this.dateto = dateto;
     55        }
     56
     57       
    2158        @Override
    2259        public String getFullFormat() {
     
    3471        }
    3572
     73        public String del() throws Exception {
     74               
     75                HashMap<String,String> clear_params = new HashMap<String,String>();
     76                if (this.getActionkey() != null){
     77                        clear_params.put("type", getActionkey());       
     78                }
     79                if (this.getRepository() != 0){
     80                        clear_params.put("repository", String.valueOf(getRepository()));       
     81                }       
     82                if (this.getDate() != null){
     83                        clear_params.put("date", getDate());   
     84                }
     85                if (this.getDatefrom() != null){
     86                        clear_params.put("datefrom", getDatefrom());   
     87                }
     88                if (this.getDateto() != null){
     89                        clear_params.put("dateto", getDateto());       
     90                }
     91                //int removed;
     92                this.setResultStream(Cache.getCache().clear(clear_params));
     93               
     94                //String ret = "1";
     95                //this.setResultStream( new ByteArrayInputStream(String.valueOf(removed).getBytes()));
     96               
     97                return SUCCESS;
     98               
     99               
     100        }
    36101       
    37 }
     102        }
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java

    r890 r980  
    1515*/
    1616import java.util.Date;
     17import java.util.HashMap;
    1718import java.text.DateFormat;
    1819import java.text.SimpleDateFormat;
     
    171172                }
    172173               
    173                 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd:hh-mm-ss");
     174                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ddThh:mm:ss");
    174175                e.setAttribute("date", dateFormat.format(new Date()).toString());
    175176                cacheindex_doc.getFirstChild().appendChild(e);
     
    235236                return transformed;
    236237        }
     238       
    237239       
    238240         //TODO: sanitize-key
     
    506508                */
    507509        }
     510       
     511        public InputStream clear(HashMap<String,String> clear_params) throws ParserConfigurationException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError {
     512                String xpath_expr = "";
     513                Integer removed = 0;
     514                InputStream is = null;
     515               
     516                if (clear_params.size() > 0 ) {
     517                        if (clear_params.containsKey("repository")){
     518                                xpath_expr = xpath_expr + " and @repository='" + clear_params.get("repository") + "'";
     519                        }
     520                        if (clear_params.containsKey("type")){
     521                                xpath_expr = xpath_expr + " and @type='" + clear_params.get("type") + "'";
     522                        }
     523                        if (clear_params.containsKey("date")){
     524                                xpath_expr = xpath_expr + " and @date='" + clear_params.get("date") + "'";
     525                        }
     526                        if (clear_params.containsKey("datefrom")){
     527                                xpath_expr = xpath_expr + " and @date >= '" + clear_params.get("datefrom") + "'";
     528                        }
     529                        if (clear_params.containsKey("dateto")){
     530                                xpath_expr = xpath_expr + " and @date <= '" + clear_params.get("dateto") + "'";
     531                        }
     532                        if (xpath_expr.length()>0){
     533                                xpath_expr = xpath_expr.substring(5);
     534                        }
     535                        xpath_expr = "//index/f[" + xpath_expr + "]";
     536                } else {
     537                        xpath_expr = "//index/f";
     538                }
     539       
     540                ////////// remove index_lines  + files
     541                String id,type,path;
     542                File f;
     543                //creating an XPathFactory:
     544                XPathFactory factory = XPathFactory.newInstance();
     545                //using this factory to create an XPath object:
     546                XPath xpath = factory.newXPath();
     547                //XPath object created compiles the XPath expression:
     548                XPathExpression expr;
     549                try {
     550                        expr = xpath.compile(xpath_expr);
     551                        //expression is evaluated with respect to a certain context node which is doc.
     552                Object result = expr.evaluate(cacheindex_doc, XPathConstants.NODESET);
     553                NodeList list = (NodeList) result;
     554               
     555                //create deleted_doc
     556                DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
     557                DocumentBuilder docBuilder;
     558                        docBuilder = docFactory.newDocumentBuilder();
     559                        Document deleted_doc = docBuilder.newDocument();
     560                        Element root = (Element) deleted_doc.createElement("index");
     561                        root.setAttribute("count_deleted", String.valueOf(list.getLength()) );
     562                        deleted_doc.appendChild(root);
     563                       
     564                        // delete items
     565                        for(int i = 0;i< list.getLength();i++){
     566                               
     567                                id = list.item(i).getAttributes().getNamedItem("id").getNodeValue();
     568                        type = list.item(i).getAttributes().getNamedItem("type").getNodeValue();
     569                        path = cachepath + PREFIX + type + "_"+id + ".xml";
     570                        f = new File (path);
     571                       
     572                        f.delete();
     573                        cacheindex_doc.getFirstChild().removeChild(list.item(i));
     574                       
     575                        Element e = deleted_doc.createElement("f");
     576                        e.setAttribute("filename", path);
     577                        e.setAttribute("id", id);
     578                        deleted_doc.getFirstChild().appendChild(e);
     579                        } 
     580                       
     581                        //create resultstream
     582                        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
     583                        Source xmlSource = new DOMSource(deleted_doc);
     584                        Result outputTarget = new StreamResult(outputStream);
     585                        TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
     586                        is = new ByteArrayInputStream(outputStream.toByteArray());
     587
     588                        removed = list.getLength();
     589               
     590                } catch (XPathExpressionException e) {
     591                        // TODO Auto-generated catch block
     592                        e.printStackTrace();
     593                }
     594               
     595                //////// set the index value
     596                NodeList nl = cacheindex_doc.getElementsByTagName("f");
     597                if (nl.getLength() < 1){
     598                        cachecounter = 1;
     599                }else {
     600                        cachecounter = Integer.parseInt(nl.item(nl.getLength()-1).getAttributes().getNamedItem("id").getNodeValue());
     601                }
     602                this.updateCachecounter();
     603                return is;
     604        }
     605
    508606}
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r911 r980  
    5858        private String actionContentType;
    5959        private String userMsg;
    60         private int repository=1;
     60        private int repository;
    6161        //private Map<String,Object> session;
    6262         private HttpServletRequest request;
    6363         private long duration = 0;
    6464         
     65         public GenericProxyAction(){
     66                 super();
     67                 initialize();
     68         }
     69         
     70         protected void  initialize(){
     71                 repository = 1;
     72         }
    6573        public String getQ() {
    6674                return q;
  • MDService2/trunk/MDService2/src/struts.xml

    r908 r980  
    198198                           <param name="format">{2}</param>
    199199                           <param name="actionkey">{1}</param>
     200                            <result type="stream">                         
     201                                <param name="contentType">${getActionContentType()}</param>
     202                                <param name="inputName">resultStream</param>                           
     203                            </result>
     204                </action>
     205               
     206                <action name="admin/cache/del" class="eu.clarin.cmdi.mdservice.action.AdminAction" method="del">
    200207                            <result type="stream">                         
    201208                                <param name="contentType">${getActionContentType()}</param>
Note: See TracChangeset for help on using the changeset viewer.