Results 1 to 5 of 5

Thread: [SOLVED] Fails to deploy....

  1. #1
    Chewie71 is offline Trained Alumni
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    371
    Rep Power
    8

    Default [SOLVED] Fails to deploy....

    I've created a zimlet with several files in it.

    edu_wiu_passwordExpiryChecker.xml
    edu_wiu_passwordExpiryChecker.js
    ldap.jsp
    image1.png
    image2.png

    I am in the directory where the files exist and type the following to create the zip file.
    Code:
    zip edu_wiu_passwordExpiryChecker.zip *
    That creates the zip file I need. When I go to deploy it however, I get an error in the mailbox.log.
    Code:
    zmzimletctl deploy edu_wiu_passwordExpiryChecker.zip
    ERROR:
    Code:
    2009-10-09 13:52:22,558 INFO  [Thread-71] [] zimlet - deploy
    java.io.FileNotFoundException: zimlet description not found: edu_wiu_passwordExpiryChecker.xml
            at com.zimbra.cs.zimlet.ZimletFile.initZimletDescription(ZimletFile.java:199)
            at com.zimbra.cs.zimlet.ZimletFile.initialize(ZimletFile.java:191)
            at com.zimbra.cs.zimlet.ZimletFile.<init>(ZimletFile.java:146)
            at com.zimbra.cs.service.admin.DeployZimlet$DeployThread.run(DeployZimlet.java:96)
            at java.lang.Thread.run(Thread.java:595)
    Any thoughts? I am running everything as the zimbra user.

    Matt

  2. #2
    JoshuaPrismon is offline Zimlet Guru & Moderator
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    Can you post the zimlet for us to look at?

  3. #3
    Chewie71 is offline Trained Alumni
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    371
    Rep Power
    8

    Default

    This code works fine in _dev. It just won't deploy.

    Matt

    Code:
    ###edu_wiu_passwordExpiryChecker.js
    
    function edu_wiu_passwordExpiryChecker() { };
    
    edu_wiu_passwordExpiryChecker.prototype = new ZmZimletBase();
    edu_wiu_passwordExpiryChecker.prototype.constructor = edu_wiu_passwordExpiryChecker;
    edu_wiu_passwordExpiryChecker.prototype.init = function() {
        try { console.info( '[ZIMLET] edu_wiu_passwordExpiryChecker has loaded' ); } catch (err) {}
            // connect to your ldap, check the password expiry date
            var reqParam = 'action=getpwexp';
            var urlStr = this.getResource("ldap.jsp");
            var url = AjxStringUtil.urlEncode(urlStr);
            var result=AjxRpc.invoke(null, url + "?" + reqParam, null, null, true);
            this.xmlDoc = result.xml;
            var xmlDoc = this.xmlDoc;
    
            if (this.qXml("length","passwordExpirationTime") !=0 ) {
                    var todaysDate = new Date();
                    var expiryDate = this.qXml("value","passwordExpirationTime");
                    var yyyy = expiryDate.substring(0,4);
                    var mo = expiryDate.substring(4,6);
                    var da = expiryDate.substring(6,8);
                    var hh = expiryDate.substring(8,10);
                    var mm = expiryDate.substring(10,12);
                    var ss = expiryDate.substring(12,14);
                    var willExpire = new Date(mo+"/"+da+"/"+yyyy+" "+hh+":"+mm+":"+ss);
                    willExpire = willExpire - todaysDate;
                    if ((willExpire <= 1209600000)&&(willExpire>0)) {
                            //expiration less than 14 days away
                            willExpire = this.convertMilliseconds(willExpire);
                            this.showExpiryMessage(willExpire);
                    }
            }
    };
    
    edu_wiu_passwordExpiryChecker.prototype.checkForPluralTime = function(varname,varval) {
            var text = "";
            if (varval == 0) {text = "";}
                    else if (varval == 1) {text = varval + " " + varname.substring(0,varname.length-1) + ", ";}
                    else {text = varval + " " + varname + ", ";}
            return text;
    };
    
    edu_wiu_passwordExpiryChecker.prototype.convertMilliseconds = function(millisecs) {
            if (millisecs <= 60000) {return " less than 60 seconds";}
            var x = millisecs/1000;
            var seconds = Math.floor(x%60);
            seconds = this.checkForPluralTime("seconds", seconds);
            x = x/60;
            var minutes = Math.floor(x%60);
            minutes = this.checkForPluralTime("minutes", minutes);
            minutes = minutes.substring(0,minutes.length-2); //strip trailing ", " from minutes
            x = x/60;
            var hours = Math.floor(x%24);
            hours = this.checkForPluralTime("hours", hours);
            x = x/24;
            var days = Math.floor(x);
            days = this.checkForPluralTime("days", days);
            return days+hours+minutes;//+seconds+" seconds";
    };
    
    edu_wiu_passwordExpiryChecker.prototype.showExpiryMessage = function(expiryDate) {
        try { console.info( 'showExpiryMessage' ); } catch (err) {}
        var view = new DwtComposite(this.getShell());
            var el = view.getHtmlElement();
            var div = document.createElement("div");
            var html=new Array();
            var i=0;
            html[i++] = '<p><center>Your password will expire in '+ expiryDate +'.<br/>Please go to <a href="http://www.wiu.edu/guava" target=_new>GUAVA</a> to change it as soon as possible.</p><br/>';
            //html[i++] = '<a href="https://www.wiu.edu/utech/passwordChange" target="_blank"><img src="./more_info.png"></a>'
            html[i++] = '<button target="_blank" onclick="location.href=\'https://www.wiu.edu/utech/passwordChange\'"><div align="center"><b> More Info </div></button>';
            html[i++] = '&nbsp&nbsp&nbsp&nbsp&nbsp'
            html[i++] = '<button target="_blank" onclick="location.href=\'https://www.wiu.edu/guava/password.sphp\'"><div align="center"><b> Change Password </div></button></center>';
            div.innerHTML = html.join('');
    
            //div.innerHTML = '<p>Your password will expire in '+ expiryDate +'. Please go to <a href="http://www.wiu.edu/guava" target=_new>GUAVA</a> to change it as soon as possible.</p>';
        el.appendChild(div);
        var dialog_args = {
            title   : "Password Expiration Notice",
            view    : view
        };
        var dlg = this._createDialog(dialog_args);
        dlg.getButton(DwtDialog.OK_BUTTON).setText("Close");
        dlg.setButtonVisible(DwtDialog.CANCEL_BUTTON, false);
        // dlg.setButtonListener block is optional; you can use it to augment the default OK button handler
        // (popdown, dispose) to do interesting things like set a flag somewhere that the user has been notified, etc.
        // As it is below, it duplicates the default OK button handler.
        dlg.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(this, function() {
            dlg.popdown();
            dlg.dispose();
        }));
        dlg.popup();
    };
    
    edu_wiu_passwordExpiryChecker.prototype.qXml = function(mode,key) {
            if (mode == "length") {
                    return parseInt(this.xmlDoc.getElementsByTagName(key).length);
            }
            else if (mode == "value") {
                    return this.xmlDoc.getElementsByTagName(key)[0].childNodes[0].nodeValue;
            }
            else {
                    return;
            }
    };
    Code:
    ###edu_wiu_passwordExpiryChecker.xml
    
    <zimlet name="edu_wiu_passwordExpiryChecker" version="1.0" description="Zimlet to display a notice if the user's password is about to expire">
            <summary>
                    This zimlet checks the password expiry date for the current user in LDAP and displays a notice if their password is about to expire or has expired and they are using a grace login.
            </summary>
            <include>edu_wiu_passwordExpiryChecker.js</include>
            <handlerObject>edu_wiu_passwordExpiryChecker</handlerObject>
    </zimlet>
    Code:
    ### ldap.jsp
    
    <%@ page contentType='text/xml'%>
    <%@ page language="java" import="com.sun.jndi.ldap.*, java.lang.String, java.io.*, java.util.*, javax.naming.*, javax.naming.directory.*, org.apache.commons.lang.StringEscapeUtils"%>
    <%@ page import="com.zimbra.cs.account.Provisioning" %>
    <%@ page import="com.zimbra.cs.account.Provisioning.AccountBy" %>
    <%@ page import="com.zimbra.cs.account.Account" %>
    <%@ page import="com.zimbra.cs.account.AuthToken" %>
    
    
    <%
    final class LdapStuff{
            //Class Variable Declarations
            private String action;
            private String zimbraUid;
            private PrintWriter output;
    
            public String init(String args[], PrintWriter output){
                    zimbraUid = args[0];
                    action = args[1];
                    output = output;
                    //output.println("action: ["+action+"]");
                    String result = "";
                    if (action.equals("getpwexp")){
                            result = GetPasswordExpirationResult("(uid="+zimbraUid+")");
                    }
                    return result;
            }//end init()
    
            private String GetPasswordExpirationResult(String filter){
                    String value = "";
                    try {
                            DirContext ctx = LdapConn();
                            SearchControls searchControls = new SearchControls();
                            searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
                            String[] attrNames = {"passwordExpirationTime"};
                            searchControls.setReturningAttributes(attrNames);
                            NamingEnumeration results = ctx.search("dc=wiu,dc=edu", filter, searchControls);
                            ctx.close();
                            value = GetResultXml(results);
                    }
                    catch (NamingException e){
                            //Authentication Failed
                            output.println("Caught Error: ");
                            output.println(e);
                    } //end try-catch
    
                    return value;
            }
    
            private String GetResultXml(NamingEnumeration results){
                    String xml = "";
                    try{
                            while (results.hasMoreElements()) {
                                    SearchResult result = (SearchResult)results.nextElement();
                                    Attributes attrs = result.getAttributes();
    
                                    if ( attrs != null ){
                                            NamingEnumeration enumer = attrs.getAll();
                                            Attribute attr;
                                            xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                                            xml = xml.concat("<wiu_dir>");
                                            while( enumer != null && enumer.hasMore() )
                                            {
                                                    attr = ( Attribute )enumer.next();
                                                    //String escXml = StringEscapeUtils.escapeXML(attr.get().toString());
                                                    xml=xml.concat("<"+attr.getID()+">"+attr.get().toString()+"</"+attr.getID()+">");
                                                    //value = value.concat(attr.getID()+"::"+attr.get().toString());
                                            }//endwhile
                                            xml = xml.concat("</wiu_dir>");
                                    }//endif
    
                            }//endwhile
                    }//endtry
                    catch (Exception e){
                            output.println("Exception: "+ e);
                    }//endcatch
                    return xml;
            }
    
            private DirContext LdapConn(){
                    DirContext ctx = null;
                    String ldapServerName = "HOST";
                    String user = "USER";
                    String pass = "PASS";
                    String dn= "cn=" . concat(user) . concat(",ou=applications,dc=wiu,dc=edu");
    
                    Properties env = new Properties();
                    env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory" );
                    env.put("java.naming.ldap.version", "3");
                    env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName + "/");
                    env.put( Context.SECURITY_AUTHENTICATION, "simple");
                    env.put( Context.SECURITY_PRINCIPAL, dn );
                    env.put( Context.SECURITY_CREDENTIALS, pass );
    
                    try{
                            ctx = new InitialDirContext( env );
                    }
                    catch (NamingException e){
                            //Authentication Failed
                            output.println("Caught Error: ");
                            output.println(e);
                    }
                    return ctx;
            }
    
    } //end LdapStuff class
    
    Cookie[] cookies = request.getCookies();
      String authTokenString = "";
      for (Cookie cooky : cookies) {
          if (cooky.getName().equals("ZM_AUTH_TOKEN")) {
              authTokenString = cooky.getValue();
          }
      }
    AuthToken authToken = AuthToken.getAuthToken(authTokenString);
    Account acct = Provisioning.getInstance().get(AccountBy.id, authToken.getAccountId());
    
    String zimbraUid = acct.getUid();
    String action = (String) request.getParameter("action");
    
    PrintWriter output = response.getWriter();
    
    //output.println("action: "+action+"  :::");
    
    String args[] = {zimbraUid, action};
    String foo = new LdapStuff().init(args, output);
    output.println(foo);
    
    %>

  4. #4
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    365
    Rep Power
    8

    Default

    Yeah, no problems with the code. I had this error once too.

    The deployment bug when you have uppercase characters in the zimlet name.
    Last edited by tdesorbaix; 10-13-2009 at 07:38 AM.

  5. #5
    Chewie71 is offline Trained Alumni
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    371
    Rep Power
    8

    Default

    That was it. Changing all instances of the name to all lowercase solved the problem.

    Thanks,
    Matt

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Contact Collector fails to deploy
    By mckoz in forum Zimlets
    Replies: 0
    Last Post: 02-11-2009, 11:30 AM
  2. xmbx_search Zimlet fails to deploy
    By ropana in forum Zimlets
    Replies: 7
    Last Post: 12-12-2008, 03:31 PM
  3. [SOLVED] All Zimlet Deploy Fails Zimbra 4.5.10
    By cantormath in forum Installation
    Replies: 7
    Last Post: 12-22-2007, 07:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •