Friday, 22 June 2012

Alfresco reset admin password

One of the problems that people are having is when they forget admin password, and what to do :D.

One of solutions is to create simple servet and execute one http get request, in witch you will reset admin password to "admin", and then change it to something else.


public class ResetAdminPassword extends HttpServlet {

    private static final long serialVersionUID = 589583745167158768L;
    private static final String USERNAME = "admin";
    private static final String PASSWORD = "admin";

    public class TemplateContentWork implements RunAsWork<Object> {

public TemplateContentWork() {

}

@Override
public Object doWork() throws Exception {

   try {
Repository.getServiceRegistry(getServletContext())
.getAuthenticationService()
.createAuthentication(USERNAME, PASSWORD.toCharArray());
   } catch (Exception ex) {
Repository.getServiceRegistry(getServletContext())
.getAuthenticationService()
.setAuthentication(USERNAME, PASSWORD.toCharArray());
   }

   return null;
}

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
TemplateContentWork contentWork = new TemplateContentWork();

AuthenticationUtil.setRunAsUser(USERNAME);
try {
   contentWork.doWork();
} catch (Exception e) {
   e.printStackTrace();
}
    }
}




add code like this into web.xml

 <servlet>
  <servlet-name>resetpassword</servlet-name>
  <servlet-class>...ResetAdminPassword </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>



 <servlet-mapping>
  <servlet-name> resetpassword </servlet-name>
  <url-pattern>/ resetpassword </url-pattern>
 </servlet-mapping>


This is one of the ways, you can add webscript and create action that will do this...
Hope this helps.


Saturday, 16 June 2012

Wicket Inter-component events example



Wicket 1.5.x brings  Inter-component events, what you can do with this is make autoupdateable components based on events sended by other components,
 I will show you easy and simple example how to do this.


Application for this example contans of one label and one ajax link, on ajax link click label should autoupdate. Ajax link does not know witch components are listening this event, it just changes model on click.

Model is for this example shared between label and ajax link, what you can do is to send model with event..

We have EventListenerLabel that extends Label:

public class EventListenerLabel extends Label {
public EventListenerLabel(String id,IModel<Integer> model) {
super(id,model);
setOutputMarkupId(true);
}
@Override
public void onEvent(IEvent<?> event) {
if (event.getPayload() instanceof UpdateEvent) if this is update event refresh i
                 {
Event update = (Event)event.getPayload();
                        update.getTarget().add(this);
                  }
}
}


Then we have  EventSenderAjaxLink that extends AjaxLink<Integer>:


public class EventSenderAjaxLink extends AjaxLink<Integer> {

public EventSenderAjaxLink(String id, IModel<Integer> model) {
super(id, model);
}

@Override
public void onClick(AjaxRequestTarget target) {
Integer obj= getModelObject();
setModelObject(++obj);//change model value
send(getPage(), Broadcast.BREADTH, new UpdateEvent(target)); //send event on click.

}

}


Page where this is shown is EventExamplePage :


public class EventExamplePage extends WebPage {


public EventExamplePage() {

IModel<Integer> model = new Model<Integer>(0);


add(new EventListenerLabel("label", model));
add(new EventSenderAjaxLink("link", model));


}


}




Then we have UpdateEvent, AbstractEvent classes and Event interface.


public interface Event {
public AjaxRequestTarget getTarget();
}



public class AbstractEvent {
private final AjaxRequestTarget target;


    public AbstractEvent(AjaxRequestTarget target)
    {
        this.target = target;
    }
    public AjaxRequestTarget getTarget()
    {
        return target;
    }
}





public class UpdateEvent extends AbstractEvent implements Event{


public UpdateEvent(AjaxRequestTarget target) {
super(target);
}


}




This is one way to use events in wicket.
    Hope that this was helpfull to you.

Monday, 8 November 2010

How to change alfresco favicon?

in repo.tld
      <name>page</name>
      <tag-class>org.alfresco.web.ui.repo.tag.PageTag</tag-class>

change to your class .

create your PageTag class with same java code as your alfresco version.
in doStartTag(){


out.write("<LINK REL=\"SHORTCUT ICON\" HREF=\"" + reqPath
+ "/icon.ico\" />");

}

//remark in alfresco.war add icon.ico .

Saturday, 2 October 2010

Send HTML email from alfresco 3.3 with attachment tutorial and code








In my first blog I will provide you with feature to send email using alfresco javascript by executing action and sending HTML email, also you can send attachment with this mail you can use templates and so on, same as using old mail action.

first javascript:

var mail = actions.create("mail2");
mail.parameters.to = "savic.prvoslav[at]gmail.com";
mail.parameters.subject = "Html test";
mail.parameters.from = "savic.prvoslav[at]gmail.com";
mail.parameters.text = "My name is Savić Prvoslav<b> if you see this it is very bold</b>";

mail.parameters.node=document;
//here you set document to sent via email, you can comment this line if you do not want to send doc :)
mail.execute(document);








you can download jar-source-file .


How to install: 
 put jar file in alfresco/web-inf/lib , restart alfresco, use the javascript.


How to set up Outbound Email Configuration for Gmail:
alfresco3.3G\tomcat\shared\classes\alfresco-global.properties


#
# Outbound Email Configuration
#-------------
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=username
mail.password=pass
mail.smtps.starttls.enable=true
mail.smtps.auth=true
mail.from.default=defaultEmail

















In case of passing the rapidshare.limit just post comment and I will update file for you.

Thursday, 23 September 2010

Finaly starting....




For last year or so i have been working with something so cool, my job as a developer changed dramatically, from not so interesting to OMG great every day different with new challenges. I have started then to work with Alfresco, for project www.organizeddocs.com and www.netdokumenti.com, which are mostly the same projects. Any how, path was very hard, mostly because of lack of knowledge and because some things was hard to do at start... After some time I have picked up and felt great working as a lead programmer on this projects... Few key features ware on the list, OCR-import of jpeg and transforming it into searchable pdf, integration with zoho.com-so all documents could be online edited, really cool thing I might say. Also import from google docs and so on... list is very very big ....



What is the idea on these two projects, well first of all idea is simple one, as on every other good one, let user have office online . Let them have high quality system, which they do not have to bother with installing and administering , let it work all time and with no errors, and that users have someone on telephone to call when they want something. And there is one more thing, and that is to cost less money. Well how is this possible ? Here is only one way go to NetDokumenti.com and OrganizedDocs.com. oh yea it is very very low cost!

With starting price of $19 per month, OrganizedDocs will provide you with complete online document management system with version control and online document creation and document editing. Minimal return of investment is 3 times monthly price! OrganizedDocs will pay for itself after one month of usage!

Wednesday, 22 September 2010

Blog future plan

Recently I have decided to create some content here on my blog,
after some thought decision has been made to do some cool things for alfresco that there are none on internet or the one that exist are not very nice.
One of my first ideas are to create Alfresco browser integration with google docs , like share has.
Jboss install instruction.
So if you have any ideas at all, please help me decide. I need 10 ideas for start up, and I have only a few good.